forked from mirror/openmw-tes3mp
[General] Turn PlayerMap into WorldMap, now a Worldstate packet
This commit is contained in:
parent
a28b27f5d9
commit
72862dc255
37 changed files with 349 additions and 348 deletions
|
@ -133,12 +133,12 @@ set(PROCESSORS_PLAYER
|
||||||
processors/player/ProcessorPlayerFaction.hpp processors/player/ProcessorPlayerInteraction.hpp
|
processors/player/ProcessorPlayerFaction.hpp processors/player/ProcessorPlayerInteraction.hpp
|
||||||
processors/player/ProcessorPlayerInventory.hpp processors/player/ProcessorPlayerJournal.hpp
|
processors/player/ProcessorPlayerInventory.hpp processors/player/ProcessorPlayerJournal.hpp
|
||||||
processors/player/ProcessorPlayerKillCount.hpp processors/player/ProcessorPlayerLevel.hpp
|
processors/player/ProcessorPlayerKillCount.hpp processors/player/ProcessorPlayerLevel.hpp
|
||||||
processors/player/ProcessorPlayerMap.hpp processors/player/ProcessorPlayerMiscellaneous.hpp
|
processors/player/ProcessorPlayerMiscellaneous.hpp processors/player/ProcessorPlayerPosition.hpp
|
||||||
processors/player/ProcessorPlayerPosition.hpp processors/player/ProcessorPlayerQuickKeys.hpp
|
processors/player/ProcessorPlayerQuickKeys.hpp processors/player/ProcessorPlayerRest.hpp
|
||||||
processors/player/ProcessorPlayerRest.hpp processors/player/ProcessorPlayerResurrect.hpp
|
processors/player/ProcessorPlayerResurrect.hpp processors/player/ProcessorPlayerShapeshift.hpp
|
||||||
processors/player/ProcessorPlayerShapeshift.hpp processors/player/ProcessorPlayerSkill.hpp
|
processors/player/ProcessorPlayerSkill.hpp processors/player/ProcessorPlayerSpeech.hpp
|
||||||
processors/player/ProcessorPlayerSpeech.hpp processors/player/ProcessorPlayerSpellbook.hpp
|
processors/player/ProcessorPlayerSpellbook.hpp processors/player/ProcessorPlayerStatsDynamic.hpp
|
||||||
processors/player/ProcessorPlayerStatsDynamic.hpp processors/player/ProcessorPlayerTopic.hpp
|
processors/player/ProcessorPlayerTopic.hpp
|
||||||
)
|
)
|
||||||
|
|
||||||
source_group(tes3mp-server\\processors\\player FILES ${PROCESSORS_PLAYER})
|
source_group(tes3mp-server\\processors\\player FILES ${PROCESSORS_PLAYER})
|
||||||
|
@ -159,7 +159,7 @@ set(PROCESSORS_OBJECT
|
||||||
source_group(tes3mp-server\\processors\\object FILES ${PROCESSORS_OBJECT})
|
source_group(tes3mp-server\\processors\\object FILES ${PROCESSORS_OBJECT})
|
||||||
|
|
||||||
set(PROCESSORS_WORLDSTATE
|
set(PROCESSORS_WORLDSTATE
|
||||||
processors/worldstate/ProcessorRecordDynamic.hpp
|
processors/worldstate/ProcessorRecordDynamic.hpp processors/worldstate/ProcessorWorldMap.hpp
|
||||||
)
|
)
|
||||||
|
|
||||||
source_group(tes3mp-server\\processors\\worldstate FILES ${PROCESSORS_WORLDSTATE})
|
source_group(tes3mp-server\\processors\\worldstate FILES ${PROCESSORS_WORLDSTATE})
|
||||||
|
@ -180,7 +180,7 @@ include_directories("./")
|
||||||
|
|
||||||
add_executable(tes3mp-server
|
add_executable(tes3mp-server
|
||||||
${SERVER} ${SERVER_HEADER}
|
${SERVER} ${SERVER_HEADER}
|
||||||
${PROCESSORS_ACTOR} ${PROCESSORS_PLAYER} ${PROCESSORS_OBJECT} ${PROCESSORS}
|
${PROCESSORS_ACTOR} ${PROCESSORS_PLAYER} ${PROCESSORS_OBJECT} ${PROCESSORS_WORLDSTATE} ${PROCESSORS}
|
||||||
${APPLE_BUNDLE_RESOURCES}
|
${APPLE_BUNDLE_RESOURCES}
|
||||||
)
|
)
|
||||||
add_definitions(-std=gnu++14 -Wno-ignored-qualifiers)
|
add_definitions(-std=gnu++14 -Wno-ignored-qualifiers)
|
||||||
|
|
|
@ -12,14 +12,6 @@ using namespace std;
|
||||||
|
|
||||||
static std::string tempCellDescription;
|
static std::string tempCellDescription;
|
||||||
|
|
||||||
void CellFunctions::InitializeMapChanges(unsigned short pid) noexcept
|
|
||||||
{
|
|
||||||
Player *player;
|
|
||||||
GET_PLAYER(pid, player, );
|
|
||||||
|
|
||||||
player->mapChanges.mapTiles.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int CellFunctions::GetCellStateChangesSize(unsigned short pid) noexcept
|
unsigned int CellFunctions::GetCellStateChangesSize(unsigned short pid) noexcept
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
|
@ -28,14 +20,6 @@ unsigned int CellFunctions::GetCellStateChangesSize(unsigned short pid) noexcept
|
||||||
return player->cellStateChanges.count;
|
return player->cellStateChanges.count;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int CellFunctions::GetMapChangesSize(unsigned short pid) noexcept
|
|
||||||
{
|
|
||||||
Player *player;
|
|
||||||
GET_PLAYER(pid, player, 0);
|
|
||||||
|
|
||||||
return player->mapChanges.mapTiles.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int CellFunctions::GetCellStateType(unsigned short pid, unsigned int i) noexcept
|
unsigned int CellFunctions::GetCellStateType(unsigned short pid, unsigned int i) noexcept
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
|
@ -103,35 +87,6 @@ bool CellFunctions::IsChangingRegion(unsigned short pid) noexcept
|
||||||
return player->isChangingRegion;
|
return player->isChangingRegion;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellFunctions::SaveMapTileImageFile(unsigned short pid, unsigned int i, const char *filePath) noexcept
|
|
||||||
{
|
|
||||||
Player *player;
|
|
||||||
GET_PLAYER(pid, player,);
|
|
||||||
|
|
||||||
if (i >= player->mapChanges.mapTiles.size())
|
|
||||||
return;
|
|
||||||
|
|
||||||
const std::vector<char>& imageData = player->mapChanges.mapTiles.at(i).imageData;
|
|
||||||
|
|
||||||
std::ofstream outputFile(filePath, std::ios::binary);
|
|
||||||
std::ostream_iterator<char> outputIterator(outputFile);
|
|
||||||
std::copy(imageData.begin(), imageData.end(), outputIterator);
|
|
||||||
}
|
|
||||||
|
|
||||||
int CellFunctions::GetMapTileCellX(unsigned short pid, unsigned int i) noexcept
|
|
||||||
{
|
|
||||||
Player *player;
|
|
||||||
GET_PLAYER(pid, player, 0);
|
|
||||||
return player->mapChanges.mapTiles.at(i).x;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CellFunctions::GetMapTileCellY(unsigned short pid, unsigned int i) noexcept
|
|
||||||
{
|
|
||||||
Player *player;
|
|
||||||
GET_PLAYER(pid, player, 0);
|
|
||||||
return player->mapChanges.mapTiles.at(i).y;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CellFunctions::SetCell(unsigned short pid, const char *cellDescription) noexcept
|
void CellFunctions::SetCell(unsigned short pid, const char *cellDescription) noexcept
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
|
@ -160,21 +115,6 @@ void CellFunctions::SetExteriorCell(unsigned short pid, int x, int y) noexcept
|
||||||
player->cell.mData.mY = y;
|
player->cell.mData.mY = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellFunctions::LoadMapTileImageFile(unsigned short pid, int cellX, int cellY, const char* filePath) noexcept
|
|
||||||
{
|
|
||||||
Player *player;
|
|
||||||
GET_PLAYER(pid, player, );
|
|
||||||
|
|
||||||
mwmp::MapTile mapTile;
|
|
||||||
mapTile.x = cellX;
|
|
||||||
mapTile.y = cellY;
|
|
||||||
|
|
||||||
std::ifstream inputFile(filePath, std::ios::binary);
|
|
||||||
mapTile.imageData = std::vector<char>(std::istreambuf_iterator<char>(inputFile), std::istreambuf_iterator<char>());
|
|
||||||
|
|
||||||
player->mapChanges.mapTiles.push_back(mapTile);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CellFunctions::SendCell(unsigned short pid) noexcept
|
void CellFunctions::SendCell(unsigned short pid) noexcept
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
|
@ -183,12 +123,3 @@ void CellFunctions::SendCell(unsigned short pid) noexcept
|
||||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_CELL_CHANGE)->setPlayer(player);
|
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_CELL_CHANGE)->setPlayer(player);
|
||||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_CELL_CHANGE)->Send(false);
|
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_CELL_CHANGE)->Send(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellFunctions::SendMapChanges(unsigned short pid, bool toOthers) noexcept
|
|
||||||
{
|
|
||||||
Player *player;
|
|
||||||
GET_PLAYER(pid, player, );
|
|
||||||
|
|
||||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_MAP)->setPlayer(player);
|
|
||||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_MAP)->Send(toOthers);
|
|
||||||
}
|
|
||||||
|
|
|
@ -4,10 +4,7 @@
|
||||||
#include "../Types.hpp"
|
#include "../Types.hpp"
|
||||||
|
|
||||||
#define CELLAPI \
|
#define CELLAPI \
|
||||||
{"InitializeMapChanges", CellFunctions::InitializeMapChanges},\
|
|
||||||
\
|
|
||||||
{"GetCellStateChangesSize", CellFunctions::GetCellStateChangesSize},\
|
{"GetCellStateChangesSize", CellFunctions::GetCellStateChangesSize},\
|
||||||
{"GetMapChangesSize", CellFunctions::GetMapChangesSize},\
|
|
||||||
\
|
\
|
||||||
{"GetCellStateType", CellFunctions::GetCellStateType},\
|
{"GetCellStateType", CellFunctions::GetCellStateType},\
|
||||||
{"GetCellStateDescription", CellFunctions::GetCellStateDescription},\
|
{"GetCellStateDescription", CellFunctions::GetCellStateDescription},\
|
||||||
|
@ -20,33 +17,16 @@
|
||||||
{"GetRegion", CellFunctions::GetRegion},\
|
{"GetRegion", CellFunctions::GetRegion},\
|
||||||
{"IsChangingRegion", CellFunctions::IsChangingRegion},\
|
{"IsChangingRegion", CellFunctions::IsChangingRegion},\
|
||||||
\
|
\
|
||||||
{"GetMapTileCellX", CellFunctions::GetMapTileCellX},\
|
|
||||||
{"GetMapTileCellY", CellFunctions::GetMapTileCellY},\
|
|
||||||
{"SaveMapTileImageFile", CellFunctions::SaveMapTileImageFile},\
|
|
||||||
\
|
|
||||||
{"SetCell", CellFunctions::SetCell},\
|
{"SetCell", CellFunctions::SetCell},\
|
||||||
{"SetExteriorCell", CellFunctions::SetExteriorCell},\
|
{"SetExteriorCell", CellFunctions::SetExteriorCell},\
|
||||||
\
|
\
|
||||||
{"LoadMapTileImageFile", CellFunctions::LoadMapTileImageFile},\
|
{"SendCell", CellFunctions::SendCell}
|
||||||
\
|
|
||||||
{"SendCell", CellFunctions::SendCell},\
|
|
||||||
{"SendMapChanges", CellFunctions::SendMapChanges}
|
|
||||||
|
|
||||||
|
|
||||||
class CellFunctions
|
class CellFunctions
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Clear the last recorded map changes for a player.
|
|
||||||
*
|
|
||||||
* This is used to initialize the sending of new PlayerMap packets.
|
|
||||||
*
|
|
||||||
* \param pid The player ID whose map changes should be used.
|
|
||||||
* \return void
|
|
||||||
*/
|
|
||||||
static void InitializeMapChanges(unsigned short pid) noexcept;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Get the number of indexes in a player's latest cell state changes.
|
* \brief Get the number of indexes in a player's latest cell state changes.
|
||||||
*
|
*
|
||||||
|
@ -55,14 +35,6 @@ public:
|
||||||
*/
|
*/
|
||||||
static unsigned int GetCellStateChangesSize(unsigned short pid) noexcept;
|
static unsigned int GetCellStateChangesSize(unsigned short pid) noexcept;
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Get the number of indexes in a player's latest map changes.
|
|
||||||
*
|
|
||||||
* \param pid The player ID whose map changes should be used.
|
|
||||||
* \return The number of indexes.
|
|
||||||
*/
|
|
||||||
static unsigned int GetMapChangesSize(unsigned short pid) noexcept;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Get the cell state type at a certain index in a player's latest cell state changes.
|
* \brief Get the cell state type at a certain index in a player's latest cell state changes.
|
||||||
*
|
*
|
||||||
|
@ -131,37 +103,6 @@ public:
|
||||||
*/
|
*/
|
||||||
static bool IsChangingRegion(unsigned short pid) noexcept;
|
static bool IsChangingRegion(unsigned short pid) noexcept;
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Get the X coordinate of the cell corresponding to the map tile at a certain index in a
|
|
||||||
* player's latest map changes.
|
|
||||||
*
|
|
||||||
* \param pid The player ID whose map changes should be used.
|
|
||||||
* \param i The index of the map tile.
|
|
||||||
* \return The X coordinate of the cell.
|
|
||||||
*/
|
|
||||||
static int GetMapTileCellX(unsigned short pid, unsigned int i) noexcept;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Get the Y coordinate of the cell corresponding to the map tile at a certain index in a
|
|
||||||
* player's latest map changes.
|
|
||||||
*
|
|
||||||
* \param pid The player ID whose map changes should be used.
|
|
||||||
* \param i The index of the map tile.
|
|
||||||
* \return The Y coordinate of the cell.
|
|
||||||
*/
|
|
||||||
static int GetMapTileCellY(unsigned short pid, unsigned int i) noexcept;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Save the .png image data of the map tile at a certain index in a player's latest map changes
|
|
||||||
* to a file.
|
|
||||||
*
|
|
||||||
* \param pid The player ID whose map changes should be used.
|
|
||||||
* \param i The index of the map tile.
|
|
||||||
* \param filePath The file path of the resulting file.
|
|
||||||
* \return void
|
|
||||||
*/
|
|
||||||
static void SaveMapTileImageFile(unsigned short pid, unsigned int i, const char *filePath) noexcept;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set the cell of a player.
|
* \brief Set the cell of a player.
|
||||||
*
|
*
|
||||||
|
@ -190,18 +131,6 @@ public:
|
||||||
*/
|
*/
|
||||||
static void SetExteriorCell(unsigned short pid, int x, int y) noexcept;
|
static void SetExteriorCell(unsigned short pid, int x, int y) noexcept;
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Load a .png file as the image data for a map tile and add it to the map changes for
|
|
||||||
* a player.
|
|
||||||
*
|
|
||||||
* \param pid The player ID whose map changes should be used.
|
|
||||||
* \param cellX The X coordinate of the cell corresponding to the map tile.
|
|
||||||
* \param cellY The Y coordinate of the cell corresponding to the map tile.
|
|
||||||
* \param filePath The file path of the loaded file.
|
|
||||||
* \return void
|
|
||||||
*/
|
|
||||||
static void LoadMapTileImageFile(unsigned short pid, int cellX, int cellY, const char* filePath) noexcept;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Send a PlayerCellChange packet about a player.
|
* \brief Send a PlayerCellChange packet about a player.
|
||||||
*
|
*
|
||||||
|
@ -212,15 +141,6 @@ public:
|
||||||
*/
|
*/
|
||||||
static void SendCell(unsigned short pid) noexcept;
|
static void SendCell(unsigned short pid) noexcept;
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Send a PlayerMap packet with a player's recorded map changes.
|
|
||||||
*
|
|
||||||
* \param pid The player ID whose map changes should be used.
|
|
||||||
* \param toOthers Whether this packet should be sent only to other players or
|
|
||||||
* only to the player it is about.
|
|
||||||
* \return void
|
|
||||||
*/
|
|
||||||
static void SendMapChanges(unsigned short pid, bool toOthers = false) noexcept;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //OPENMW_CELLAPI_HPP
|
#endif //OPENMW_CELLAPI_HPP
|
||||||
|
|
|
@ -11,6 +11,56 @@ using namespace std;
|
||||||
using namespace mwmp;
|
using namespace mwmp;
|
||||||
|
|
||||||
BaseWorldstate writeWorldstate;
|
BaseWorldstate writeWorldstate;
|
||||||
|
BaseWorldstate *readWorldstate;
|
||||||
|
|
||||||
|
void WorldstateFunctions::ReadLastWorldstate() noexcept
|
||||||
|
{
|
||||||
|
readWorldstate = mwmp::Networking::getPtr()->getLastWorldstate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorldstateFunctions::ClearMapChanges() noexcept
|
||||||
|
{
|
||||||
|
writeWorldstate.mapChanges.mapTiles.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int WorldstateFunctions::GetMapChangesSize() noexcept
|
||||||
|
{
|
||||||
|
return readWorldstate->mapChanges.mapTiles.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
int WorldstateFunctions::GetMapTileCellX(unsigned int index) noexcept
|
||||||
|
{
|
||||||
|
return readWorldstate->mapChanges.mapTiles.at(index).x;
|
||||||
|
}
|
||||||
|
|
||||||
|
int WorldstateFunctions::GetMapTileCellY(unsigned int index) noexcept
|
||||||
|
{
|
||||||
|
return readWorldstate->mapChanges.mapTiles.at(index).y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorldstateFunctions::SaveMapTileImageFile(unsigned int index, const char *filePath) noexcept
|
||||||
|
{
|
||||||
|
if (index >= readWorldstate->mapChanges.mapTiles.size())
|
||||||
|
return;
|
||||||
|
|
||||||
|
const std::vector<char>& imageData = readWorldstate->mapChanges.mapTiles.at(index).imageData;
|
||||||
|
|
||||||
|
std::ofstream outputFile(filePath, std::ios::binary);
|
||||||
|
std::ostream_iterator<char> outputIterator(outputFile);
|
||||||
|
std::copy(imageData.begin(), imageData.end(), outputIterator);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorldstateFunctions::LoadMapTileImageFile(int cellX, int cellY, const char* filePath) noexcept
|
||||||
|
{
|
||||||
|
mwmp::MapTile mapTile;
|
||||||
|
mapTile.x = cellX;
|
||||||
|
mapTile.y = cellY;
|
||||||
|
|
||||||
|
std::ifstream inputFile(filePath, std::ios::binary);
|
||||||
|
mapTile.imageData = std::vector<char>(std::istreambuf_iterator<char>(inputFile), std::istreambuf_iterator<char>());
|
||||||
|
|
||||||
|
writeWorldstate.mapChanges.mapTiles.push_back(mapTile);
|
||||||
|
}
|
||||||
|
|
||||||
void WorldstateFunctions::SetHour(double hour) noexcept
|
void WorldstateFunctions::SetHour(double hour) noexcept
|
||||||
{
|
{
|
||||||
|
@ -62,7 +112,21 @@ void WorldstateFunctions::UseActorCollisionForPlacedObjects(bool useActorCollisi
|
||||||
writeWorldstate.useActorCollisionForPlacedObjects = useActorCollision;
|
writeWorldstate.useActorCollisionForPlacedObjects = useActorCollision;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldstateFunctions::SendWorldTime(unsigned short pid, bool toOthers) noexcept
|
void WorldstateFunctions::SendWorldMap(unsigned short pid, bool broadcast) noexcept
|
||||||
|
{
|
||||||
|
Player *player;
|
||||||
|
GET_PLAYER(pid, player, );
|
||||||
|
|
||||||
|
writeWorldstate.guid = player->guid;
|
||||||
|
|
||||||
|
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_MAP)->setWorldstate(&writeWorldstate);
|
||||||
|
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_MAP)->Send(false);
|
||||||
|
|
||||||
|
if (broadcast)
|
||||||
|
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_MAP)->Send(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorldstateFunctions::SendWorldTime(unsigned short pid, bool broadcast) noexcept
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
GET_PLAYER(pid, player, );
|
GET_PLAYER(pid, player, );
|
||||||
|
@ -72,11 +136,11 @@ void WorldstateFunctions::SendWorldTime(unsigned short pid, bool toOthers) noexc
|
||||||
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_TIME)->setWorldstate(&writeWorldstate);
|
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_TIME)->setWorldstate(&writeWorldstate);
|
||||||
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_TIME)->Send(false);
|
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_TIME)->Send(false);
|
||||||
|
|
||||||
if (toOthers)
|
if (broadcast)
|
||||||
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_TIME)->Send(true);
|
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_TIME)->Send(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldstateFunctions::SendWorldCollisionOverride(unsigned short pid, bool toOthers) noexcept
|
void WorldstateFunctions::SendWorldCollisionOverride(unsigned short pid, bool broadcast) noexcept
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
GET_PLAYER(pid, player, );
|
GET_PLAYER(pid, player, );
|
||||||
|
@ -86,6 +150,6 @@ void WorldstateFunctions::SendWorldCollisionOverride(unsigned short pid, bool to
|
||||||
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_COLLISION_OVERRIDE)->setWorldstate(&writeWorldstate);
|
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_COLLISION_OVERRIDE)->setWorldstate(&writeWorldstate);
|
||||||
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_COLLISION_OVERRIDE)->Send(false);
|
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_COLLISION_OVERRIDE)->Send(false);
|
||||||
|
|
||||||
if (toOthers)
|
if (broadcast)
|
||||||
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_COLLISION_OVERRIDE)->Send(true);
|
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_COLLISION_OVERRIDE)->Send(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,18 @@
|
||||||
#include "../Types.hpp"
|
#include "../Types.hpp"
|
||||||
|
|
||||||
#define WORLDSTATEAPI \
|
#define WORLDSTATEAPI \
|
||||||
|
{"ReadLastWorldstate", WorldstateFunctions::ReadLastWorldstate},\
|
||||||
|
\
|
||||||
|
{"ClearMapChanges", WorldstateFunctions::ClearMapChanges},\
|
||||||
|
\
|
||||||
|
{"GetMapChangesSize", WorldstateFunctions::GetMapChangesSize},\
|
||||||
|
\
|
||||||
|
{"GetMapTileCellX", WorldstateFunctions::GetMapTileCellX},\
|
||||||
|
{"GetMapTileCellY", WorldstateFunctions::GetMapTileCellY},\
|
||||||
|
\
|
||||||
|
{"SaveMapTileImageFile", WorldstateFunctions::SaveMapTileImageFile},\
|
||||||
|
{"LoadMapTileImageFile", WorldstateFunctions::LoadMapTileImageFile},\
|
||||||
|
\
|
||||||
{"SetHour", WorldstateFunctions::SetHour},\
|
{"SetHour", WorldstateFunctions::SetHour},\
|
||||||
{"SetDay", WorldstateFunctions::SetDay},\
|
{"SetDay", WorldstateFunctions::SetDay},\
|
||||||
{"SetMonth", WorldstateFunctions::SetMonth},\
|
{"SetMonth", WorldstateFunctions::SetMonth},\
|
||||||
|
@ -16,6 +28,7 @@
|
||||||
{"SetPlacedObjectCollisionState", WorldstateFunctions::SetPlacedObjectCollisionState},\
|
{"SetPlacedObjectCollisionState", WorldstateFunctions::SetPlacedObjectCollisionState},\
|
||||||
{"UseActorCollisionForPlacedObjects", WorldstateFunctions::UseActorCollisionForPlacedObjects},\
|
{"UseActorCollisionForPlacedObjects", WorldstateFunctions::UseActorCollisionForPlacedObjects},\
|
||||||
\
|
\
|
||||||
|
{"SendWorldMap", WorldstateFunctions::SendWorldMap},\
|
||||||
{"SendWorldTime", WorldstateFunctions::SendWorldTime},\
|
{"SendWorldTime", WorldstateFunctions::SendWorldTime},\
|
||||||
{"SendWorldCollisionOverride", WorldstateFunctions::SendWorldCollisionOverride}
|
{"SendWorldCollisionOverride", WorldstateFunctions::SendWorldCollisionOverride}
|
||||||
|
|
||||||
|
@ -24,7 +37,69 @@ class WorldstateFunctions
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set the world's hour in the worldstate stored on the server.
|
* \brief Use the last worldstate received by the server as the one being read.
|
||||||
|
*
|
||||||
|
* \return void
|
||||||
|
*/
|
||||||
|
static void ReadLastWorldstate() noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Clear the map changes for the write-only worldstate.
|
||||||
|
*
|
||||||
|
* This is used to initialize the sending of new WorldMap packets.
|
||||||
|
*
|
||||||
|
* \return void
|
||||||
|
*/
|
||||||
|
static void ClearMapChanges() noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Get the number of indexes in the read worldstate's map changes.
|
||||||
|
*
|
||||||
|
* \return The number of indexes.
|
||||||
|
*/
|
||||||
|
static unsigned int GetMapChangesSize() noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Get the X coordinate of the cell corresponding to the map tile at a certain index in
|
||||||
|
* the read worldstate's map changes.
|
||||||
|
*
|
||||||
|
* \param i The index of the map tile.
|
||||||
|
* \return The X coordinate of the cell.
|
||||||
|
*/
|
||||||
|
static int GetMapTileCellX(unsigned int index) noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Get the Y coordinate of the cell corresponding to the map tile at a certain index in
|
||||||
|
* the read worldstate's map changes.
|
||||||
|
*
|
||||||
|
* \param i The index of the map tile.
|
||||||
|
* \return The Y coordinate of the cell.
|
||||||
|
*/
|
||||||
|
static int GetMapTileCellY(unsigned int index) noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Save the .png image data of the map tile at a certain index in the read worldstate's
|
||||||
|
* map changes.
|
||||||
|
*
|
||||||
|
* \param i The index of the map tile.
|
||||||
|
* \param filePath The file path of the resulting file.
|
||||||
|
* \return void
|
||||||
|
*/
|
||||||
|
static void SaveMapTileImageFile(unsigned int index, const char *filePath) noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Load a .png file as the image data for a map tile and add it to the write-only worldstate
|
||||||
|
* stored on the server.
|
||||||
|
*
|
||||||
|
* \param cellX The X coordinate of the cell corresponding to the map tile.
|
||||||
|
* \param cellY The Y coordinate of the cell corresponding to the map tile.
|
||||||
|
* \param filePath The file path of the loaded file.
|
||||||
|
* \return void
|
||||||
|
*/
|
||||||
|
static void LoadMapTileImageFile(int cellX, int cellY, const char* filePath) noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Set the world's hour in the write-only worldstate stored on the server.
|
||||||
*
|
*
|
||||||
* \param hour The hour.
|
* \param hour The hour.
|
||||||
* \return void
|
* \return void
|
||||||
|
@ -32,7 +107,7 @@ public:
|
||||||
static void SetHour(double hour) noexcept;
|
static void SetHour(double hour) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set the world's day in the worldstate stored on the server.
|
* \brief Set the world's day in the write-only worldstate stored on the server.
|
||||||
*
|
*
|
||||||
* \param day The day.
|
* \param day The day.
|
||||||
* \return void
|
* \return void
|
||||||
|
@ -40,7 +115,7 @@ public:
|
||||||
static void SetDay(int day) noexcept;
|
static void SetDay(int day) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set the world's month in the worldstate stored on the server.
|
* \brief Set the world's month in the write-only worldstate stored on the server.
|
||||||
*
|
*
|
||||||
* \param month The month.
|
* \param month The month.
|
||||||
* \return void
|
* \return void
|
||||||
|
@ -48,7 +123,7 @@ public:
|
||||||
static void SetMonth(int month) noexcept;
|
static void SetMonth(int month) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set the world's year in the worldstate stored on the server.
|
* \brief Set the world's year in the write-only worldstate stored on the server.
|
||||||
*
|
*
|
||||||
* \param year The year.
|
* \param year The year.
|
||||||
* \return void
|
* \return void
|
||||||
|
@ -56,7 +131,7 @@ public:
|
||||||
static void SetYear(int year) noexcept;
|
static void SetYear(int year) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set the world's days passed in the worldstate stored on the server.
|
* \brief Set the world's days passed in the write-only worldstate stored on the server.
|
||||||
*
|
*
|
||||||
* \param daysPassed The days passed.
|
* \param daysPassed The days passed.
|
||||||
* \return void
|
* \return void
|
||||||
|
@ -64,7 +139,7 @@ public:
|
||||||
static void SetDaysPassed(int daysPassed) noexcept;
|
static void SetDaysPassed(int daysPassed) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set the world's time scale in the worldstate stored on the server.
|
* \brief Set the world's time scale in the write-only worldstate stored on the server.
|
||||||
*
|
*
|
||||||
* \param pid The player ID.
|
* \param pid The player ID.
|
||||||
* \param timeScale The time scale.
|
* \param timeScale The time scale.
|
||||||
|
@ -73,7 +148,8 @@ public:
|
||||||
static void SetTimeScale(double timeScale) noexcept;
|
static void SetTimeScale(double timeScale) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set the collision state for other players.
|
* \brief Set the collision state for other players in the write-only worldstate stored
|
||||||
|
* on the server.
|
||||||
*
|
*
|
||||||
* \param state The collision state.
|
* \param state The collision state.
|
||||||
* \return void
|
* \return void
|
||||||
|
@ -81,7 +157,8 @@ public:
|
||||||
static void SetPlayerCollisionState(bool state) noexcept;
|
static void SetPlayerCollisionState(bool state) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set the collision state for actors.
|
* \brief Set the collision state for actors in the write-only worldstate stored on the
|
||||||
|
* server.
|
||||||
*
|
*
|
||||||
* \param state The collision state.
|
* \param state The collision state.
|
||||||
* \return void
|
* \return void
|
||||||
|
@ -89,7 +166,8 @@ public:
|
||||||
static void SetActorCollisionState(bool state) noexcept;
|
static void SetActorCollisionState(bool state) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set the collision state for placed objects.
|
* \brief Set the collision state for placed objects in the write-only worldstate stored
|
||||||
|
* on the server.
|
||||||
*
|
*
|
||||||
* \param state The collision state.
|
* \param state The collision state.
|
||||||
* \return void
|
* \return void
|
||||||
|
@ -97,9 +175,8 @@ public:
|
||||||
static void SetPlacedObjectCollisionState(bool state) noexcept;
|
static void SetPlacedObjectCollisionState(bool state) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Whether placed objects with collision turned on should use
|
* \brief Whether placed objects with collision turned on should use actor collision, i.e.
|
||||||
* actor collision, i.e. whether they should be slippery
|
* whether they should be slippery and prevent players from standing on them.
|
||||||
* and prevent players from standing on them.
|
|
||||||
*
|
*
|
||||||
* \param useActorCollision Whether to use actor collision.
|
* \param useActorCollision Whether to use actor collision.
|
||||||
* \return void
|
* \return void
|
||||||
|
@ -107,22 +184,37 @@ public:
|
||||||
static void UseActorCollisionForPlacedObjects(bool useActorCollision) noexcept;
|
static void UseActorCollisionForPlacedObjects(bool useActorCollision) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Send a WorldTime packet with the current time and time scale
|
* \brief Send a WorldMap packet with the current set of map changes in the write-only
|
||||||
* to a specific player or to all players.
|
* worldstate.
|
||||||
*
|
*
|
||||||
* \param pid The player ID.
|
* \param pid The player ID attached to the packet.
|
||||||
|
* \param broadcast Whether this packet should be sent only to the attached player
|
||||||
|
* or to all players on the server.
|
||||||
* \return void
|
* \return void
|
||||||
*/
|
*/
|
||||||
static void SendWorldTime(unsigned short pid, bool toOthers = false) noexcept;
|
static void SendWorldMap(unsigned short pid, bool broadcast = false) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Send a WorldCollisionOverride packet with the current collision overrides
|
* \brief Send a WorldTime packet with the current time and time scale in the write-only
|
||||||
* to a specific player or to all players.
|
* worldstate.
|
||||||
*
|
*
|
||||||
* \param pid The player ID.
|
* \param pid The player ID attached to the packet.
|
||||||
|
* \param broadcast Whether this packet should be sent only to the attached player
|
||||||
|
* or to all players on the server.
|
||||||
* \return void
|
* \return void
|
||||||
*/
|
*/
|
||||||
static void SendWorldCollisionOverride(unsigned short pid, bool toOthers = false) noexcept;
|
static void SendWorldTime(unsigned short pid, bool broadcast = false) noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Send a WorldCollisionOverride packet with the current collision overrides in
|
||||||
|
* the write-only worldstate.
|
||||||
|
*
|
||||||
|
* \param pid The player ID attached to the packet.
|
||||||
|
* \param broadcast Whether this packet should be sent only to the attached player
|
||||||
|
* or to all players on the server.
|
||||||
|
* \return void
|
||||||
|
*/
|
||||||
|
static void SendWorldCollisionOverride(unsigned short pid, bool broadcast = false) noexcept;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -323,7 +323,6 @@ public:
|
||||||
{"OnPlayerDisposition", Function<void, unsigned short>()},
|
{"OnPlayerDisposition", Function<void, unsigned short>()},
|
||||||
{"OnPlayerBook", Function<void, unsigned short>()},
|
{"OnPlayerBook", Function<void, unsigned short>()},
|
||||||
{"OnPlayerMiscellaneous", Function<void, unsigned short>()},
|
{"OnPlayerMiscellaneous", Function<void, unsigned short>()},
|
||||||
{"OnPlayerMap", Function<void, unsigned short>()},
|
|
||||||
{"OnPlayerInteraction", Function<void, unsigned short>()},
|
{"OnPlayerInteraction", Function<void, unsigned short>()},
|
||||||
{"OnPlayerRest", Function<void, unsigned short>()},
|
{"OnPlayerRest", Function<void, unsigned short>()},
|
||||||
{"OnRecordDynamic", Function<void, unsigned short>()},
|
{"OnRecordDynamic", Function<void, unsigned short>()},
|
||||||
|
@ -346,6 +345,7 @@ public:
|
||||||
{"OnPlayerSendMessage", Function<bool, unsigned short, const char*>()},
|
{"OnPlayerSendMessage", Function<bool, unsigned short, const char*>()},
|
||||||
{"OnPlayerEndCharGen", Function<void, unsigned short>()},
|
{"OnPlayerEndCharGen", Function<void, unsigned short>()},
|
||||||
{"OnGUIAction", Function<void, unsigned short, int, const char*>()},
|
{"OnGUIAction", Function<void, unsigned short, int, const char*>()},
|
||||||
|
{"OnWorldMap", Function<void, unsigned short>()},
|
||||||
{"OnMpNumIncrement", Function<void, int>()},
|
{"OnMpNumIncrement", Function<void, int>()},
|
||||||
{"OnRequestPluginList", Function<const char *, unsigned int, unsigned int>()}
|
{"OnRequestPluginList", Function<const char *, unsigned int, unsigned int>()}
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#include "player/ProcessorPlayerKillCount.hpp"
|
#include "player/ProcessorPlayerKillCount.hpp"
|
||||||
#include "player/ProcessorPlayerInteraction.hpp"
|
#include "player/ProcessorPlayerInteraction.hpp"
|
||||||
#include "player/ProcessorPlayerLevel.hpp"
|
#include "player/ProcessorPlayerLevel.hpp"
|
||||||
#include "player/ProcessorPlayerMap.hpp"
|
|
||||||
#include "player/ProcessorPlayerMiscellaneous.hpp"
|
#include "player/ProcessorPlayerMiscellaneous.hpp"
|
||||||
#include "player/ProcessorPlayerPosition.hpp"
|
#include "player/ProcessorPlayerPosition.hpp"
|
||||||
#include "player/ProcessorPlayerQuickKeys.hpp"
|
#include "player/ProcessorPlayerQuickKeys.hpp"
|
||||||
|
@ -76,6 +75,7 @@
|
||||||
#include "object/ProcessorVideoPlay.hpp"
|
#include "object/ProcessorVideoPlay.hpp"
|
||||||
#include "WorldstateProcessor.hpp"
|
#include "WorldstateProcessor.hpp"
|
||||||
#include "worldstate/ProcessorRecordDynamic.hpp"
|
#include "worldstate/ProcessorRecordDynamic.hpp"
|
||||||
|
#include "worldstate/ProcessorWorldMap.hpp"
|
||||||
|
|
||||||
using namespace mwmp;
|
using namespace mwmp;
|
||||||
|
|
||||||
|
@ -103,7 +103,6 @@ void ProcessorInitializer()
|
||||||
PlayerProcessor::AddProcessor(new ProcessorPlayerKillCount());
|
PlayerProcessor::AddProcessor(new ProcessorPlayerKillCount());
|
||||||
PlayerProcessor::AddProcessor(new ProcessorPlayerInteraction());
|
PlayerProcessor::AddProcessor(new ProcessorPlayerInteraction());
|
||||||
PlayerProcessor::AddProcessor(new ProcessorPlayerLevel());
|
PlayerProcessor::AddProcessor(new ProcessorPlayerLevel());
|
||||||
PlayerProcessor::AddProcessor(new ProcessorPlayerMap());
|
|
||||||
PlayerProcessor::AddProcessor(new ProcessorPlayerMiscellaneous());
|
PlayerProcessor::AddProcessor(new ProcessorPlayerMiscellaneous());
|
||||||
PlayerProcessor::AddProcessor(new ProcessorPlayerPosition());
|
PlayerProcessor::AddProcessor(new ProcessorPlayerPosition());
|
||||||
PlayerProcessor::AddProcessor(new ProcessorPlayerQuickKeys());
|
PlayerProcessor::AddProcessor(new ProcessorPlayerQuickKeys());
|
||||||
|
@ -153,4 +152,5 @@ void ProcessorInitializer()
|
||||||
ObjectProcessor::AddProcessor(new ProcessorVideoPlay());
|
ObjectProcessor::AddProcessor(new ProcessorVideoPlay());
|
||||||
|
|
||||||
WorldstateProcessor::AddProcessor(new ProcessorRecordDynamic());
|
WorldstateProcessor::AddProcessor(new ProcessorRecordDynamic());
|
||||||
|
WorldstateProcessor::AddProcessor(new ProcessorWorldMap());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
#ifndef OPENMW_PROCESSORPLAYERMAP_HPP
|
|
||||||
#define OPENMW_PROCESSORPLAYERMAP_HPP
|
|
||||||
|
|
||||||
#include "../PlayerProcessor.hpp"
|
|
||||||
|
|
||||||
namespace mwmp
|
|
||||||
{
|
|
||||||
class ProcessorPlayerMap : public PlayerProcessor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ProcessorPlayerMap()
|
|
||||||
{
|
|
||||||
BPP_INIT(ID_PLAYER_MAP)
|
|
||||||
}
|
|
||||||
|
|
||||||
void Do(PlayerPacket &packet, Player &player) override
|
|
||||||
{
|
|
||||||
DEBUG_PRINTF(strPacketID.c_str());
|
|
||||||
|
|
||||||
Script::Call<Script::CallbackIdentity("OnPlayerMap")>(player.getId());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif //OPENMW_PROCESSORPLAYERMAP_HPP
|
|
25
apps/openmw-mp/processors/worldstate/ProcessorWorldMap.hpp
Normal file
25
apps/openmw-mp/processors/worldstate/ProcessorWorldMap.hpp
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#ifndef OPENMW_PROCESSORWORLDMAP_HPP
|
||||||
|
#define OPENMW_PROCESSORWORLDMAP_HPP
|
||||||
|
|
||||||
|
#include "../WorldstateProcessor.hpp"
|
||||||
|
|
||||||
|
namespace mwmp
|
||||||
|
{
|
||||||
|
class ProcessorWorldMap : public WorldstateProcessor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ProcessorWorldMap()
|
||||||
|
{
|
||||||
|
BPP_INIT(ID_WORLD_MAP)
|
||||||
|
}
|
||||||
|
|
||||||
|
void Do(WorldstatePacket &packet, Player &player, BaseWorldstate &worldstate) override
|
||||||
|
{
|
||||||
|
DEBUG_PRINTF(strPacketID.c_str());
|
||||||
|
|
||||||
|
Script::Call<Script::CallbackIdentity("OnWorldMap")>(player.getId());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //OPENMW_PROCESSORWORLDMAP_HPP
|
|
@ -119,9 +119,10 @@ add_openmw_dir (mwmp/processors/player ProcessorChatMessage ProcessorGUIMessageB
|
||||||
ProcessorPlayerBehavior ProcessorPlayerBook ProcessorPlayerBounty ProcessorPlayerCellChange ProcessorPlayerCellState
|
ProcessorPlayerBehavior ProcessorPlayerBook ProcessorPlayerBounty ProcessorPlayerCellChange ProcessorPlayerCellState
|
||||||
ProcessorPlayerCharClass ProcessorPlayerCharGen ProcessorPlayerDeath ProcessorPlayerDisposition ProcessorPlayerEquipment
|
ProcessorPlayerCharClass ProcessorPlayerCharGen ProcessorPlayerDeath ProcessorPlayerDisposition ProcessorPlayerEquipment
|
||||||
ProcessorPlayerFaction ProcessorPlayerInteraction ProcessorPlayerInventory ProcessorPlayerJail ProcessorPlayerJournal
|
ProcessorPlayerFaction ProcessorPlayerInteraction ProcessorPlayerInventory ProcessorPlayerJail ProcessorPlayerJournal
|
||||||
ProcessorPlayerKillCount ProcessorPlayerLevel ProcessorPlayerMap ProcessorPlayerMiscellaneous ProcessorPlayerMomentum
|
ProcessorPlayerKillCount ProcessorPlayerLevel ProcessorPlayerMiscellaneous ProcessorPlayerMomentum
|
||||||
ProcessorPlayerPosition ProcessorPlayerQuickKeys ProcessorPlayerReputation ProcessorPlayerResurrect ProcessorPlayerShapeshift
|
ProcessorPlayerPosition ProcessorPlayerQuickKeys ProcessorPlayerReputation ProcessorPlayerResurrect
|
||||||
ProcessorPlayerSkill ProcessorPlayerSpeech ProcessorPlayerSpellbook ProcessorPlayerStatsDynamic ProcessorPlayerTopic
|
ProcessorPlayerShapeshift ProcessorPlayerSkill ProcessorPlayerSpeech ProcessorPlayerSpellbook ProcessorPlayerStatsDynamic
|
||||||
|
ProcessorPlayerTopic
|
||||||
)
|
)
|
||||||
|
|
||||||
add_openmw_dir (mwmp/processors/object BaseObjectProcessor ProcessorConsoleCommand ProcessorContainer
|
add_openmw_dir (mwmp/processors/object BaseObjectProcessor ProcessorConsoleCommand ProcessorContainer
|
||||||
|
@ -132,7 +133,8 @@ add_openmw_dir (mwmp/processors/object BaseObjectProcessor ProcessorConsoleComma
|
||||||
ProcessorScriptMemberShort ProcessorScriptMemberFloat ProcessorScriptGlobalShort ProcessorScriptGlobalFloat
|
ProcessorScriptMemberShort ProcessorScriptMemberFloat ProcessorScriptGlobalShort ProcessorScriptGlobalFloat
|
||||||
)
|
)
|
||||||
|
|
||||||
add_openmw_dir (mwmp/processors/worldstate ProcessorRecordDynamic ProcessorWorldCollisionOverride ProcessorWorldTime
|
add_openmw_dir (mwmp/processors/worldstate ProcessorRecordDynamic ProcessorWorldCollisionOverride ProcessorWorldMap
|
||||||
|
ProcessorWorldTime
|
||||||
)
|
)
|
||||||
|
|
||||||
# Main executable
|
# Main executable
|
||||||
|
|
|
@ -1289,22 +1289,6 @@ void LocalPlayer::setBooks()
|
||||||
ptrNpcStats.flagAsUsed(book.bookId);
|
ptrNpcStats.flagAsUsed(book.bookId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalPlayer::setMapExplored()
|
|
||||||
{
|
|
||||||
MWWorld::Ptr ptrPlayer = getPlayerPtr();
|
|
||||||
MWMechanics::NpcStats &ptrNpcStats = ptrPlayer.getClass().getNpcStats(ptrPlayer);
|
|
||||||
|
|
||||||
for (const auto &mapTile : mapChanges.mapTiles)
|
|
||||||
{
|
|
||||||
const MWWorld::CellStore *cellStore = MWBase::Environment::get().getWorld()->getExterior(mapTile.x, mapTile.y);
|
|
||||||
|
|
||||||
if (!cellStore->getCell()->mName.empty())
|
|
||||||
MWBase::Environment::get().getWindowManager()->addVisitedLocation(cellStore->getCell()->mName, mapTile.x, mapTile.y);
|
|
||||||
|
|
||||||
MWBase::Environment::get().getWindowManager()->setGlobalMapImage(mapTile.x, mapTile.y, mapTile.imageData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void LocalPlayer::setShapeshift()
|
void LocalPlayer::setShapeshift()
|
||||||
{
|
{
|
||||||
MWWorld::Ptr ptrPlayer = getPlayerPtr();
|
MWWorld::Ptr ptrPlayer = getPlayerPtr();
|
||||||
|
@ -1650,23 +1634,6 @@ void LocalPlayer::sendSelectedSpell(const std::string& newSelectedSpellId)
|
||||||
getNetworking()->getPlayerPacket(ID_PLAYER_MISCELLANEOUS)->Send();
|
getNetworking()->getPlayerPacket(ID_PLAYER_MISCELLANEOUS)->Send();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalPlayer::sendMapExplored(int x, int y, const std::vector<char>& imageData)
|
|
||||||
{
|
|
||||||
mapChanges.mapTiles.clear();
|
|
||||||
|
|
||||||
mwmp::MapTile mapTile;
|
|
||||||
mapTile.x = x;
|
|
||||||
mapTile.y = y;
|
|
||||||
mapTile.imageData = imageData;
|
|
||||||
|
|
||||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_PLAYER_MAP with x: %i, y: %i", x, y);
|
|
||||||
|
|
||||||
mapChanges.mapTiles.push_back(mapTile);
|
|
||||||
|
|
||||||
getNetworking()->getPlayerPacket(ID_PLAYER_MAP)->setPlayer(this);
|
|
||||||
getNetworking()->getPlayerPacket(ID_PLAYER_MAP)->Send();
|
|
||||||
}
|
|
||||||
|
|
||||||
void LocalPlayer::clearCellStates()
|
void LocalPlayer::clearCellStates()
|
||||||
{
|
{
|
||||||
cellStateChanges.cellStates.clear();
|
cellStateChanges.cellStates.clear();
|
||||||
|
|
|
@ -67,7 +67,6 @@ namespace mwmp
|
||||||
void setShapeshift();
|
void setShapeshift();
|
||||||
void setMarkLocation();
|
void setMarkLocation();
|
||||||
void setSelectedSpell();
|
void setSelectedSpell();
|
||||||
void setMapExplored();
|
|
||||||
|
|
||||||
void sendClass();
|
void sendClass();
|
||||||
void sendInventory();
|
void sendInventory();
|
||||||
|
@ -90,7 +89,6 @@ namespace mwmp
|
||||||
void sendWerewolfState(bool isWerewolf);
|
void sendWerewolfState(bool isWerewolf);
|
||||||
void sendMarkLocation(const ESM::Cell& newMarkCell, const ESM::Position& newMarkPosition);
|
void sendMarkLocation(const ESM::Cell& newMarkCell, const ESM::Position& newMarkPosition);
|
||||||
void sendSelectedSpell(const std::string& newSelectedSpellId);
|
void sendSelectedSpell(const std::string& newSelectedSpellId);
|
||||||
void sendMapExplored(int x, int y, const std::vector<char>& imageData);
|
|
||||||
|
|
||||||
void clearCellStates();
|
void clearCellStates();
|
||||||
void clearCurrentContainer();
|
void clearCurrentContainer();
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
#include <components/openmw-mp/Log.hpp>
|
||||||
|
|
||||||
|
#include "../mwbase/environment.hpp"
|
||||||
|
|
||||||
|
#include "../mwgui/windowmanagerimp.hpp"
|
||||||
|
|
||||||
|
#include "../mwworld/worldimp.hpp"
|
||||||
|
|
||||||
#include "Worldstate.hpp"
|
#include "Worldstate.hpp"
|
||||||
#include "Main.hpp"
|
#include "Main.hpp"
|
||||||
#include "Networking.hpp"
|
#include "Networking.hpp"
|
||||||
|
@ -22,3 +30,33 @@ Networking *Worldstate::getNetworking()
|
||||||
{
|
{
|
||||||
return mwmp::Main::get().getNetworking();
|
return mwmp::Main::get().getNetworking();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Worldstate::sendMapExplored(int x, int y, const std::vector<char>& imageData)
|
||||||
|
{
|
||||||
|
mapChanges.mapTiles.clear();
|
||||||
|
|
||||||
|
mwmp::MapTile mapTile;
|
||||||
|
mapTile.x = x;
|
||||||
|
mapTile.y = y;
|
||||||
|
mapTile.imageData = imageData;
|
||||||
|
|
||||||
|
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_PLAYER_MAP with x: %i, y: %i", x, y);
|
||||||
|
|
||||||
|
mapChanges.mapTiles.push_back(mapTile);
|
||||||
|
|
||||||
|
getNetworking()->getWorldstatePacket(ID_WORLD_MAP)->setWorldstate(this);
|
||||||
|
getNetworking()->getWorldstatePacket(ID_WORLD_MAP)->Send();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Worldstate::setMapExplored()
|
||||||
|
{
|
||||||
|
for (const auto &mapTile : mapChanges.mapTiles)
|
||||||
|
{
|
||||||
|
const MWWorld::CellStore *cellStore = MWBase::Environment::get().getWorld()->getExterior(mapTile.x, mapTile.y);
|
||||||
|
|
||||||
|
if (!cellStore->getCell()->mName.empty())
|
||||||
|
MWBase::Environment::get().getWindowManager()->addVisitedLocation(cellStore->getCell()->mName, mapTile.x, mapTile.y);
|
||||||
|
|
||||||
|
MWBase::Environment::get().getWindowManager()->setGlobalMapImage(mapTile.x, mapTile.y, mapTile.imageData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -13,6 +13,10 @@ namespace mwmp
|
||||||
Worldstate();
|
Worldstate();
|
||||||
virtual ~Worldstate();
|
virtual ~Worldstate();
|
||||||
|
|
||||||
|
void setMapExplored();
|
||||||
|
|
||||||
|
void sendMapExplored(int x, int y, const std::vector<char>& imageData);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Networking *getNetworking();
|
Networking *getNetworking();
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
#include "player/ProcessorPlayerJournal.hpp"
|
#include "player/ProcessorPlayerJournal.hpp"
|
||||||
#include "player/ProcessorPlayerKillCount.hpp"
|
#include "player/ProcessorPlayerKillCount.hpp"
|
||||||
#include "player/ProcessorPlayerLevel.hpp"
|
#include "player/ProcessorPlayerLevel.hpp"
|
||||||
#include "player/ProcessorPlayerMap.hpp"
|
|
||||||
#include "player/ProcessorPlayerMiscellaneous.hpp"
|
#include "player/ProcessorPlayerMiscellaneous.hpp"
|
||||||
#include "player/ProcessorPlayerMomentum.hpp"
|
#include "player/ProcessorPlayerMomentum.hpp"
|
||||||
#include "player/ProcessorPlayerPosition.hpp"
|
#include "player/ProcessorPlayerPosition.hpp"
|
||||||
|
@ -92,6 +91,7 @@
|
||||||
#include "WorldstateProcessor.hpp"
|
#include "WorldstateProcessor.hpp"
|
||||||
#include "worldstate/ProcessorRecordDynamic.hpp"
|
#include "worldstate/ProcessorRecordDynamic.hpp"
|
||||||
#include "worldstate/ProcessorWorldCollisionOverride.hpp"
|
#include "worldstate/ProcessorWorldCollisionOverride.hpp"
|
||||||
|
#include "worldstate/ProcessorWorldMap.hpp"
|
||||||
#include "worldstate/ProcessorWorldTime.hpp"
|
#include "worldstate/ProcessorWorldTime.hpp"
|
||||||
|
|
||||||
using namespace mwmp;
|
using namespace mwmp;
|
||||||
|
@ -127,7 +127,6 @@ void ProcessorInitializer()
|
||||||
PlayerProcessor::AddProcessor(new ProcessorPlayerJournal());
|
PlayerProcessor::AddProcessor(new ProcessorPlayerJournal());
|
||||||
PlayerProcessor::AddProcessor(new ProcessorPlayerKillCount());
|
PlayerProcessor::AddProcessor(new ProcessorPlayerKillCount());
|
||||||
PlayerProcessor::AddProcessor(new ProcessorPlayerLevel());
|
PlayerProcessor::AddProcessor(new ProcessorPlayerLevel());
|
||||||
PlayerProcessor::AddProcessor(new ProcessorPlayerMap());
|
|
||||||
PlayerProcessor::AddProcessor(new ProcessorPlayerMiscellaneous());
|
PlayerProcessor::AddProcessor(new ProcessorPlayerMiscellaneous());
|
||||||
PlayerProcessor::AddProcessor(new ProcessorPlayerMomentum());
|
PlayerProcessor::AddProcessor(new ProcessorPlayerMomentum());
|
||||||
PlayerProcessor::AddProcessor(new ProcessorPlayerPosition());
|
PlayerProcessor::AddProcessor(new ProcessorPlayerPosition());
|
||||||
|
@ -186,5 +185,6 @@ void ProcessorInitializer()
|
||||||
|
|
||||||
WorldstateProcessor::AddProcessor(new ProcessorRecordDynamic());
|
WorldstateProcessor::AddProcessor(new ProcessorRecordDynamic());
|
||||||
WorldstateProcessor::AddProcessor(new ProcessorWorldCollisionOverride());
|
WorldstateProcessor::AddProcessor(new ProcessorWorldCollisionOverride());
|
||||||
|
WorldstateProcessor::AddProcessor(new ProcessorWorldMap());
|
||||||
WorldstateProcessor::AddProcessor(new ProcessorWorldTime());
|
WorldstateProcessor::AddProcessor(new ProcessorWorldTime());
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ using namespace mwmp;
|
||||||
template<class T>
|
template<class T>
|
||||||
typename BasePacketProcessor<T>::processors_t BasePacketProcessor<T>::processors;
|
typename BasePacketProcessor<T>::processors_t BasePacketProcessor<T>::processors;
|
||||||
|
|
||||||
bool WorldstateProcessor::Process(RakNet::Packet &packet, BaseWorldstate &worldstate)
|
bool WorldstateProcessor::Process(RakNet::Packet &packet, Worldstate &worldstate)
|
||||||
{
|
{
|
||||||
RakNet::BitStream bsIn(&packet.data[1], packet.length, false);
|
RakNet::BitStream bsIn(&packet.data[1], packet.length, false);
|
||||||
bsIn.Read(guid);
|
bsIn.Read(guid);
|
||||||
|
|
|
@ -11,9 +11,9 @@ namespace mwmp
|
||||||
class WorldstateProcessor : public BasePacketProcessor<WorldstateProcessor>, public BaseClientPacketProcessor
|
class WorldstateProcessor : public BasePacketProcessor<WorldstateProcessor>, public BaseClientPacketProcessor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void Do(WorldstatePacket &packet, BaseWorldstate &worldstate) = 0;
|
virtual void Do(WorldstatePacket &packet, Worldstate &worldstate) = 0;
|
||||||
|
|
||||||
static bool Process(RakNet::Packet &packet, BaseWorldstate &worldstate);
|
static bool Process(RakNet::Packet &packet, Worldstate &worldstate);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
#ifndef OPENMW_PROCESSORPLAYERMAP_HPP
|
|
||||||
#define OPENMW_PROCESSORPLAYERMAP_HPP
|
|
||||||
|
|
||||||
#include "../PlayerProcessor.hpp"
|
|
||||||
|
|
||||||
namespace mwmp
|
|
||||||
{
|
|
||||||
class ProcessorPlayerMap : public PlayerProcessor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ProcessorPlayerMap()
|
|
||||||
{
|
|
||||||
BPP_INIT(ID_PLAYER_MAP)
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void Do(PlayerPacket &packet, BasePlayer *player)
|
|
||||||
{
|
|
||||||
if (isLocal())
|
|
||||||
{
|
|
||||||
static_cast<LocalPlayer*>(player)->setMapExplored();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif //OPENMW_PROCESSORPLAYERMAP_HPP
|
|
|
@ -13,7 +13,7 @@ namespace mwmp
|
||||||
BPP_INIT(ID_RECORD_DYNAMIC)
|
BPP_INIT(ID_RECORD_DYNAMIC)
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Do(WorldstatePacket &packet, BaseWorldstate &worldstate)
|
virtual void Do(WorldstatePacket &packet, Worldstate &worldstate)
|
||||||
{
|
{
|
||||||
// Placeholder
|
// Placeholder
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace mwmp
|
||||||
BPP_INIT(ID_WORLD_COLLISION_OVERRIDE)
|
BPP_INIT(ID_WORLD_COLLISION_OVERRIDE)
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Do(WorldstatePacket &packet, BaseWorldstate &worldstate)
|
virtual void Do(WorldstatePacket &packet, Worldstate &worldstate)
|
||||||
{
|
{
|
||||||
// Placeholder
|
// Placeholder
|
||||||
}
|
}
|
||||||
|
|
23
apps/openmw/mwmp/processors/worldstate/ProcessorWorldMap.hpp
Normal file
23
apps/openmw/mwmp/processors/worldstate/ProcessorWorldMap.hpp
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
#ifndef OPENMW_PROCESSORWORLDMAP_HPP
|
||||||
|
#define OPENMW_PROCESSORWORLDMAP_HPP
|
||||||
|
|
||||||
|
#include "../WorldstateProcessor.hpp"
|
||||||
|
|
||||||
|
namespace mwmp
|
||||||
|
{
|
||||||
|
class ProcessorWorldMap : public WorldstateProcessor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ProcessorWorldMap()
|
||||||
|
{
|
||||||
|
BPP_INIT(ID_WORLD_MAP)
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void Do(WorldstatePacket &packet, Worldstate &worldstate)
|
||||||
|
{
|
||||||
|
worldstate.setMapExplored();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //OPENMW_PROCESSORWORLDMAP_HPP
|
|
@ -16,7 +16,7 @@ namespace mwmp
|
||||||
BPP_INIT(ID_WORLD_TIME)
|
BPP_INIT(ID_WORLD_TIME)
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Do(WorldstatePacket &packet, BaseWorldstate &worldstate)
|
virtual void Do(WorldstatePacket &packet, Worldstate &worldstate)
|
||||||
{
|
{
|
||||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,8 @@
|
||||||
*/
|
*/
|
||||||
#include <components/openmw-mp/Log.hpp>
|
#include <components/openmw-mp/Log.hpp>
|
||||||
#include "../mwmp/Main.hpp"
|
#include "../mwmp/Main.hpp"
|
||||||
#include "../mwmp/LocalPlayer.hpp"
|
#include "../mwmp/Networking.hpp"
|
||||||
|
#include "../mwmp/Worldstate.hpp"
|
||||||
/*
|
/*
|
||||||
End of tes3mp addition
|
End of tes3mp addition
|
||||||
*/
|
*/
|
||||||
|
@ -660,7 +661,7 @@ namespace MWRender
|
||||||
std::string stringData = ostream.str();
|
std::string stringData = ostream.str();
|
||||||
std::vector<char> vectorData = std::vector<char>(stringData.begin(), stringData.end());
|
std::vector<char> vectorData = std::vector<char>(stringData.begin(), stringData.end());
|
||||||
|
|
||||||
mwmp::Main::get().getLocalPlayer()->sendMapExplored(originToCellX.at(imageDest.mX), originToCellY.at(imageDest.mY), vectorData);
|
mwmp::Main::get().getNetworking()->getWorldstate()->sendMapExplored(originToCellX.at(imageDest.mX), originToCellY.at(imageDest.mY), vectorData);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
End of tes3mp addition
|
End of tes3mp addition
|
||||||
|
|
|
@ -184,9 +184,10 @@ add_component_dir (openmw-mp/Packets/Player
|
||||||
PacketPlayerAttack PacketPlayerAttribute PacketPlayerBehavior PacketPlayerBook PacketPlayerBounty
|
PacketPlayerAttack PacketPlayerAttribute PacketPlayerBehavior PacketPlayerBook PacketPlayerBounty
|
||||||
PacketPlayerCellChange PacketPlayerCellState PacketPlayerClass PacketPlayerDeath PacketPlayerEquipment
|
PacketPlayerCellChange PacketPlayerCellState PacketPlayerClass PacketPlayerDeath PacketPlayerEquipment
|
||||||
PacketPlayerFaction PacketPlayerInteraction PacketPlayerInventory PacketPlayerJail PacketPlayerJournal
|
PacketPlayerFaction PacketPlayerInteraction PacketPlayerInventory PacketPlayerJail PacketPlayerJournal
|
||||||
PacketPlayerKillCount PacketPlayerLevel PacketPlayerMap PacketPlayerMiscellaneous PacketPlayerMomentum
|
PacketPlayerKillCount PacketPlayerLevel PacketPlayerMiscellaneous PacketPlayerMomentum PacketPlayerPosition
|
||||||
PacketPlayerPosition PacketPlayerQuickKeys PacketPlayerRegionAuthority PacketPlayerReputation PacketPlayerRest
|
PacketPlayerQuickKeys PacketPlayerRegionAuthority PacketPlayerReputation PacketPlayerRest PacketPlayerResurrect
|
||||||
PacketPlayerResurrect PacketPlayerShapeshift PacketPlayerSkill PacketPlayerSpeech PacketPlayerSpellbook PacketPlayerStatsDynamic PacketPlayerTopic
|
PacketPlayerShapeshift PacketPlayerSkill PacketPlayerSpeech PacketPlayerSpellbook PacketPlayerStatsDynamic
|
||||||
|
PacketPlayerTopic
|
||||||
)
|
)
|
||||||
|
|
||||||
add_component_dir (openmw-mp/Packets/Object
|
add_component_dir (openmw-mp/Packets/Object
|
||||||
|
@ -202,7 +203,7 @@ add_component_dir (openmw-mp/Packets/Object
|
||||||
add_component_dir (openmw-mp/Packets/Worldstate
|
add_component_dir (openmw-mp/Packets/Worldstate
|
||||||
WorldstatePacket
|
WorldstatePacket
|
||||||
|
|
||||||
PacketRecordDynamic PacketWorldCollisionOverride PacketWorldTime
|
PacketRecordDynamic PacketWorldCollisionOverride PacketWorldMap PacketWorldTime
|
||||||
)
|
)
|
||||||
|
|
||||||
add_component_dir (fallback
|
add_component_dir (fallback
|
||||||
|
|
|
@ -91,13 +91,6 @@ namespace mwmp
|
||||||
int type; // 0 - Cell load, 1 - Cell unload
|
int type; // 0 - Cell load, 1 - Cell unload
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MapTile
|
|
||||||
{
|
|
||||||
int x;
|
|
||||||
int y;
|
|
||||||
std::vector<char> imageData;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct JournalChanges
|
struct JournalChanges
|
||||||
{
|
{
|
||||||
std::vector<JournalItem> journalItems;
|
std::vector<JournalItem> journalItems;
|
||||||
|
@ -137,11 +130,6 @@ namespace mwmp
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MapChanges
|
|
||||||
{
|
|
||||||
std::vector<MapTile> mapTiles;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct InventoryChanges
|
struct InventoryChanges
|
||||||
{
|
{
|
||||||
std::vector<Item> items;
|
std::vector<Item> items;
|
||||||
|
@ -269,7 +257,6 @@ namespace mwmp
|
||||||
TopicChanges topicChanges;
|
TopicChanges topicChanges;
|
||||||
KillChanges killChanges;
|
KillChanges killChanges;
|
||||||
BookChanges bookChanges;
|
BookChanges bookChanges;
|
||||||
MapChanges mapChanges;
|
|
||||||
CellStateChanges cellStateChanges;
|
CellStateChanges cellStateChanges;
|
||||||
|
|
||||||
ESM::ActiveSpells activeSpells;
|
ESM::ActiveSpells activeSpells;
|
||||||
|
|
|
@ -1,12 +1,25 @@
|
||||||
#ifndef OPENMW_BASEWORLDSTATE_HPP
|
#ifndef OPENMW_BASEWORLDSTATE_HPP
|
||||||
#define OPENMW_BASEWORLDSTATE_HPP
|
#define OPENMW_BASEWORLDSTATE_HPP
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include <components/openmw-mp/Base/BaseStructs.hpp>
|
#include <components/openmw-mp/Base/BaseStructs.hpp>
|
||||||
|
|
||||||
#include <RakNetTypes.h>
|
#include <RakNetTypes.h>
|
||||||
|
|
||||||
namespace mwmp
|
namespace mwmp
|
||||||
{
|
{
|
||||||
|
struct MapTile
|
||||||
|
{
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
std::vector<char> imageData;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct MapChanges
|
||||||
|
{
|
||||||
|
std::vector<MapTile> mapTiles;
|
||||||
|
};
|
||||||
|
|
||||||
class BaseWorldstate
|
class BaseWorldstate
|
||||||
{
|
{
|
||||||
|
@ -37,6 +50,8 @@ namespace mwmp
|
||||||
bool hasPlacedObjectCollision;
|
bool hasPlacedObjectCollision;
|
||||||
bool useActorCollisionForPlacedObjects;
|
bool useActorCollisionForPlacedObjects;
|
||||||
|
|
||||||
|
MapChanges mapChanges;
|
||||||
|
|
||||||
bool isValid;
|
bool isValid;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
#include "../Packets/Player/PacketPlayerJournal.hpp"
|
#include "../Packets/Player/PacketPlayerJournal.hpp"
|
||||||
#include "../Packets/Player/PacketPlayerKillCount.hpp"
|
#include "../Packets/Player/PacketPlayerKillCount.hpp"
|
||||||
#include "../Packets/Player/PacketPlayerLevel.hpp"
|
#include "../Packets/Player/PacketPlayerLevel.hpp"
|
||||||
#include "../Packets/Player/PacketPlayerMap.hpp"
|
|
||||||
#include "../Packets/Player/PacketPlayerMiscellaneous.hpp"
|
#include "../Packets/Player/PacketPlayerMiscellaneous.hpp"
|
||||||
#include "../Packets/Player/PacketPlayerMomentum.hpp"
|
#include "../Packets/Player/PacketPlayerMomentum.hpp"
|
||||||
#include "../Packets/Player/PacketPlayerPosition.hpp"
|
#include "../Packets/Player/PacketPlayerPosition.hpp"
|
||||||
|
@ -87,7 +86,6 @@ mwmp::PlayerPacketController::PlayerPacketController(RakNet::RakPeerInterface *p
|
||||||
AddPacket<PacketPlayerJournal>(&packets, peer);
|
AddPacket<PacketPlayerJournal>(&packets, peer);
|
||||||
AddPacket<PacketPlayerKillCount>(&packets, peer);
|
AddPacket<PacketPlayerKillCount>(&packets, peer);
|
||||||
AddPacket<PacketPlayerLevel>(&packets, peer);
|
AddPacket<PacketPlayerLevel>(&packets, peer);
|
||||||
AddPacket<PacketPlayerMap>(&packets, peer);
|
|
||||||
AddPacket<PacketPlayerMiscellaneous>(&packets, peer);
|
AddPacket<PacketPlayerMiscellaneous>(&packets, peer);
|
||||||
AddPacket<PacketPlayerMomentum>(&packets, peer);
|
AddPacket<PacketPlayerMomentum>(&packets, peer);
|
||||||
AddPacket<PacketPlayerPosition>(&packets, peer);
|
AddPacket<PacketPlayerPosition>(&packets, peer);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "../Packets/Worldstate/PacketRecordDynamic.hpp"
|
#include "../Packets/Worldstate/PacketRecordDynamic.hpp"
|
||||||
#include "../Packets/Worldstate/PacketWorldCollisionOverride.hpp"
|
#include "../Packets/Worldstate/PacketWorldCollisionOverride.hpp"
|
||||||
|
#include "../Packets/Worldstate/PacketWorldMap.hpp"
|
||||||
#include "../Packets/Worldstate/PacketWorldTime.hpp"
|
#include "../Packets/Worldstate/PacketWorldTime.hpp"
|
||||||
|
|
||||||
#include "WorldstatePacketController.hpp"
|
#include "WorldstatePacketController.hpp"
|
||||||
|
@ -16,6 +17,7 @@ mwmp::WorldstatePacketController::WorldstatePacketController(RakNet::RakPeerInte
|
||||||
{
|
{
|
||||||
AddPacket<PacketRecordDynamic>(&packets, peer);
|
AddPacket<PacketRecordDynamic>(&packets, peer);
|
||||||
AddPacket<PacketWorldCollisionOverride>(&packets, peer);
|
AddPacket<PacketWorldCollisionOverride>(&packets, peer);
|
||||||
|
AddPacket<PacketWorldMap>(&packets, peer);
|
||||||
AddPacket<PacketWorldTime>(&packets, peer);
|
AddPacket<PacketWorldTime>(&packets, peer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,6 @@ enum GameMessages
|
||||||
ID_PLAYER_JOURNAL,
|
ID_PLAYER_JOURNAL,
|
||||||
ID_PLAYER_KILL_COUNT,
|
ID_PLAYER_KILL_COUNT,
|
||||||
ID_PLAYER_LEVEL,
|
ID_PLAYER_LEVEL,
|
||||||
ID_PLAYER_MAP,
|
|
||||||
ID_PLAYER_MISCELLANEOUS,
|
ID_PLAYER_MISCELLANEOUS,
|
||||||
ID_PLAYER_MOMENTUM,
|
ID_PLAYER_MOMENTUM,
|
||||||
ID_PLAYER_POSITION,
|
ID_PLAYER_POSITION,
|
||||||
|
@ -109,6 +108,7 @@ enum GameMessages
|
||||||
|
|
||||||
ID_RECORD_DYNAMIC,
|
ID_RECORD_DYNAMIC,
|
||||||
ID_WORLD_COLLISION_OVERRIDE,
|
ID_WORLD_COLLISION_OVERRIDE,
|
||||||
|
ID_WORLD_MAP,
|
||||||
ID_WORLD_TIME,
|
ID_WORLD_TIME,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
//
|
|
||||||
// Created by koncord on 05.03.17.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <components/openmw-mp/NetworkMessages.hpp>
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
#include "PacketPreInit.hpp"
|
#include "PacketPreInit.hpp"
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
//
|
|
||||||
// Created by koncord on 05.03.17.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef OPENMW_PACKETPREINIT_HPP
|
#ifndef OPENMW_PACKETPREINIT_HPP
|
||||||
#define OPENMW_PACKETPREINIT_HPP
|
#define OPENMW_PACKETPREINIT_HPP
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
//
|
|
||||||
// Created by koncord on 15.01.16.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <components/openmw-mp/NetworkMessages.hpp>
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||||
#include "PacketPlayerAnimFlags.hpp"
|
#include "PacketPlayerAnimFlags.hpp"
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
//
|
|
||||||
// Created by koncord on 15.01.16.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef OPENMW_PACKETPLAYERANIMFLAGS_HPP
|
#ifndef OPENMW_PACKETPLAYERANIMFLAGS_HPP
|
||||||
#define OPENMW_PACKETPLAYERANIMFLAGS_HPP
|
#define OPENMW_PACKETPLAYERANIMFLAGS_HPP
|
||||||
|
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
#ifndef OPENMW_PACKETPLAYERMAP_HPP
|
|
||||||
#define OPENMW_PACKETPLAYERMAP_HPP
|
|
||||||
|
|
||||||
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
|
|
||||||
|
|
||||||
namespace mwmp
|
|
||||||
{
|
|
||||||
class PacketPlayerMap : public PlayerPacket
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
PacketPlayerMap(RakNet::RakPeerInterface *peer);
|
|
||||||
|
|
||||||
virtual void Packet(RakNet::BitStream *bs, bool send);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif //OPENMW_PACKETPLAYERMAP_HPP
|
|
|
@ -1,32 +1,32 @@
|
||||||
#include <components/openmw-mp/NetworkMessages.hpp>
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||||
#include "PacketPlayerMap.hpp"
|
#include "PacketWorldMap.hpp"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace mwmp;
|
using namespace mwmp;
|
||||||
|
|
||||||
PacketPlayerMap::PacketPlayerMap(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
|
PacketWorldMap::PacketWorldMap(RakNet::RakPeerInterface *peer) : WorldstatePacket(peer)
|
||||||
{
|
{
|
||||||
packetID = ID_PLAYER_MAP;
|
packetID = ID_WORLD_MAP;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PacketPlayerMap::Packet(RakNet::BitStream *bs, bool send)
|
void PacketWorldMap::Packet(RakNet::BitStream *bs, bool send)
|
||||||
{
|
{
|
||||||
PlayerPacket::Packet(bs, send);
|
WorldstatePacket::Packet(bs, send);
|
||||||
|
|
||||||
uint32_t changesCount;
|
uint32_t changesCount;
|
||||||
|
|
||||||
if (send)
|
if (send)
|
||||||
changesCount = static_cast<uint32_t>(player->mapChanges.mapTiles.size());
|
changesCount = static_cast<uint32_t>(worldstate->mapChanges.mapTiles.size());
|
||||||
|
|
||||||
RW(changesCount, send);
|
RW(changesCount, send);
|
||||||
|
|
||||||
if (!send)
|
if (!send)
|
||||||
{
|
{
|
||||||
player->mapChanges.mapTiles.clear();
|
worldstate->mapChanges.mapTiles.clear();
|
||||||
player->mapChanges.mapTiles.resize(changesCount);
|
worldstate->mapChanges.mapTiles.resize(changesCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &&mapTile : player->mapChanges.mapTiles)
|
for (auto &&mapTile : worldstate->mapChanges.mapTiles)
|
||||||
{
|
{
|
||||||
RW(mapTile.x, send);
|
RW(mapTile.x, send);
|
||||||
RW(mapTile.y, send);
|
RW(mapTile.y, send);
|
17
components/openmw-mp/Packets/Worldstate/PacketWorldMap.hpp
Normal file
17
components/openmw-mp/Packets/Worldstate/PacketWorldMap.hpp
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#ifndef OPENMW_PACKETWORLDMAP_HPP
|
||||||
|
#define OPENMW_PACKETWORLDMAP_HPP
|
||||||
|
|
||||||
|
#include <components/openmw-mp/Packets/Worldstate/WorldstatePacket.hpp>
|
||||||
|
|
||||||
|
namespace mwmp
|
||||||
|
{
|
||||||
|
class PacketWorldMap : public WorldstatePacket
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PacketWorldMap(RakNet::RakPeerInterface *peer);
|
||||||
|
|
||||||
|
virtual void Packet(RakNet::BitStream *bs, bool send);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //OPENMW_PACKETWORLDMAP_HPP
|
|
@ -1,5 +1,5 @@
|
||||||
#include "PacketWorldTime.hpp"
|
|
||||||
#include <components/openmw-mp/NetworkMessages.hpp>
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||||
|
#include "PacketWorldTime.hpp"
|
||||||
|
|
||||||
using namespace mwmp;
|
using namespace mwmp;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue