[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
{
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];
}
void WorldFunctions::SendContainer() noexcept
{
mwmp::Networking::get().getWorldController()->GetPacket(ID_CONTAINER)->Send(baseEvent, baseEvent->guid);
}
void WorldFunctions::SendObjectDelete() noexcept
{
mwmp::Networking::get().getWorldController()->GetPacket(ID_OBJECT_DELETE)->Send(baseEvent, baseEvent->guid);

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

@ -735,6 +735,7 @@ void Networking::processWorldPacket(RakNet::Packet *packet)
WorldPacket *myPacket = worldController.GetPacket(packet->data[0]);
WorldEvent *event = new WorldEvent(guid);
myPacket->Packet(&bsIn, event, false);
switch (packet->data[0])
@ -746,7 +747,13 @@ void Networking::processWorldPacket(RakNet::Packet *packet)
if (!ptrCellStore) return;
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;
}

@ -45,7 +45,12 @@ void WorldEvent::addContainerItem(ContainerItem 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;

@ -18,7 +18,9 @@ namespace mwmp
void addObject(WorldObject worldObject);
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 deleteObjects(MWWorld::CellStore* cellStore);
void lockObjects(MWWorld::CellStore* cellStore);

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

@ -63,10 +63,11 @@ namespace mwmp
{
SET = 0,
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

Loading…
Cancel
Save