[Server] Use consistent order for WorldstateFunctions

This commit is contained in:
David Cernat 2020-02-14 11:51:31 +02:00
parent 60ca72a70a
commit ffead444db
2 changed files with 67 additions and 70 deletions

View File

@ -250,6 +250,12 @@ void WorldstateFunctions::AddEnforcedCollisionRefId(const char *refId) noexcept
writeWorldstate.enforcedCollisionRefIds.push_back(refId); writeWorldstate.enforcedCollisionRefIds.push_back(refId);
} }
void WorldstateFunctions::AddCellToReset(const char *cellDescription) noexcept
{
ESM::Cell cell = Utils::getCellFromDescription(cellDescription);
writeWorldstate.cellsToReset.push_back(cell);
}
void WorldstateFunctions::AddDestinationOverride(const char *oldCellDescription, const char *newCellDescription) noexcept void WorldstateFunctions::AddDestinationOverride(const char *oldCellDescription, const char *newCellDescription) noexcept
{ {
writeWorldstate.destinationOverrides[oldCellDescription] = newCellDescription; writeWorldstate.destinationOverrides[oldCellDescription] = newCellDescription;
@ -265,27 +271,21 @@ void WorldstateFunctions::ClearSynchronizedClientGlobalIds() noexcept
writeWorldstate.synchronizedClientGlobalIds.clear(); writeWorldstate.synchronizedClientGlobalIds.clear();
} }
void WorldstateFunctions::AddCellToReset(const char *cellDescription) noexcept
{
ESM::Cell cell = Utils::getCellFromDescription(cellDescription);
writeWorldstate.cellsToReset.push_back(cell);
}
void WorldstateFunctions::ClearEnforcedCollisionRefIds() noexcept void WorldstateFunctions::ClearEnforcedCollisionRefIds() noexcept
{ {
writeWorldstate.enforcedCollisionRefIds.clear(); writeWorldstate.enforcedCollisionRefIds.clear();
} }
void WorldstateFunctions::ClearDestinationOverrides() noexcept
{
writeWorldstate.destinationOverrides.clear();
}
void WorldstateFunctions::ClearCellsToReset() noexcept void WorldstateFunctions::ClearCellsToReset() noexcept
{ {
writeWorldstate.cellsToReset.clear(); writeWorldstate.cellsToReset.clear();
} }
void WorldstateFunctions::ClearDestinationOverrides() noexcept
{
writeWorldstate.destinationOverrides.clear();
}
void WorldstateFunctions::SaveMapTileImageFile(unsigned int index, const char *filePath) noexcept void WorldstateFunctions::SaveMapTileImageFile(unsigned int index, const char *filePath) noexcept
{ {
if (index >= readWorldstate->mapTiles.size()) if (index >= readWorldstate->mapTiles.size())
@ -431,38 +431,6 @@ void WorldstateFunctions::SendWorldCollisionOverride(unsigned short pid, bool se
packet->Send(true); packet->Send(true);
} }
void WorldstateFunctions::SendWorldDestinationOverride(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
writeWorldstate.guid = player->guid;
mwmp::WorldstatePacket *packet = mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_DESTINATION_OVERRIDE);
packet->setWorldstate(&writeWorldstate);
if (!skipAttachedPlayer)
packet->Send(false);
if (sendToOtherPlayers)
packet->Send(true);
}
void WorldstateFunctions::SendWorldRegionAuthority(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
writeWorldstate.guid = player->guid;
mwmp::WorldstatePacket *packet = mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_REGION_AUTHORITY);
packet->setWorldstate(&writeWorldstate);
packet->Send(false);
// This packet should always be sent to all other players
packet->Send(true);
}
void WorldstateFunctions::SendCellReset(unsigned short pid, bool sendToOtherPlayers) noexcept void WorldstateFunctions::SendCellReset(unsigned short pid, bool sendToOtherPlayers) noexcept
{ {
mwmp::WorldstatePacket *packet = mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_CELL_RESET); mwmp::WorldstatePacket *packet = mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_CELL_RESET);
@ -498,6 +466,37 @@ void WorldstateFunctions::SendCellReset(unsigned short pid, bool sendToOtherPlay
} }
} }
void WorldstateFunctions::SendWorldDestinationOverride(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
writeWorldstate.guid = player->guid;
mwmp::WorldstatePacket *packet = mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_DESTINATION_OVERRIDE);
packet->setWorldstate(&writeWorldstate);
if (!skipAttachedPlayer)
packet->Send(false);
if (sendToOtherPlayers)
packet->Send(true);
}
void WorldstateFunctions::SendWorldRegionAuthority(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
writeWorldstate.guid = player->guid;
mwmp::WorldstatePacket *packet = mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_REGION_AUTHORITY);
packet->setWorldstate(&writeWorldstate);
packet->Send(false);
// This packet should always be sent to all other players
packet->Send(true);
}
// All methods below are deprecated versions of methods from above // All methods below are deprecated versions of methods from above

