forked from mirror/openmw-tes3mp
[Client] Simplify sending of world packets, part 2
This commit is contained in:
parent
b55a3d5eb2
commit
d7a760490e
7 changed files with 143 additions and 112 deletions
|
@ -208,6 +208,131 @@ void WorldEvent::sendObjectScale(MWWorld::Ptr ptr, int scale)
|
|||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_SCALE)->Send();
|
||||
}
|
||||
|
||||
void WorldEvent::sendObjectAnimPlay(MWWorld::Ptr ptr, std::string group, int mode)
|
||||
{
|
||||
cell = *ptr.getCell()->getCell();
|
||||
|
||||
mwmp::WorldObject worldObject;
|
||||
worldObject.refId = ptr.getCellRef().getRefId();
|
||||
worldObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex;
|
||||
worldObject.mpNum = ptr.getCellRef().getMpNum();
|
||||
worldObject.animGroup = group;
|
||||
worldObject.animMode = mode;
|
||||
addObject(worldObject);
|
||||
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_ANIM_PLAY)->setEvent(this);
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_ANIM_PLAY)->Send();
|
||||
}
|
||||
|
||||
void WorldEvent::sendDoorState(MWWorld::Ptr ptr, int state)
|
||||
{
|
||||
cell = *ptr.getCell()->getCell();
|
||||
|
||||
mwmp::WorldObject worldObject;
|
||||
worldObject.refId = ptr.getCellRef().getRefId();
|
||||
worldObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex;
|
||||
worldObject.mpNum = ptr.getCellRef().getMpNum();
|
||||
worldObject.doorState = state;
|
||||
addObject(worldObject);
|
||||
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_DOOR_STATE)->setEvent(this);
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_DOOR_STATE)->Send();
|
||||
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Door activation 1\n- cellRef: %s, %i\n- cell: %s\n- state: %s",
|
||||
worldObject.refId.c_str(), worldObject.refNumIndex, cell.getDescription().c_str(),
|
||||
worldObject.doorState ? "true" : "false");
|
||||
}
|
||||
|
||||
void WorldEvent::sendMusicPlay(std::string filename)
|
||||
{
|
||||
mwmp::WorldObject worldObject;
|
||||
worldObject.filename = filename;
|
||||
addObject(worldObject);
|
||||
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_MUSIC_PLAY)->setEvent(this);
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_MUSIC_PLAY)->Send();
|
||||
}
|
||||
|
||||
void WorldEvent::sendVideoPlay(std::string filename, bool allowSkipping)
|
||||
{
|
||||
mwmp::WorldObject worldObject;
|
||||
worldObject.filename = filename;
|
||||
worldObject.allowSkipping = allowSkipping;
|
||||
addObject(worldObject);
|
||||
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_VIDEO_PLAY)->setEvent(this);
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_VIDEO_PLAY)->Send();
|
||||
}
|
||||
|
||||
void WorldEvent::sendScriptLocalShort(MWWorld::Ptr ptr, int index, int shortVal)
|
||||
{
|
||||
cell = *ptr.getCell()->getCell();
|
||||
|
||||
mwmp::WorldObject worldObject;
|
||||
worldObject.refId = ptr.getCellRef().getRefId();
|
||||
worldObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex;
|
||||
worldObject.mpNum = ptr.getCellRef().getMpNum();
|
||||
worldObject.index = index;
|
||||
worldObject.shortVal = shortVal;
|
||||
addObject(worldObject);
|
||||
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_LOCAL_SHORT)->setEvent(this);
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_LOCAL_SHORT)->Send();
|
||||
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_SCRIPT_LOCAL_SHORT\n- cellRef: %s, %i\n- cell: %s\n- index: %i\n- shortVal: %i",
|
||||
worldObject.refId.c_str(), worldObject.refNumIndex, cell.getDescription().c_str(),
|
||||
worldObject.index, worldObject.shortVal);
|
||||
}
|
||||
|
||||
void WorldEvent::sendScriptLocalFloat(MWWorld::Ptr ptr, int index, float floatVal)
|
||||
{
|
||||
cell = *ptr.getCell()->getCell();
|
||||
|
||||
mwmp::WorldObject worldObject;
|
||||
worldObject.refId = ptr.getCellRef().getRefId();
|
||||
worldObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex;
|
||||
worldObject.mpNum = ptr.getCellRef().getMpNum();
|
||||
worldObject.index = index;
|
||||
worldObject.floatVal = floatVal;
|
||||
addObject(worldObject);
|
||||
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_LOCAL_FLOAT)->setEvent(this);
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_LOCAL_FLOAT)->Send();
|
||||
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_SCRIPT_LOCAL_FLOAT\n- cellRef: %s, %i\n- cell: %s\n- index: %i\n- floatVal: %f",
|
||||
worldObject.refId.c_str(), worldObject.refNumIndex, cell.getDescription().c_str(),
|
||||
worldObject.index, worldObject.floatVal);
|
||||
}
|
||||
|
||||
void WorldEvent::sendScriptMemberShort(std::string refId, int index, int shortVal)
|
||||
{
|
||||
mwmp::WorldObject worldObject;
|
||||
worldObject.refId = refId;
|
||||
worldObject.index = index;
|
||||
worldObject.shortVal = shortVal;
|
||||
addObject(worldObject);
|
||||
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_MEMBER_SHORT)->setEvent(this);
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_MEMBER_SHORT)->Send();
|
||||
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_SCRIPT_MEMBER_SHORT\n- cellRef: %s\n- index: %i\n- shortVal: %i",
|
||||
worldObject.refId.c_str(), worldObject.index, worldObject.shortVal);
|
||||
}
|
||||
|
||||
void WorldEvent::sendScriptGlobalShort(std::string varName, int shortVal)
|
||||
{
|
||||
mwmp::WorldObject worldObject;
|
||||
worldObject.varName = varName;
|
||||
worldObject.shortVal = shortVal;
|
||||
addObject(worldObject);
|
||||
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_GLOBAL_SHORT)->setEvent(this);
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_GLOBAL_SHORT)->Send();
|
||||
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_SCRIPT_GLOBAL_SHORT\n- varName: %s\n- shortVal: %i",
|
||||
worldObject.varName.c_str(), worldObject.shortVal);
|
||||
}
|
||||
|
||||
void WorldEvent::editActors(MWWorld::CellStore* cellStore)
|
||||
{
|
||||
WorldObject worldObject;
|
||||
|
|
|
@ -19,11 +19,20 @@ namespace mwmp
|
|||
|
||||
void sendActors(MWWorld::CellStore* cellStore);
|
||||
void sendContainers(MWWorld::CellStore* cellStore);
|
||||
|
||||
void sendObjectPlace(MWWorld::Ptr ptr);
|
||||
void sendObjectDelete(MWWorld::Ptr ptr);
|
||||
void sendObjectLock(MWWorld::Ptr ptr, int lockLevel);
|
||||
void sendObjectUnlock(MWWorld::Ptr ptr);
|
||||
void sendObjectScale(MWWorld::Ptr ptr, int scale);
|
||||
void sendObjectAnimPlay(MWWorld::Ptr ptr, std::string group, int mode);
|
||||
void sendDoorState(MWWorld::Ptr ptr, int state);
|
||||
void sendMusicPlay(std::string filename);
|
||||
void sendVideoPlay(std::string filename, bool allowSkipping);
|
||||
void sendScriptLocalShort(MWWorld::Ptr ptr, int index, int shortVal);
|
||||
void sendScriptLocalFloat(MWWorld::Ptr ptr, int index, float floatVal);
|
||||
void sendScriptMemberShort(std::string refId, int index, int shortVal);
|
||||
void sendScriptGlobalShort(std::string varName, int shortVal);
|
||||
|
||||
void editActors(MWWorld::CellStore* cellStore);
|
||||
void editContainers(MWWorld::CellStore* cellStore);
|
||||
|
|
|
@ -72,18 +72,7 @@ namespace MWScript
|
|||
if (mwmp::Main::isValidPacketScript(ptr.getClass().getScript(ptr)))
|
||||
{
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
worldEvent->cell = *ptr.getCell()->getCell();
|
||||
|
||||
mwmp::WorldObject worldObject;
|
||||
worldObject.refId = ptr.getCellRef().getRefId();
|
||||
worldObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex;
|
||||
worldObject.mpNum = ptr.getCellRef().getMpNum();
|
||||
worldObject.animGroup = group;
|
||||
worldObject.animMode = mode;
|
||||
worldEvent->addObject(worldObject);
|
||||
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_ANIM_PLAY)->setEvent(worldEvent);
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_ANIM_PLAY)->Send();
|
||||
worldEvent->sendObjectAnimPlay(ptr, group, mode);
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
|
|
|
@ -203,22 +203,7 @@ namespace MWScript
|
|||
if (sendPackets)
|
||||
{
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
worldEvent->cell = *mReference.getCell()->getCell();
|
||||
|
||||
mwmp::WorldObject worldObject;
|
||||
worldObject.refId = mReference.getCellRef().getRefId();
|
||||
worldObject.refNumIndex = mReference.getCellRef().getRefNum().mIndex;
|
||||
worldObject.mpNum = mReference.getCellRef().getMpNum();
|
||||
worldObject.index = index;
|
||||
worldObject.shortVal = value;
|
||||
worldEvent->addObject(worldObject);
|
||||
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_LOCAL_SHORT)->setEvent(worldEvent);
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_LOCAL_SHORT)->Send();
|
||||
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_SCRIPT_LOCAL_SHORT\n- cellRef: %s, %i\n- cell: %s\n- index: %i\n- shortVal: %i",
|
||||
worldObject.refId.c_str(), worldObject.refNumIndex, worldEvent->cell.getDescription().c_str(),
|
||||
worldObject.index, worldObject.shortVal);
|
||||
worldEvent->sendScriptLocalShort(mReference, index, value);
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
|
@ -250,22 +235,7 @@ namespace MWScript
|
|||
if (sendPackets && value == (int) value)
|
||||
{
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
worldEvent->cell = *mReference.getCell()->getCell();
|
||||
|
||||
mwmp::WorldObject worldObject;
|
||||
worldObject.refId = mReference.getCellRef().getRefId();
|
||||
worldObject.refNumIndex = mReference.getCellRef().getRefNum().mIndex;
|
||||
worldObject.mpNum = mReference.getCellRef().getMpNum();
|
||||
worldObject.index = index;
|
||||
worldObject.floatVal = value;
|
||||
worldEvent->addObject(worldObject);
|
||||
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_LOCAL_FLOAT)->setEvent(worldEvent);
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_LOCAL_FLOAT)->Send();
|
||||
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_SCRIPT_LOCAL_FLOAT\n- cellRef: %s, %i\n- cell: %s\n- index: %i\n- floatVal: %f",
|
||||
worldObject.refId.c_str(), worldObject.refNumIndex, worldEvent->cell.getDescription().c_str(),
|
||||
worldObject.index, worldObject.floatVal);
|
||||
worldEvent->sendScriptLocalFloat(mReference, index, value);
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
|
@ -322,17 +292,7 @@ namespace MWScript
|
|||
if (sendPackets)
|
||||
{
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
|
||||
mwmp::WorldObject worldObject;
|
||||
worldObject.varName = name;
|
||||
worldObject.shortVal = value;
|
||||
worldEvent->addObject(worldObject);
|
||||
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_GLOBAL_SHORT)->setEvent(worldEvent);
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_GLOBAL_SHORT)->Send();
|
||||
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_SCRIPT_GLOBAL_SHORT\n- varName: %s\n- shortVal: %i",
|
||||
worldObject.varName.c_str(), worldObject.shortVal);
|
||||
worldEvent->sendScriptGlobalShort(name, value);
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
|
@ -667,18 +627,7 @@ namespace MWScript
|
|||
if (sendPackets && !global)
|
||||
{
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
|
||||
mwmp::WorldObject worldObject;
|
||||
worldObject.refId = id;
|
||||
worldObject.index = index;
|
||||
worldObject.shortVal = value;
|
||||
worldEvent->addObject(worldObject);
|
||||
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_MEMBER_SHORT)->setEvent(worldEvent);
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_MEMBER_SHORT)->Send();
|
||||
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_SCRIPT_MEMBER_SHORT\n- cellRef: %s\n- index: %i\n- shortVal: %i",
|
||||
worldObject.refId.c_str(), worldObject.index, worldObject.shortVal);
|
||||
worldEvent->sendScriptMemberShort(id, index, value);
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
|
|
|
@ -96,14 +96,7 @@ namespace MWScript
|
|||
through a script
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
|
||||
mwmp::WorldObject worldObject;
|
||||
worldObject.filename = name;
|
||||
worldObject.allowSkipping = allowSkipping;
|
||||
worldEvent->addObject(worldObject);
|
||||
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_VIDEO_PLAY)->setEvent(worldEvent);
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_VIDEO_PLAY)->Send();
|
||||
worldEvent->sendVideoPlay(name, allowSkipping);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
|
|
@ -80,13 +80,7 @@ namespace MWScript
|
|||
a script
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
|
||||
mwmp::WorldObject worldObject;
|
||||
worldObject.filename = sound;
|
||||
worldEvent->addObject(worldObject);
|
||||
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_MUSIC_PLAY)->setEvent(worldEvent);
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_MUSIC_PLAY)->Send();
|
||||
worldEvent->sendMusicPlay(sound);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
|
|
@ -2325,21 +2325,7 @@ namespace MWWorld
|
|||
Send an ID_DOOR_STATE packet every time a door is activated
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
worldEvent->cell = *door.getCell()->getCell();
|
||||
|
||||
mwmp::WorldObject worldObject;
|
||||
worldObject.refId = door.getCellRef().getRefId();
|
||||
worldObject.refNumIndex = door.getCellRef().getRefNum().mIndex;
|
||||
worldObject.mpNum = door.getCellRef().getMpNum();
|
||||
worldObject.doorState = state;
|
||||
worldEvent->addObject(worldObject);
|
||||
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_DOOR_STATE)->setEvent(worldEvent);
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_DOOR_STATE)->Send();
|
||||
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Door activation 1\n- cellRef: %s, %i\n- cell: %s\n- state: %s",
|
||||
worldObject.refId.c_str(), worldObject.refNumIndex, worldEvent->cell.getDescription().c_str(),
|
||||
worldObject.doorState ? "true" : "false");
|
||||
worldEvent->sendDoorState(door, state);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
@ -2356,21 +2342,7 @@ namespace MWWorld
|
|||
Send an ID_DOOR_STATE packet every time a door is activated
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
worldEvent->cell = *door.getCell()->getCell();
|
||||
|
||||
mwmp::WorldObject worldObject;
|
||||
worldObject.refId = door.getCellRef().getRefId();
|
||||
worldObject.refNumIndex = door.getCellRef().getRefNum().mIndex;
|
||||
worldObject.mpNum = door.getCellRef().getMpNum();
|
||||
worldObject.doorState = state;
|
||||
worldEvent->addObject(worldObject);
|
||||
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_DOOR_STATE)->setEvent(worldEvent);
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_DOOR_STATE)->Send();
|
||||
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Door activation 2\n- cellRef: %s, %i\n- cell: %s\n- state: %s",
|
||||
worldObject.refId.c_str(), worldObject.refNumIndex, worldEvent->cell.getDescription().c_str(),
|
||||
worldObject.doorState ? "true" : "false");
|
||||
worldEvent->sendDoorState(door, state);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue