[General] Sketch out server requests to players for container data

coverity_scan^2
David Cernat 8 years ago
parent 2ed9ae5739
commit c8cbfbef62

@ -67,6 +67,11 @@ void WorldFunctions::SetBaseEventCell(const char* cellDescription) noexcept
} }
} }
void WorldFunctions::SetContainerChangesAction(int action) noexcept
{
baseEvent->containerChanges.action = action;
}
void WorldFunctions::SetObjectRefId(const char* refId) noexcept void WorldFunctions::SetObjectRefId(const char* refId) noexcept
{ {
tempWorldObject.refId = refId; tempWorldObject.refId = refId;
@ -196,6 +201,11 @@ double WorldFunctions::GetObjectRotZ(unsigned int i) noexcept
return mwmp::Networking::getPtr()->getLastEvent()->objectChanges.objects.at(i).pos.rot[2]; return mwmp::Networking::getPtr()->getLastEvent()->objectChanges.objects.at(i).pos.rot[2];
} }
void WorldFunctions::SendContainer() noexcept
{
mwmp::Networking::get().getWorldController()->GetPacket(ID_CONTAINER)->Send(baseEvent, baseEvent->guid);
}
void WorldFunctions::SendObjectDelete() noexcept void WorldFunctions::SendObjectDelete() noexcept
{ {
mwmp::Networking::get().getWorldController()->GetPacket(ID_OBJECT_DELETE)->Send(baseEvent, baseEvent->guid); mwmp::Networking::get().getWorldController()->GetPacket(ID_OBJECT_DELETE)->Send(baseEvent, baseEvent->guid);

@ -2,38 +2,41 @@
#define OPENMW_WORLD_HPP #define OPENMW_WORLD_HPP
#define WORLDFUNCTIONS \ #define WORLDFUNCTIONS \
{"CreateBaseEvent", WorldFunctions::CreateBaseEvent},\ {"CreateBaseEvent", WorldFunctions::CreateBaseEvent},\
\ \
{"AddWorldObject", WorldFunctions::AddWorldObject},\ {"AddWorldObject", WorldFunctions::AddWorldObject},\
{"SetBaseEventCell", WorldFunctions::SetBaseEventCell},\ {"SetBaseEventCell", WorldFunctions::SetBaseEventCell},\
{"SetContainerChangesAction", WorldFunctions::SetContainerChangesAction},\
\ \
{"SetObjectRefId", WorldFunctions::SetObjectRefId},\ {"SetObjectRefId", WorldFunctions::SetObjectRefId},\
{"SetObjectRefNumIndex", WorldFunctions::SetObjectRefNumIndex},\ {"SetObjectRefNumIndex", WorldFunctions::SetObjectRefNumIndex},\
{"SetObjectCharge", WorldFunctions::SetObjectCharge},\ {"SetObjectCharge", WorldFunctions::SetObjectCharge},\
{"SetObjectCount", WorldFunctions::SetObjectCount},\ {"SetObjectCount", WorldFunctions::SetObjectCount},\
{"SetObjectGoldValue", WorldFunctions::SetObjectGoldValue},\ {"SetObjectGoldValue", WorldFunctions::SetObjectGoldValue},\
{"SetObjectScale", WorldFunctions::SetObjectScale},\ {"SetObjectScale", WorldFunctions::SetObjectScale},\
{"SetObjectDoorState", WorldFunctions::SetObjectDoorState},\ {"SetObjectDoorState", WorldFunctions::SetObjectDoorState},\
{"SetObjectLockLevel", WorldFunctions::SetObjectLockLevel},\ {"SetObjectLockLevel", WorldFunctions::SetObjectLockLevel},\
{"SetObjectPosition", WorldFunctions::SetObjectPosition},\ {"SetObjectPosition", WorldFunctions::SetObjectPosition},\
{"SetObjectRotation", WorldFunctions::SetObjectRotation},\ {"SetObjectRotation", WorldFunctions::SetObjectRotation},\
\ \
{"GetObjectChangesSize", WorldFunctions::GetObjectChangesSize},\ {"GetObjectChangesSize", WorldFunctions::GetObjectChangesSize},\
\ \
{"GetObjectRefId", WorldFunctions::GetObjectRefId},\ {"GetObjectRefId", WorldFunctions::GetObjectRefId},\
{"GetObjectRefNumIndex", WorldFunctions::GetObjectRefNumIndex},\ {"GetObjectRefNumIndex", WorldFunctions::GetObjectRefNumIndex},\
{"GetObjectCharge", WorldFunctions::GetObjectCharge},\ {"GetObjectCharge", WorldFunctions::GetObjectCharge},\
{"GetObjectCount", WorldFunctions::GetObjectCount},\ {"GetObjectCount", WorldFunctions::GetObjectCount},\
{"GetObjectGoldValue", WorldFunctions::GetObjectGoldValue},\ {"GetObjectGoldValue", WorldFunctions::GetObjectGoldValue},\
{"GetObjectScale", WorldFunctions::GetObjectScale},\ {"GetObjectScale", WorldFunctions::GetObjectScale},\
{"GetObjectDoorState", WorldFunctions::GetObjectDoorState},\ {"GetObjectDoorState", WorldFunctions::GetObjectDoorState},\
{"GetObjectLockLevel", WorldFunctions::GetObjectLockLevel},\ {"GetObjectLockLevel", WorldFunctions::GetObjectLockLevel},\
{"GetObjectPosX", WorldFunctions::GetObjectPosX},\ {"GetObjectPosX", WorldFunctions::GetObjectPosX},\
{"GetObjectPosY", WorldFunctions::GetObjectPosY},\ {"GetObjectPosY", WorldFunctions::GetObjectPosY},\
{"GetObjectPosZ", WorldFunctions::GetObjectPosZ},\ {"GetObjectPosZ", WorldFunctions::GetObjectPosZ},\
{"GetObjectRotX", WorldFunctions::GetObjectRotX},\ {"GetObjectRotX", WorldFunctions::GetObjectRotX},\
{"GetObjectRotY", WorldFunctions::GetObjectRotY},\ {"GetObjectRotY", WorldFunctions::GetObjectRotY},\
{"GetObjectRotZ", WorldFunctions::GetObjectRotZ},\ {"GetObjectRotZ", WorldFunctions::GetObjectRotZ},\
\
{"SendContainer", WorldFunctions::SendContainer},\
\ \
{"SendObjectDelete", WorldFunctions::SendObjectDelete},\ {"SendObjectDelete", WorldFunctions::SendObjectDelete},\
{"SendObjectPlace", WorldFunctions::SendObjectPlace},\ {"SendObjectPlace", WorldFunctions::SendObjectPlace},\
@ -54,6 +57,7 @@ public:
static void AddWorldObject() noexcept; static void AddWorldObject() noexcept;
static void SetBaseEventCell(const char* cellDescription) noexcept; static void SetBaseEventCell(const char* cellDescription) noexcept;
static void SetContainerChangesAction(int action) noexcept;
static void SetObjectRefId(const char* refId) noexcept; static void SetObjectRefId(const char* refId) noexcept;
static void SetObjectRefNumIndex(int refNumIndex) noexcept; static void SetObjectRefNumIndex(int refNumIndex) noexcept;
@ -83,6 +87,8 @@ public:
static double GetObjectRotY(unsigned int i) noexcept; static double GetObjectRotY(unsigned int i) noexcept;
static double GetObjectRotZ(unsigned int i) noexcept; static double GetObjectRotZ(unsigned int i) noexcept;
static void SendContainer() noexcept;
static void SendObjectDelete() noexcept; static void SendObjectDelete() noexcept;
static void SendObjectPlace() noexcept; static void SendObjectPlace() noexcept;
static void SendObjectScale() noexcept; static void SendObjectScale() noexcept;

@ -735,6 +735,7 @@ void Networking::processWorldPacket(RakNet::Packet *packet)
WorldPacket *myPacket = worldController.GetPacket(packet->data[0]); WorldPacket *myPacket = worldController.GetPacket(packet->data[0]);
WorldEvent *event = new WorldEvent(guid); WorldEvent *event = new WorldEvent(guid);
myPacket->Packet(&bsIn, event, false); myPacket->Packet(&bsIn, event, false);
switch (packet->data[0]) switch (packet->data[0])
@ -746,7 +747,13 @@ void Networking::processWorldPacket(RakNet::Packet *packet)
if (!ptrCellStore) return; if (!ptrCellStore) return;
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_CONTAINER"); LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_CONTAINER");
event->editContainer(ptrCellStore);
// If we've received a request for information, comply with it
if (event->containerChanges.action == mwmp::ContainerChanges::REQUEST)
event->sendContainers(ptrCellStore);
// Otherwise, edit containers based on the information received
else
event->editContainers(ptrCellStore);
break; break;
} }

