[Server] Add script functions that read & send ScriptGlobalShort packets

pull/541/head
David Cernat 5 years ago
parent 0d51eb5b23
commit ca21bc35c2

@ -254,6 +254,16 @@ const char *ObjectFunctions::GetVideoFilename(unsigned int index) noexcept
return readObjectList->baseObjects.at(index).videoFilename.c_str(); return readObjectList->baseObjects.at(index).videoFilename.c_str();
} }
const char *ObjectFunctions::GetScriptVariableName(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).varName.c_str();
}
int ObjectFunctions::GetScriptVariableShortValue(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).shortVal;
}
unsigned int ObjectFunctions::GetContainerChangesSize(unsigned int objectIndex) noexcept unsigned int ObjectFunctions::GetContainerChangesSize(unsigned int objectIndex) noexcept
{ {
return readObjectList->baseObjects.at(objectIndex).containerItemCount; return readObjectList->baseObjects.at(objectIndex).containerItemCount;
@ -436,6 +446,16 @@ void ObjectFunctions::SetObjectDoorDestinationRotation(double x, double z) noexc
tempObject.destinationPosition.rot[2] = z; tempObject.destinationPosition.rot[2] = z;
} }
void ObjectFunctions::SetScriptVariableName(const char* varName) noexcept
{
tempObject.varName = varName;
}
void ObjectFunctions::SetScriptVariableShortValue(int shortVal) noexcept
{
tempObject.shortVal = shortVal;
}
void ObjectFunctions::SetPlayerAsObject(unsigned short pid) noexcept void ObjectFunctions::SetPlayerAsObject(unsigned short pid) noexcept
{ {
Player *player; Player *player;
@ -622,6 +642,17 @@ void ObjectFunctions::SendVideoPlay(bool sendToOtherPlayers, bool skipAttachedPl
packet->Send(true); packet->Send(true);
} }
void ObjectFunctions::SendScriptGlobalShort(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_SCRIPT_GLOBAL_SHORT);
packet->setObjectList(&writeObjectList);
if (!skipAttachedPlayer)
packet->Send(false);
if (sendToOtherPlayers)
packet->Send(true);
}
void ObjectFunctions::SendConsoleCommand(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept void ObjectFunctions::SendConsoleCommand(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{ {
mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_CONSOLE_COMMAND); mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_CONSOLE_COMMAND);

@ -54,6 +54,9 @@
\ \
{"GetVideoFilename", ObjectFunctions::GetVideoFilename},\ {"GetVideoFilename", ObjectFunctions::GetVideoFilename},\
\ \
{"GetScriptVariableName", ObjectFunctions::GetScriptVariableName},\
{"GetScriptVariableShortValue", ObjectFunctions::GetScriptVariableShortValue},\
\
{"GetContainerChangesSize", ObjectFunctions::GetContainerChangesSize},\ {"GetContainerChangesSize", ObjectFunctions::GetContainerChangesSize},\
{"GetContainerItemRefId", ObjectFunctions::GetContainerItemRefId},\ {"GetContainerItemRefId", ObjectFunctions::GetContainerItemRefId},\
{"GetContainerItemCount", ObjectFunctions::GetContainerItemCount},\ {"GetContainerItemCount", ObjectFunctions::GetContainerItemCount},\
@ -93,6 +96,9 @@
{"SetObjectDoorDestinationPosition", ObjectFunctions::SetObjectDoorDestinationPosition},\ {"SetObjectDoorDestinationPosition", ObjectFunctions::SetObjectDoorDestinationPosition},\
{"SetObjectDoorDestinationRotation", ObjectFunctions::SetObjectDoorDestinationRotation},\ {"SetObjectDoorDestinationRotation", ObjectFunctions::SetObjectDoorDestinationRotation},\
\ \
{"SetScriptVariableName", ObjectFunctions::SetScriptVariableName},\
{"SetScriptVariableShortValue", ObjectFunctions::SetScriptVariableShortValue},\
\
{"SetPlayerAsObject", ObjectFunctions::SetPlayerAsObject},\ {"SetPlayerAsObject", ObjectFunctions::SetPlayerAsObject},\
\ \
{"SetContainerItemRefId", ObjectFunctions::SetContainerItemRefId},\ {"SetContainerItemRefId", ObjectFunctions::SetContainerItemRefId},\
@ -118,6 +124,7 @@
{"SendDoorDestination", ObjectFunctions::SendDoorDestination},\ {"SendDoorDestination", ObjectFunctions::SendDoorDestination},\
{"SendContainer", ObjectFunctions::SendContainer},\ {"SendContainer", ObjectFunctions::SendContainer},\
{"SendVideoPlay", ObjectFunctions::SendVideoPlay},\ {"SendVideoPlay", ObjectFunctions::SendVideoPlay},\
{"SendScriptGlobalShort", ObjectFunctions::SendScriptGlobalShort},\
{"SendConsoleCommand", ObjectFunctions::SendConsoleCommand},\ {"SendConsoleCommand", ObjectFunctions::SendConsoleCommand},\
\ \
{"ReadLastObjectList", ObjectFunctions::ReadLastObjectList},\ {"ReadLastObjectList", ObjectFunctions::ReadLastObjectList},\
@ -508,6 +515,9 @@ public:
*/ */
static const char *GetVideoFilename(unsigned int index) noexcept; static const char *GetVideoFilename(unsigned int index) noexcept;
static const char *GetScriptVariableName(unsigned int index) noexcept;
static int GetScriptVariableShortValue(unsigned int index) noexcept;
/** /**
* \brief Get the number of container item indexes of the object at a certain index in the * \brief Get the number of container item indexes of the object at a certain index in the
* read object list. * read object list.
@ -841,6 +851,9 @@ public:
*/ */
static void SetObjectDoorDestinationRotation(double x, double z) noexcept; static void SetObjectDoorDestinationRotation(double x, double z) noexcept;
static void SetScriptVariableName(const char* varName) noexcept;
static void SetScriptVariableShortValue(int shortVal) noexcept;
/** /**
* \brief Set a player as the object in the temporary object stored on the server. * \brief Set a player as the object in the temporary object stored on the server.
* Currently only used for ConsoleCommand packets. * Currently only used for ConsoleCommand packets.
@ -1057,6 +1070,8 @@ public:
*/ */
static void SendVideoPlay(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; static void SendVideoPlay(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
static void SendScriptGlobalShort(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
/** /**
* \brief Send a ConsoleCommand packet. * \brief Send a ConsoleCommand packet.
* *

Loading…
Cancel
Save