View File

@ -61,11 +61,13 @@
{"AddSynchronizedClientScriptId", WorldstateFunctions::AddSynchronizedClientScriptId},\ {"AddSynchronizedClientScriptId", WorldstateFunctions::AddSynchronizedClientScriptId},\
{"AddSynchronizedClientGlobalId", WorldstateFunctions::AddSynchronizedClientGlobalId},\ {"AddSynchronizedClientGlobalId", WorldstateFunctions::AddSynchronizedClientGlobalId},\
{"AddEnforcedCollisionRefId", WorldstateFunctions::AddEnforcedCollisionRefId},\ {"AddEnforcedCollisionRefId", WorldstateFunctions::AddEnforcedCollisionRefId},\
{"AddCellToReset", WorldstateFunctions::AddCellToReset},\
{"AddDestinationOverride", WorldstateFunctions::AddDestinationOverride},\ {"AddDestinationOverride", WorldstateFunctions::AddDestinationOverride},\
\ \
{"ClearSynchronizedClientScriptIds", WorldstateFunctions::ClearSynchronizedClientScriptIds},\ {"ClearSynchronizedClientScriptIds", WorldstateFunctions::ClearSynchronizedClientScriptIds},\
{"ClearSynchronizedClientGlobalIds", WorldstateFunctions::ClearSynchronizedClientGlobalIds},\ {"ClearSynchronizedClientGlobalIds", WorldstateFunctions::ClearSynchronizedClientGlobalIds},\
{"ClearEnforcedCollisionRefIds", WorldstateFunctions::ClearEnforcedCollisionRefIds},\ {"ClearEnforcedCollisionRefIds", WorldstateFunctions::ClearEnforcedCollisionRefIds},\
{"ClearCellsToReset", WorldstateFunctions::ClearCellsToReset},\
{"ClearDestinationOverrides", WorldstateFunctions::ClearDestinationOverrides},\ {"ClearDestinationOverrides", WorldstateFunctions::ClearDestinationOverrides},\
\ \
{"SaveMapTileImageFile", WorldstateFunctions::SaveMapTileImageFile},\ {"SaveMapTileImageFile", WorldstateFunctions::SaveMapTileImageFile},\
@ -78,13 +80,10 @@
{"SendWorldTime", WorldstateFunctions::SendWorldTime},\ {"SendWorldTime", WorldstateFunctions::SendWorldTime},\
{"SendWorldWeather", WorldstateFunctions::SendWorldWeather},\ {"SendWorldWeather", WorldstateFunctions::SendWorldWeather},\
{"SendWorldCollisionOverride", WorldstateFunctions::SendWorldCollisionOverride},\ {"SendWorldCollisionOverride", WorldstateFunctions::SendWorldCollisionOverride},\
{"SendCellReset", WorldstateFunctions::SendCellReset},\
{"SendWorldDestinationOverride", WorldstateFunctions::SendWorldDestinationOverride},\ {"SendWorldDestinationOverride", WorldstateFunctions::SendWorldDestinationOverride},\
{"SendWorldRegionAuthority", WorldstateFunctions::SendWorldRegionAuthority},\ {"SendWorldRegionAuthority", WorldstateFunctions::SendWorldRegionAuthority},\
\ \
{"AddCellToReset", WorldstateFunctions::AddCellToReset},\
{"ClearCellsToReset", WorldstateFunctions::ClearCellsToReset},\
{"SendCellReset", WorldstateFunctions::SendCellReset},\
\
{"ReadLastWorldstate", WorldstateFunctions::ReadLastWorldstate},\ {"ReadLastWorldstate", WorldstateFunctions::ReadLastWorldstate},\
{"CopyLastWorldstateToStore", WorldstateFunctions::CopyLastWorldstateToStore} {"CopyLastWorldstateToStore", WorldstateFunctions::CopyLastWorldstateToStore}
@ -461,6 +460,13 @@ public:
*/ */
static void AddEnforcedCollisionRefId(const char* refId) noexcept; static void AddEnforcedCollisionRefId(const char* refId) noexcept;
/**
* \brief Add a cell with given cellDescription to the list of cells that should be reset on the client.
*
* \return void
*/
static void AddCellToReset(const char * cellDescription) noexcept;
/** /**
* \brief Add a destination override containing the cell description for the old cell * \brief Add a destination override containing the cell description for the old cell
* and the new cell. * and the new cell.
@ -489,27 +495,12 @@ public:
/** /**
* \brief Clear the list of refIds for which collision should be enforced irrespective * \brief Clear the list of refIds for which collision should be enforced irrespective
* \brief Add a cell with given cellDescription to the list of cells that should be reset on the client.
*
* \return void
*/
static void AddCellToReset(const char * cellDescription) noexcept;
/**
* \brief Clear the list of refIdsd for which collision should be enforced irrespective
* of other settings. * of other settings.
* *
* \return void * \return void
*/ */
static void ClearEnforcedCollisionRefIds() noexcept; static void ClearEnforcedCollisionRefIds() noexcept;
/**
* \brief Clear the list of destination overrides.
*
* \return void
*/
static void ClearDestinationOverrides() noexcept;
/** /**
* \brief Clear the list of cells which should be reset on the client. * \brief Clear the list of cells which should be reset on the client.
* *
@ -517,6 +508,13 @@ public:
*/ */
static void ClearCellsToReset() noexcept; static void ClearCellsToReset() noexcept;
/**
* \brief Clear the list of destination overrides.
*
* \return void
*/
static void ClearDestinationOverrides() noexcept;
/** /**
* \brief Save the .png image data of the map tile at a certain index in the read worldstate's * \brief Save the .png image data of the map tile at a certain index in the read worldstate's
* map changes. * map changes.
@ -588,14 +586,6 @@ public:
*/ */
static void SendWorldRegionAuthority(unsigned short pid) noexcept; static void SendWorldRegionAuthority(unsigned short pid) noexcept;
/**
* \brief Send a CellReset packet with a list of cells,
*
* \param pid The player ID attached to the packet.
* \return void
*/
static void SendCellReset(unsigned short pid, bool sendToOtherPlayers) noexcept;
/** /**
* \brief Send a WorldMap packet with the current set of map changes in the write-only * \brief Send a WorldMap packet with the current set of map changes in the write-only
* worldstate. * worldstate.
@ -645,6 +635,14 @@ public:
*/ */
static void SendWorldCollisionOverride(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; static void SendWorldCollisionOverride(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
/**
* \brief Send a CellReset packet with a list of cells,
*
* \param pid The player ID attached to the packet.
* \return void
*/
static void SendCellReset(unsigned short pid, bool sendToOtherPlayers) noexcept;
/** /**
* \brief Send a WorldDestinationOverride packet with the current destination overrides in * \brief Send a WorldDestinationOverride packet with the current destination overrides in
* the write-only worldstate. * the write-only worldstate.