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

pull/163/head
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);

@ -6,6 +6,7 @@
\
{"AddWorldObject", WorldFunctions::AddWorldObject},\
{"SetBaseEventCell", WorldFunctions::SetBaseEventCell},\
{"SetContainerChangesAction", WorldFunctions::SetContainerChangesAction},\
\
{"SetObjectRefId", WorldFunctions::SetObjectRefId},\
{"SetObjectRefNumIndex", WorldFunctions::SetObjectRefNumIndex},\
@ -35,6 +36,8 @@
{"GetObjectRotY", WorldFunctions::GetObjectRotY},\
{"GetObjectRotZ", WorldFunctions::GetObjectRotZ},\
\
{"SendContainer", WorldFunctions::SendContainer},\
\
{"SendObjectDelete", WorldFunctions::SendObjectDelete},\
{"SendObjectPlace", WorldFunctions::SendObjectPlace},\
{"SendObjectScale", WorldFunctions::SendObjectScale},\
@ -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