@ -45,7 +45,12 @@ void WorldEvent::addContainerItem(ContainerItem containerItem)
containerChanges.items.push_back(containerItem); containerChanges.items.push_back(containerItem);
} }
void WorldEvent::editContainer(MWWorld::CellStore* cellStore) void WorldEvent::sendContainers(MWWorld::CellStore* cellStore)
{
}
void WorldEvent::editContainers(MWWorld::CellStore* cellStore)
{ {
WorldObject worldObject; WorldObject worldObject;

@ -18,7 +18,9 @@ namespace mwmp
void addObject(WorldObject worldObject); void addObject(WorldObject worldObject);
void addContainerItem(ContainerItem containerItem); void addContainerItem(ContainerItem containerItem);
void editContainer(MWWorld::CellStore* cellStore); void sendContainers(MWWorld::CellStore* cellStore);
void editContainers(MWWorld::CellStore* cellStore);
void placeObjects(MWWorld::CellStore* cellStore); void placeObjects(MWWorld::CellStore* cellStore);
void deleteObjects(MWWorld::CellStore* cellStore); void deleteObjects(MWWorld::CellStore* cellStore);
void lockObjects(MWWorld::CellStore* cellStore); void lockObjects(MWWorld::CellStore* cellStore);

@ -277,7 +277,7 @@ namespace MWScript
return MWBase::Environment::get().getWindowManager()->isGuiMode(); return MWBase::Environment::get().getWindowManager()->isGuiMode();
*/ */
return 0; return false;
} }
int InterpreterContext::getGlobalShort (const std::string& name) const int InterpreterContext::getGlobalShort (const std::string& name) const

@ -63,10 +63,11 @@ namespace mwmp
{ {
SET = 0, SET = 0,
ADD = 1, ADD = 1,
REMOVE = 2 REMOVE = 2,
REQUEST = 3
}; };
int action; // 0 - Clear and set in entirety, 1 - Add item, 2 - Remove item int action; // 0 - Clear and set in entirety, 1 - Add item, 2 - Remove item, 3 - Request items
}; };
class BaseEvent class BaseEvent

Loading…
Cancel
Save