forked from mirror/openmw-tes3mp
[General] Sketch out server requests to players for container data
This commit is contained in:
parent
2ed9ae5739
commit
c8cbfbef62
7 changed files with 65 additions and 34 deletions
|
@ -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);
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
\
|
\
|
||||||
{"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},\
|
||||||
|
@ -35,6 +36,8 @@
|
||||||
{"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},\
|
||||||
{"SendObjectScale", WorldFunctions::SendObjectScale},\
|
{"SendObjectScale", WorldFunctions::SendObjectScale},\
|
||||||
|
@ -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…
Reference in a new issue