diff --git a/CHANGELOG.md b/CHANGELOG.md index 49c0f3ef3..7a958fbc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -87,6 +87,7 @@ Bug #4413: Moving with 0 strength uses all of your fatigue Bug #4420: Camera flickering when I open up and close menus while sneaking Bug #4435: Item health is considered a signed integer + Bug #4441: Adding items to currently disabled weapon-wielding creatures crashes the game Feature #1786: Round up encumbrance value in the encumbrance bar Feature #2694: Editor: rename "model" column to make its purpose clear Feature #3870: Editor: Terrain Texture Brush Button diff --git a/apps/openmw-mp/BaseMgr.cpp b/apps/openmw-mp/BaseMgr.cpp index 484991ff4..128910d40 100644 --- a/apps/openmw-mp/BaseMgr.cpp +++ b/apps/openmw-mp/BaseMgr.cpp @@ -4,12 +4,18 @@ #include "BaseMgr.hpp" #include "Player.hpp" +#include "Worldstate.hpp" BaseMgr::BaseMgr(Player *player) : player(player), changed(false) { } +BaseMgr::BaseMgr(Worldstate *worldstate) : worldstate(worldstate), changed(false) +{ + +} + void BaseMgr::update() { if (!changed) @@ -22,5 +28,7 @@ void BaseMgr::update() void BaseMgr::setChanged() { changed = true; - player->addToUpdateQueue(); + + if (player != nullptr) + player->addToUpdateQueue(); } diff --git a/apps/openmw-mp/BaseMgr.hpp b/apps/openmw-mp/BaseMgr.hpp index 2c830eb81..6502d969a 100644 --- a/apps/openmw-mp/BaseMgr.hpp +++ b/apps/openmw-mp/BaseMgr.hpp @@ -5,17 +5,20 @@ #pragma once class Player; +class Worldstate; class BaseMgr { public: explicit BaseMgr(Player *player); + explicit BaseMgr(Worldstate *worldstate); void update(); protected: bool isChanged() const { return changed; }; void setChanged(); virtual void processUpdate() = 0; Player *player; + Worldstate *worldstate; private: bool changed; }; diff --git a/apps/openmw-mp/CMakeLists.txt b/apps/openmw-mp/CMakeLists.txt index 8e6919949..f9e09e925 100644 --- a/apps/openmw-mp/CMakeLists.txt +++ b/apps/openmw-mp/CMakeLists.txt @@ -85,12 +85,12 @@ set(PROCESSORS_PLAYER processors/player/ProcessorPlayerFaction.hpp processors/player/ProcessorPlayerInteraction.hpp processors/player/ProcessorPlayerInventory.hpp processors/player/ProcessorPlayerJournal.hpp processors/player/ProcessorPlayerKillCount.hpp processors/player/ProcessorPlayerLevel.hpp - processors/player/ProcessorPlayerMap.hpp processors/player/ProcessorPlayerMiscellaneous.hpp - processors/player/ProcessorPlayerPosition.hpp processors/player/ProcessorPlayerQuickKeys.hpp - processors/player/ProcessorPlayerRest.hpp processors/player/ProcessorPlayerResurrect.hpp - processors/player/ProcessorPlayerShapeshift.hpp processors/player/ProcessorPlayerSkill.hpp - processors/player/ProcessorPlayerSpeech.hpp processors/player/ProcessorPlayerSpellbook.hpp - processors/player/ProcessorPlayerStatsDynamic.hpp processors/player/ProcessorPlayerTopic.hpp + processors/player/ProcessorPlayerMiscellaneous.hpp processors/player/ProcessorPlayerPosition.hpp + processors/player/ProcessorPlayerQuickKeys.hpp processors/player/ProcessorPlayerRest.hpp + processors/player/ProcessorPlayerResurrect.hpp processors/player/ProcessorPlayerShapeshift.hpp + processors/player/ProcessorPlayerSkill.hpp processors/player/ProcessorPlayerSpeech.hpp + processors/player/ProcessorPlayerSpellbook.hpp processors/player/ProcessorPlayerStatsDynamic.hpp + processors/player/ProcessorPlayerTopic.hpp ) source_group(tes3mp-server\\processors\\player FILES ${PROCESSORS_PLAYER}) @@ -111,7 +111,7 @@ set(PROCESSORS_OBJECT source_group(tes3mp-server\\processors\\object FILES ${PROCESSORS_OBJECT}) set(PROCESSORS_WORLDSTATE - processors/worldstate/ProcessorRecordDynamic.hpp + processors/worldstate/ProcessorRecordDynamic.hpp processors/worldstate/ProcessorWorldMap.hpp ) source_group(tes3mp-server\\processors\\worldstate FILES ${PROCESSORS_WORLDSTATE}) @@ -132,7 +132,7 @@ include_directories("./") add_executable(tes3mp-server ${SERVER} ${SERVER_HEADER} - ${PROCESSORS_ACTOR} ${PROCESSORS_PLAYER} ${PROCESSORS_OBJECT} ${PROCESSORS} + ${PROCESSORS_ACTOR} ${PROCESSORS_PLAYER} ${PROCESSORS_OBJECT} ${PROCESSORS_WORLDSTATE} ${PROCESSORS} ${APPLE_BUNDLE_RESOURCES} ) diff --git a/apps/openmw-mp/GUI.cpp b/apps/openmw-mp/GUI.cpp index aea40c864..c3f678aaf 100644 --- a/apps/openmw-mp/GUI.cpp +++ b/apps/openmw-mp/GUI.cpp @@ -277,103 +277,3 @@ void QuickKey::setItemId(const std::string &itemId) { quickKey.itemId = itemId; } - -void MapTiles::Init(LuaState &lua) -{ - lua.getState()->new_usertype("MapTiles", - "addMapTile", &MapTiles::addMapTile, - "getMapTile", &MapTiles::getMapTile, - "setMapTile", &MapTiles::setMapTile, - "clear", &MapTiles::clear, - "size", &MapTiles::size - ); -} - -MapTiles::MapTiles(Player *player) : BaseMgr(player) -{ - -} - -void MapTiles::processUpdate() -{ - auto packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_MAP); - packet->setPlayer(player); - packet->Send(false); - clear(); -} - -void MapTiles::addMapTile(const MapTile &mapTile) -{ - player->mapChanges.mapTiles.push_back(mapTile.mapTile); - setChanged(); -} - -MapTile MapTiles::getMapTile(int id) const -{ - return MapTile(player->mapChanges.mapTiles.at(id)); -} - -void MapTiles::setMapTile(int id, const MapTile &mapTile) -{ - player->mapChanges.mapTiles.at(id) = mapTile.mapTile; - setChanged(); -} - -void MapTiles::clear() -{ - player->mapChanges.mapTiles.clear(); - setChanged(); -} - -size_t MapTiles::size() const -{ - return player->mapChanges.mapTiles.size(); -} - -void MapTile::Init(LuaState &lua) -{ - lua.getState()->new_usertype("MapTile", - "cellX", sol::property(&MapTile::getCellX, &MapTile::setCellX), - "cellY", sol::property(&MapTile::getCellY, &MapTile::setCellY), - "loadImageFile", &MapTile::loadImageFile, - "saveImageFile", &MapTile::saveImageFile - ); -} - -MapTile::MapTile(mwmp::MapTile &mapTile) : mapTile(mapTile) -{ - -} - -int MapTile::getCellX() const -{ - return mapTile.x; -} - -void MapTile::setCellX(int cellX) -{ - mapTile.x = cellX; -} - -int MapTile::getCellY() const -{ - return mapTile.y; -} - -void MapTile::setCellY(int cellY) -{ - mapTile.y = cellY; -} - -void MapTile::loadImageFile(const char* filePath) -{ - std::ifstream inputFile(filePath, std::ios::binary); - mapTile.imageData = std::vector(std::istreambuf_iterator(inputFile), std::istreambuf_iterator()); -} - -void MapTile::saveImageFile(const char* filePath) -{ - std::ofstream outputFile(filePath, std::ios::binary); - std::ostream_iterator outputIterator(outputFile); - std::copy(mapTile.imageData.begin(), mapTile.imageData.end(), outputIterator); -} diff --git a/apps/openmw-mp/GUI.hpp b/apps/openmw-mp/GUI.hpp index 36dfb6f05..1f0f7f69f 100644 --- a/apps/openmw-mp/GUI.hpp +++ b/apps/openmw-mp/GUI.hpp @@ -80,40 +80,3 @@ public: private: void processUpdate() final; }; - -class MapTile -{ - friend class MapTiles; -public: - static void Init(LuaState &lua); -public: - explicit MapTile(mwmp::MapTile &mapTile); - - int getCellX() const; - void setCellX(int cellX); - - int getCellY() const; - void setCellY(int cellY); - - void loadImageFile(const char* filePath); - void saveImageFile(const char *filePath); - - mwmp::MapTile mapTile; -}; - -class MapTiles final: public BaseMgr -{ -public: - static void Init(LuaState &lua); -public: - explicit MapTiles(Player *player); - - void addMapTile(const MapTile &mapTile); - MapTile getMapTile(int id) const; - void setMapTile(int id, const MapTile &mapTile); - size_t size() const; - void clear(); - -private: - void processUpdate() final; -}; diff --git a/apps/openmw-mp/Player.cpp b/apps/openmw-mp/Player.cpp index 9c17df78b..b5fe9fac2 100644 --- a/apps/openmw-mp/Player.cpp +++ b/apps/openmw-mp/Player.cpp @@ -92,7 +92,6 @@ void Player::Init(LuaState &lua) "getQuests", &Player::getQuests, "getSpells", &Player::getSpells, "getQuickKeys", &Player::getQuickKeys, - "getMapTiles", &Player::getMapTiles, "getWeatherMgr", &Player::getWeatherMgr, "getMark", &Player::getMark, @@ -118,9 +117,9 @@ void Player::Init(LuaState &lua) "leaveChannel", 3); } -Player::Player(RakNet::RakNetGUID guid) : BasePlayer(guid), NetActor(), changedMap(false), cClass(this), - settings(this), books(this), gui(this), dialogue(this), factions(this), - quests(this), spells(this), quickKeys(this), mapTiles(this), weatherMgr(this) +Player::Player(RakNet::RakNetGUID guid) : BasePlayer(guid), NetActor(), cClass(this), settings(this), books(this), gui(this), + dialogue(this), factions(this), quests(this), spells(this), quickKeys(this), + weatherMgr(this) { basePlayer = this; netCreature = this; @@ -277,14 +276,6 @@ void Player::update() changedSelectedSpell = false; } - if (changedMap) - { - auto packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_MAP); - packet->setPlayer(this); - packet->Send(/*toOthers*/ false); - changedMap = false; - } - settings.update(); books.update(); gui.update(); @@ -293,7 +284,6 @@ void Player::update() quests.update(); spells.update(); quickKeys.update(); - mapTiles.update(); weatherMgr.update(); resetUpdateFlags(); @@ -835,11 +825,6 @@ QuickKeys &Player::getQuickKeys() return quickKeys; } -MapTiles &Player::getMapTiles() -{ - return mapTiles; -} - WeatherMgr &Player::getWeatherMgr() { return weatherMgr; diff --git a/apps/openmw-mp/Player.hpp b/apps/openmw-mp/Player.hpp index 0ecda3af8..b540a0d1d 100644 --- a/apps/openmw-mp/Player.hpp +++ b/apps/openmw-mp/Player.hpp @@ -198,7 +198,6 @@ public: Quests &getQuests(); Spells &getSpells(); QuickKeys &getQuickKeys(); - MapTiles &getMapTiles(); WeatherMgr &getWeatherMgr(); void setAuthority(); @@ -211,7 +210,7 @@ private: CellController::TContainer cells; int loadState; int handshakeCounter; - bool /*statsChanged, attributesChanged, skillsChanged, baseInfoChanged, positionChanged,*/ changedMarkLocation, changedSelectedSpell, changedMap; + bool /*statsChanged, attributesChanged, skillsChanged, baseInfoChanged, positionChanged,*/ changedMarkLocation, changedSelectedSpell; CharClass cClass; GameSettings settings; Books books; @@ -221,7 +220,6 @@ private: Quests quests; Spells spells; QuickKeys quickKeys; - MapTiles mapTiles; WeatherMgr weatherMgr; sol::table storedData; sol::table customData; diff --git a/apps/openmw-mp/Script/EventController.cpp b/apps/openmw-mp/Script/EventController.cpp index e01fdd9c1..46cceb568 100644 --- a/apps/openmw-mp/Script/EventController.cpp +++ b/apps/openmw-mp/Script/EventController.cpp @@ -63,7 +63,6 @@ EventController::EventController(LuaState *luaCtrl) ADD_CORE_EVENT(ON_PLAYER_DISPOSITION), ADD_CORE_EVENT(ON_PLAYER_BOOK), ADD_CORE_EVENT(ON_PLAYER_MISCELLANEOUS), - ADD_CORE_EVENT(ON_PLAYER_MAP), ADD_CORE_EVENT(ON_PLAYER_INTERACTION), ADD_CORE_EVENT(ON_PLAYER_REST), ADD_CORE_EVENT(ON_PLAYER_SENDMESSAGE), @@ -88,7 +87,8 @@ EventController::EventController(LuaState *luaCtrl) ADD_CORE_EVENT(ON_OBJECT_DELETE), ADD_CORE_EVENT(ON_OBJECT_LOCK), ADD_CORE_EVENT(ON_OBJECT_SCALE), - ADD_CORE_EVENT(ON_OBJECT_TRAP) + ADD_CORE_EVENT(ON_OBJECT_TRAP), + ADD_CORE_EVENT(ON_WORLD_MAP) ); sol::state &state = *luaCtrl->getState(); diff --git a/apps/openmw-mp/Script/EventController.hpp b/apps/openmw-mp/Script/EventController.hpp index d9adfa87c..d2cb638d2 100644 --- a/apps/openmw-mp/Script/EventController.hpp +++ b/apps/openmw-mp/Script/EventController.hpp @@ -39,7 +39,6 @@ namespace CoreEvent ON_PLAYER_DISPOSITION, ON_PLAYER_BOOK, ON_PLAYER_MISCELLANEOUS, - ON_PLAYER_MAP, ON_PLAYER_INTERACTION, ON_PLAYER_REST, ON_PLAYER_SENDMESSAGE, @@ -71,6 +70,8 @@ namespace CoreEvent ON_OBJECT_SCALE, ON_OBJECT_TRAP, + ON_WORLD_MAP, + LAST, }; const int FIRST = ON_EXIT; diff --git a/apps/openmw-mp/Worldstate.cpp b/apps/openmw-mp/Worldstate.cpp index 8427df744..d73e453ab 100644 --- a/apps/openmw-mp/Worldstate.cpp +++ b/apps/openmw-mp/Worldstate.cpp @@ -5,10 +5,19 @@ using namespace std; +Worldstate::Worldstate() : mapTiles(this) +{ + +} + void Worldstate::Init(LuaState &lua) { sol::table worldstateTable = lua.getState()->create_named_table("Worldstate"); + //worldstateTable.set_function("getMapTiles", []() { + // mwmp::Networking::get().get().getServerWorldstate()->getMapTiles(); + //}); + worldstateTable.set_function("setHour", [](double hour) { mwmp::Networking::get().get().getServerWorldstate()->setHour(hour); }); @@ -71,6 +80,13 @@ void Worldstate::update() shouldUpdateCollisionOverrides = false; } + + //mapTiles.update(); +} + +MapTiles &Worldstate::getMapTiles() +{ + return mapTiles; } void Worldstate::setHour(double inputHour) @@ -131,3 +147,103 @@ void Worldstate::setActorCollisionForPlacedObjects(bool state) useActorCollisionForPlacedObjects = state; shouldUpdateCollisionOverrides = true; } + +void MapTiles::Init(LuaState &lua) +{ + lua.getState()->new_usertype("MapTiles", + "addMapTile", &MapTiles::addMapTile, + "getMapTile", &MapTiles::getMapTile, + "setMapTile", &MapTiles::setMapTile, + "clear", &MapTiles::clear, + "size", &MapTiles::size + ); +} + +MapTiles::MapTiles(Worldstate *worldstate) : BaseMgr(worldstate) +{ + +} + +void MapTiles::processUpdate() +{ + auto packet = mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_MAP); + packet->Send(false); + clear(); +} + +void MapTiles::addMapTile(const MapTile &mapTile) +{ + mwmp::Networking::get().get().getServerWorldstate()->mapChanges.mapTiles.push_back(mapTile.mapTile); + setChanged(); +} + +MapTile MapTiles::getMapTile(int id) const +{ + return MapTile(mwmp::Networking::get().get().getServerWorldstate()->mapChanges.mapTiles.at(id)); +} + +void MapTiles::setMapTile(int id, const MapTile &mapTile) +{ + mwmp::Networking::get().get().getServerWorldstate()->mapChanges.mapTiles.at(id) = mapTile.mapTile; + setChanged(); +} + +void MapTiles::clear() +{ + mwmp::Networking::get().get().getServerWorldstate()->mapChanges.mapTiles.clear(); + setChanged(); +} + +size_t MapTiles::size() const +{ + return mwmp::Networking::get().get().getServerWorldstate()->mapChanges.mapTiles.size(); +} + +void MapTile::Init(LuaState &lua) +{ + lua.getState()->new_usertype("MapTile", + "cellX", sol::property(&MapTile::getCellX, &MapTile::setCellX), + "cellY", sol::property(&MapTile::getCellY, &MapTile::setCellY), + "loadImageFile", &MapTile::loadImageFile, + "saveImageFile", &MapTile::saveImageFile + ); +} + +MapTile::MapTile(mwmp::BaseMapTile &mapTile) : mapTile(mapTile) +{ + +} + +int MapTile::getCellX() const +{ + return mapTile.x; +} + +void MapTile::setCellX(int cellX) +{ + mapTile.x = cellX; +} + +int MapTile::getCellY() const +{ + return mapTile.y; +} + +void MapTile::setCellY(int cellY) +{ + mapTile.y = cellY; +} + +void MapTile::loadImageFile(const char* filePath) +{ + std::ifstream inputFile(filePath, std::ios::binary); + mapTile.imageData = std::vector(std::istreambuf_iterator(inputFile), std::istreambuf_iterator()); +} + +void MapTile::saveImageFile(const char* filePath) +{ + std::ofstream outputFile(filePath, std::ios::binary); + std::ostream_iterator outputIterator(outputFile); + std::copy(mapTile.imageData.begin(), mapTile.imageData.end(), outputIterator); +} + diff --git a/apps/openmw-mp/Worldstate.hpp b/apps/openmw-mp/Worldstate.hpp index 1d087c8cd..e0c676a8c 100644 --- a/apps/openmw-mp/Worldstate.hpp +++ b/apps/openmw-mp/Worldstate.hpp @@ -6,17 +6,60 @@ #include #include +#include "BaseMgr.hpp" + class LuaState; +class MapTile +{ + friend class MapTiles; +public: + static void Init(LuaState &lua); +public: + explicit MapTile(mwmp::BaseMapTile &mapTile); + + int getCellX() const; + void setCellX(int cellX); + + int getCellY() const; + void setCellY(int cellY); + + void loadImageFile(const char* filePath); + void saveImageFile(const char *filePath); + + mwmp::BaseMapTile mapTile; +}; + +class MapTiles final : public BaseMgr +{ +public: + static void Init(LuaState &lua); +public: + explicit MapTiles(Worldstate *worldstate); + + void addMapTile(const MapTile &mapTile); + MapTile getMapTile(int id) const; + void setMapTile(int id, const MapTile &mapTile); + size_t size() const; + void clear(); + +private: + void processUpdate() final; +}; + class Worldstate : public mwmp::BaseWorldstate { public: + explicit Worldstate(); + static void Init(LuaState &lua); void update(); + MapTiles &getMapTiles(); + void setHour(double hour); void setDay(int day); void setMonth(int month); @@ -33,4 +76,7 @@ private: bool shouldUpdateTime, shouldUpdateCollisionOverrides; + MapTiles mapTiles; + }; + diff --git a/apps/openmw-mp/processors/ProcessorInitializer.cpp b/apps/openmw-mp/processors/ProcessorInitializer.cpp index a7f0fb441..9cc8fb44e 100644 --- a/apps/openmw-mp/processors/ProcessorInitializer.cpp +++ b/apps/openmw-mp/processors/ProcessorInitializer.cpp @@ -26,7 +26,6 @@ #include "player/ProcessorPlayerKillCount.hpp" #include "player/ProcessorPlayerInteraction.hpp" #include "player/ProcessorPlayerLevel.hpp" -#include "player/ProcessorPlayerMap.hpp" #include "player/ProcessorPlayerMiscellaneous.hpp" #include "player/ProcessorPlayerPosition.hpp" #include "player/ProcessorPlayerQuickKeys.hpp" @@ -76,6 +75,7 @@ #include "object/ProcessorVideoPlay.hpp" #include "WorldstateProcessor.hpp" #include "worldstate/ProcessorRecordDynamic.hpp" +#include "worldstate/ProcessorWorldMap.hpp" using namespace mwmp; @@ -104,7 +104,6 @@ void ProcessorInitializer() PlayerProcessor::AddProcessor(new ProcessorPlayerKillCount()); PlayerProcessor::AddProcessor(new ProcessorPlayerInteraction()); PlayerProcessor::AddProcessor(new ProcessorPlayerLevel()); - PlayerProcessor::AddProcessor(new ProcessorPlayerMap()); PlayerProcessor::AddProcessor(new ProcessorPlayerMiscellaneous()); PlayerProcessor::AddProcessor(new ProcessorPlayerPosition()); PlayerProcessor::AddProcessor(new ProcessorPlayerQuickKeys()); @@ -154,4 +153,5 @@ void ProcessorInitializer() ObjectProcessor::AddProcessor(new ProcessorVideoPlay()); WorldstateProcessor::AddProcessor(new ProcessorRecordDynamic()); + WorldstateProcessor::AddProcessor(new ProcessorWorldMap()); } diff --git a/apps/openmw-mp/processors/worldstate/ProcessorWorldMap.hpp b/apps/openmw-mp/processors/worldstate/ProcessorWorldMap.hpp new file mode 100644 index 000000000..9311afc06 --- /dev/null +++ b/apps/openmw-mp/processors/worldstate/ProcessorWorldMap.hpp @@ -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, const std::shared_ptr &player, BaseWorldstate &worldstate) override + { + DEBUG_PRINTF(strPacketID.c_str()); + + Networking::get().getState().getEventCtrl().Call(player.get()); + } + }; +} + +#endif //OPENMW_PROCESSORWORLDMAP_HPP diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 1ccd1f47f..c6d320aa8 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -119,9 +119,10 @@ add_openmw_dir (mwmp/processors/player ProcessorChatMessage ProcessorGUIMessageB ProcessorPlayerBehavior ProcessorPlayerBook ProcessorPlayerBounty ProcessorPlayerCellChange ProcessorPlayerCellState ProcessorPlayerCharClass ProcessorPlayerCharGen ProcessorPlayerDeath ProcessorPlayerDisposition ProcessorPlayerEquipment ProcessorPlayerFaction ProcessorPlayerInteraction ProcessorPlayerInventory ProcessorPlayerJail ProcessorPlayerJournal - ProcessorPlayerKillCount ProcessorPlayerLevel ProcessorPlayerMap ProcessorPlayerMiscellaneous ProcessorPlayerMomentum - ProcessorPlayerPosition ProcessorPlayerQuickKeys ProcessorPlayerReputation ProcessorPlayerResurrect ProcessorPlayerShapeshift - ProcessorPlayerSkill ProcessorPlayerSpeech ProcessorPlayerSpellbook ProcessorPlayerStatsDynamic ProcessorPlayerTopic + ProcessorPlayerKillCount ProcessorPlayerLevel ProcessorPlayerMiscellaneous ProcessorPlayerMomentum + ProcessorPlayerPosition ProcessorPlayerQuickKeys ProcessorPlayerReputation ProcessorPlayerResurrect + ProcessorPlayerShapeshift ProcessorPlayerSkill ProcessorPlayerSpeech ProcessorPlayerSpellbook ProcessorPlayerStatsDynamic + ProcessorPlayerTopic ) 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 ) -add_openmw_dir (mwmp/processors/worldstate ProcessorRecordDynamic ProcessorWorldCollisionOverride ProcessorWorldTime +add_openmw_dir (mwmp/processors/worldstate ProcessorRecordDynamic ProcessorWorldCollisionOverride ProcessorWorldMap + ProcessorWorldTime ) # Main executable diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index 4fe517308..95443525d 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -1297,22 +1297,6 @@ void LocalPlayer::setBooks() 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() { MWWorld::Ptr ptrPlayer = getPlayerPtr(); @@ -1656,23 +1640,6 @@ void LocalPlayer::sendSelectedSpell(const std::string& newSelectedSpellId) getNetworking()->getPlayerPacket(ID_PLAYER_MISCELLANEOUS)->Send(); } -void LocalPlayer::sendMapExplored(int x, int y, const std::vector& 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() { cellStateChanges.cellStates.clear(); diff --git a/apps/openmw/mwmp/LocalPlayer.hpp b/apps/openmw/mwmp/LocalPlayer.hpp index b916da73d..df0955f68 100644 --- a/apps/openmw/mwmp/LocalPlayer.hpp +++ b/apps/openmw/mwmp/LocalPlayer.hpp @@ -67,7 +67,6 @@ namespace mwmp void setShapeshift(); void setMarkLocation(); void setSelectedSpell(); - void setMapExplored(); void sendClass(); void sendInventory(); @@ -90,7 +89,6 @@ namespace mwmp void sendWerewolfState(bool isWerewolf); void sendMarkLocation(const ESM::Cell& newMarkCell, const ESM::Position& newMarkPosition); void sendSelectedSpell(const std::string& newSelectedSpellId); - void sendMapExplored(int x, int y, const std::vector& imageData); void clearCellStates(); void clearCurrentContainer(); diff --git a/apps/openmw/mwmp/Worldstate.cpp b/apps/openmw/mwmp/Worldstate.cpp index e3c487445..9af7369b9 100644 --- a/apps/openmw/mwmp/Worldstate.cpp +++ b/apps/openmw/mwmp/Worldstate.cpp @@ -1,3 +1,11 @@ +#include + +#include "../mwbase/environment.hpp" + +#include "../mwgui/windowmanagerimp.hpp" + +#include "../mwworld/worldimp.hpp" + #include "Worldstate.hpp" #include "Main.hpp" #include "Networking.hpp" @@ -22,3 +30,33 @@ Networking *Worldstate::getNetworking() { return mwmp::Main::get().getNetworking(); } + +void Worldstate::sendMapExplored(int x, int y, const std::vector& imageData) +{ + mapChanges.mapTiles.clear(); + + mwmp::BaseMapTile 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); + } +} diff --git a/apps/openmw/mwmp/Worldstate.hpp b/apps/openmw/mwmp/Worldstate.hpp index 97b89375d..df44372c1 100644 --- a/apps/openmw/mwmp/Worldstate.hpp +++ b/apps/openmw/mwmp/Worldstate.hpp @@ -13,6 +13,10 @@ namespace mwmp Worldstate(); virtual ~Worldstate(); + void setMapExplored(); + + void sendMapExplored(int x, int y, const std::vector& imageData); + private: Networking *getNetworking(); diff --git a/apps/openmw/mwmp/processors/ProcessorInitializer.cpp b/apps/openmw/mwmp/processors/ProcessorInitializer.cpp index f9883dce0..d27faff88 100644 --- a/apps/openmw/mwmp/processors/ProcessorInitializer.cpp +++ b/apps/openmw/mwmp/processors/ProcessorInitializer.cpp @@ -31,7 +31,6 @@ #include "player/ProcessorPlayerJournal.hpp" #include "player/ProcessorPlayerKillCount.hpp" #include "player/ProcessorPlayerLevel.hpp" -#include "player/ProcessorPlayerMap.hpp" #include "player/ProcessorPlayerMiscellaneous.hpp" #include "player/ProcessorPlayerMomentum.hpp" #include "player/ProcessorPlayerPosition.hpp" @@ -93,6 +92,7 @@ #include "WorldstateProcessor.hpp" #include "worldstate/ProcessorRecordDynamic.hpp" #include "worldstate/ProcessorWorldCollisionOverride.hpp" +#include "worldstate/ProcessorWorldMap.hpp" #include "worldstate/ProcessorWorldTime.hpp" using namespace mwmp; @@ -129,7 +129,6 @@ void ProcessorInitializer() PlayerProcessor::AddProcessor(new ProcessorPlayerJournal()); PlayerProcessor::AddProcessor(new ProcessorPlayerKillCount()); PlayerProcessor::AddProcessor(new ProcessorPlayerLevel()); - PlayerProcessor::AddProcessor(new ProcessorPlayerMap()); PlayerProcessor::AddProcessor(new ProcessorPlayerMiscellaneous()); PlayerProcessor::AddProcessor(new ProcessorPlayerMomentum()); PlayerProcessor::AddProcessor(new ProcessorPlayerPosition()); @@ -188,5 +187,6 @@ void ProcessorInitializer() WorldstateProcessor::AddProcessor(new ProcessorRecordDynamic()); WorldstateProcessor::AddProcessor(new ProcessorWorldCollisionOverride()); + WorldstateProcessor::AddProcessor(new ProcessorWorldMap()); WorldstateProcessor::AddProcessor(new ProcessorWorldTime()); } diff --git a/apps/openmw/mwmp/processors/WorldstateProcessor.cpp b/apps/openmw/mwmp/processors/WorldstateProcessor.cpp index 693241ace..210815c58 100644 --- a/apps/openmw/mwmp/processors/WorldstateProcessor.cpp +++ b/apps/openmw/mwmp/processors/WorldstateProcessor.cpp @@ -8,7 +8,7 @@ using namespace mwmp; template typename BasePacketProcessor::processors_t BasePacketProcessor::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); bsIn.Read(guid); diff --git a/apps/openmw/mwmp/processors/WorldstateProcessor.hpp b/apps/openmw/mwmp/processors/WorldstateProcessor.hpp index 77a888e0d..faf523896 100644 --- a/apps/openmw/mwmp/processors/WorldstateProcessor.hpp +++ b/apps/openmw/mwmp/processors/WorldstateProcessor.hpp @@ -11,9 +11,9 @@ namespace mwmp class WorldstateProcessor : public BasePacketProcessor, public BaseClientPacketProcessor { 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); }; } diff --git a/apps/openmw/mwmp/processors/worldstate/ProcessorRecordDynamic.hpp b/apps/openmw/mwmp/processors/worldstate/ProcessorRecordDynamic.hpp index 591a6d66c..757355c7a 100644 --- a/apps/openmw/mwmp/processors/worldstate/ProcessorRecordDynamic.hpp +++ b/apps/openmw/mwmp/processors/worldstate/ProcessorRecordDynamic.hpp @@ -13,7 +13,7 @@ namespace mwmp BPP_INIT(ID_RECORD_DYNAMIC) } - virtual void Do(WorldstatePacket &packet, BaseWorldstate &worldstate) + virtual void Do(WorldstatePacket &packet, Worldstate &worldstate) { // Placeholder } diff --git a/apps/openmw/mwmp/processors/worldstate/ProcessorWorldCollisionOverride.hpp b/apps/openmw/mwmp/processors/worldstate/ProcessorWorldCollisionOverride.hpp index e918e7d09..aab6fc3de 100644 --- a/apps/openmw/mwmp/processors/worldstate/ProcessorWorldCollisionOverride.hpp +++ b/apps/openmw/mwmp/processors/worldstate/ProcessorWorldCollisionOverride.hpp @@ -16,7 +16,7 @@ namespace mwmp BPP_INIT(ID_WORLD_COLLISION_OVERRIDE) } - virtual void Do(WorldstatePacket &packet, BaseWorldstate &worldstate) + virtual void Do(WorldstatePacket &packet, Worldstate &worldstate) { // Placeholder } diff --git a/apps/openmw/mwmp/processors/worldstate/ProcessorWorldMap.hpp b/apps/openmw/mwmp/processors/worldstate/ProcessorWorldMap.hpp new file mode 100644 index 000000000..388f9a17e --- /dev/null +++ b/apps/openmw/mwmp/processors/worldstate/ProcessorWorldMap.hpp @@ -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 diff --git a/apps/openmw/mwmp/processors/worldstate/ProcessorWorldTime.hpp b/apps/openmw/mwmp/processors/worldstate/ProcessorWorldTime.hpp index 002917ec5..99e0f1abe 100644 --- a/apps/openmw/mwmp/processors/worldstate/ProcessorWorldTime.hpp +++ b/apps/openmw/mwmp/processors/worldstate/ProcessorWorldTime.hpp @@ -16,7 +16,7 @@ namespace mwmp 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(); diff --git a/apps/openmw/mwrender/globalmap.cpp b/apps/openmw/mwrender/globalmap.cpp index 2ce6517ba..218ef7704 100644 --- a/apps/openmw/mwrender/globalmap.cpp +++ b/apps/openmw/mwrender/globalmap.cpp @@ -26,7 +26,8 @@ */ #include #include "../mwmp/Main.hpp" -#include "../mwmp/LocalPlayer.hpp" +#include "../mwmp/Networking.hpp" +#include "../mwmp/Worldstate.hpp" /* End of tes3mp addition */ @@ -660,7 +661,7 @@ namespace MWRender std::string stringData = ostream.str(); std::vector vectorData = std::vector(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 diff --git a/apps/openmw/mwrender/objects.cpp b/apps/openmw/mwrender/objects.cpp index f0a3d2e38..db6772eaa 100644 --- a/apps/openmw/mwrender/objects.cpp +++ b/apps/openmw/mwrender/objects.cpp @@ -123,11 +123,12 @@ bool Objects::removeObject (const MWWorld::Ptr& ptr) mObjects.erase(iter); - if (ptr.getClass().isNpc()) + if (ptr.getClass().isActor()) { - MWWorld::InventoryStore& store = ptr.getClass().getInventoryStore(ptr); - store.setInvListener(NULL, ptr); - store.setContListener(NULL); + if (ptr.getClass().hasInventoryStore(ptr)) + ptr.getClass().getInventoryStore(ptr).setInvListener(NULL, ptr); + + ptr.getClass().getContainerStore(ptr).setContListener(NULL); } ptr.getRefData().getBaseNode()->getParent(0)->removeChild(ptr.getRefData().getBaseNode()); diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 09dc7c3d9..f864acf5f 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -184,9 +184,10 @@ add_component_dir (openmw-mp/Packets/Player PacketPlayerAttack PacketPlayerAttribute PacketPlayerBehavior PacketPlayerBook PacketPlayerBounty PacketPlayerCellChange PacketPlayerCellState PacketPlayerClass PacketPlayerDeath PacketPlayerEquipment PacketPlayerFaction PacketPlayerInteraction PacketPlayerInventory PacketPlayerJail PacketPlayerJournal - PacketPlayerKillCount PacketPlayerLevel PacketPlayerMap PacketPlayerMiscellaneous PacketPlayerMomentum - PacketPlayerPosition PacketPlayerQuickKeys PacketPlayerRegionAuthority PacketPlayerReputation PacketPlayerRest - PacketPlayerResurrect PacketPlayerShapeshift PacketPlayerSkill PacketPlayerSpeech PacketPlayerSpellbook PacketPlayerStatsDynamic PacketPlayerTopic + PacketPlayerKillCount PacketPlayerLevel PacketPlayerMiscellaneous PacketPlayerMomentum PacketPlayerPosition + PacketPlayerQuickKeys PacketPlayerRegionAuthority PacketPlayerReputation PacketPlayerRest PacketPlayerResurrect + PacketPlayerShapeshift PacketPlayerSkill PacketPlayerSpeech PacketPlayerSpellbook PacketPlayerStatsDynamic + PacketPlayerTopic ) 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 WorldstatePacket - PacketRecordDynamic PacketWorldCollisionOverride PacketWorldTime + PacketRecordDynamic PacketWorldCollisionOverride PacketWorldMap PacketWorldTime ) add_component_dir (fallback diff --git a/components/openmw-mp/Base/BasePlayer.hpp b/components/openmw-mp/Base/BasePlayer.hpp index e62253f8f..977d94623 100644 --- a/components/openmw-mp/Base/BasePlayer.hpp +++ b/components/openmw-mp/Base/BasePlayer.hpp @@ -123,13 +123,6 @@ namespace mwmp Type type; }; - struct MapTile - { - int x; - int y; - std::vector imageData; - }; - struct JournalChanges { std::vector journalItems; @@ -155,11 +148,6 @@ namespace mwmp std::vector books; }; - struct MapChanges - { - std::vector mapTiles; - }; - struct SpellbookChanges { std::vector spells; @@ -296,7 +284,6 @@ namespace mwmp TopicChanges topicChanges; KillChanges killChanges; BookChanges bookChanges; - MapChanges mapChanges; CellStateChanges cellStateChanges; ESM::ActiveSpells activeSpells; diff --git a/components/openmw-mp/Base/BaseWorldstate.hpp b/components/openmw-mp/Base/BaseWorldstate.hpp index 6e2518c0f..cd15ee940 100644 --- a/components/openmw-mp/Base/BaseWorldstate.hpp +++ b/components/openmw-mp/Base/BaseWorldstate.hpp @@ -1,12 +1,25 @@ #ifndef OPENMW_BASEWORLDSTATE_HPP #define OPENMW_BASEWORLDSTATE_HPP +#include + #include #include namespace mwmp { + struct BaseMapTile + { + int x; + int y; + std::vector imageData; + }; + + struct MapChanges + { + std::vector mapTiles; + }; class BaseWorldstate { @@ -37,6 +50,8 @@ namespace mwmp bool hasPlacedObjectCollision; bool useActorCollisionForPlacedObjects; + MapChanges mapChanges; + bool isValid; }; } diff --git a/components/openmw-mp/Controllers/PlayerPacketController.cpp b/components/openmw-mp/Controllers/PlayerPacketController.cpp index 41729c946..69d745351 100644 --- a/components/openmw-mp/Controllers/PlayerPacketController.cpp +++ b/components/openmw-mp/Controllers/PlayerPacketController.cpp @@ -29,7 +29,6 @@ #include "../Packets/Player/PacketPlayerJournal.hpp" #include "../Packets/Player/PacketPlayerKillCount.hpp" #include "../Packets/Player/PacketPlayerLevel.hpp" -#include "../Packets/Player/PacketPlayerMap.hpp" #include "../Packets/Player/PacketPlayerMiscellaneous.hpp" #include "../Packets/Player/PacketPlayerMomentum.hpp" #include "../Packets/Player/PacketPlayerPosition.hpp" @@ -81,7 +80,6 @@ mwmp::PlayerPacketController::PlayerPacketController(RakNet::RakPeerInterface *p AddPacket(&packets, peer); AddPacket(&packets, peer); AddPacket(&packets, peer); - AddPacket(&packets, peer); AddPacket(&packets, peer); AddPacket(&packets, peer); AddPacket(&packets, peer); diff --git a/components/openmw-mp/Controllers/WorldstatePacketController.cpp b/components/openmw-mp/Controllers/WorldstatePacketController.cpp index 94cc6b528..7ef179866 100644 --- a/components/openmw-mp/Controllers/WorldstatePacketController.cpp +++ b/components/openmw-mp/Controllers/WorldstatePacketController.cpp @@ -1,5 +1,6 @@ #include "../Packets/Worldstate/PacketRecordDynamic.hpp" #include "../Packets/Worldstate/PacketWorldCollisionOverride.hpp" +#include "../Packets/Worldstate/PacketWorldMap.hpp" #include "../Packets/Worldstate/PacketWorldTime.hpp" #include "WorldstatePacketController.hpp" @@ -8,5 +9,6 @@ mwmp::WorldstatePacketController::WorldstatePacketController(RakNet::RakPeerInte { AddPacket(&packets, peer); AddPacket(&packets, peer); + AddPacket(&packets, peer); AddPacket(&packets, peer); } diff --git a/components/openmw-mp/NetworkMessages.hpp b/components/openmw-mp/NetworkMessages.hpp index 9b2d87abe..fa5ba1fd8 100644 --- a/components/openmw-mp/NetworkMessages.hpp +++ b/components/openmw-mp/NetworkMessages.hpp @@ -44,7 +44,6 @@ enum GameMessages ID_PLAYER_JOURNAL, ID_PLAYER_KILL_COUNT, ID_PLAYER_LEVEL, - ID_PLAYER_MAP, ID_PLAYER_MISCELLANEOUS, ID_PLAYER_MOMENTUM, ID_PLAYER_POSITION, @@ -110,6 +109,7 @@ enum GameMessages ID_RECORD_DYNAMIC, ID_WORLD_COLLISION_OVERRIDE, + ID_WORLD_MAP, ID_WORLD_TIME, }; diff --git a/components/openmw-mp/Packets/PacketPreInit.cpp b/components/openmw-mp/Packets/PacketPreInit.cpp index 91e5e28e7..147da1972 100644 --- a/components/openmw-mp/Packets/PacketPreInit.cpp +++ b/components/openmw-mp/Packets/PacketPreInit.cpp @@ -1,7 +1,3 @@ -// -// Created by koncord on 05.03.17. -// - #include #include #include "PacketPreInit.hpp" diff --git a/components/openmw-mp/Packets/PacketPreInit.hpp b/components/openmw-mp/Packets/PacketPreInit.hpp index a973f0603..b9c82c9dc 100644 --- a/components/openmw-mp/Packets/PacketPreInit.hpp +++ b/components/openmw-mp/Packets/PacketPreInit.hpp @@ -1,7 +1,3 @@ -// -// Created by koncord on 05.03.17. -// - #ifndef OPENMW_PACKETPREINIT_HPP #define OPENMW_PACKETPREINIT_HPP diff --git a/components/openmw-mp/Packets/Player/PacketPlayerAnimFlags.cpp b/components/openmw-mp/Packets/Player/PacketPlayerAnimFlags.cpp index 0173dd8df..73d2361e6 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerAnimFlags.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerAnimFlags.cpp @@ -1,7 +1,3 @@ -// -// Created by koncord on 15.01.16. -// - #include #include "PacketPlayerAnimFlags.hpp" diff --git a/components/openmw-mp/Packets/Player/PacketPlayerAnimFlags.hpp b/components/openmw-mp/Packets/Player/PacketPlayerAnimFlags.hpp index fe7e493ca..168e9a6f9 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerAnimFlags.hpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerAnimFlags.hpp @@ -1,7 +1,3 @@ -// -// Created by koncord on 15.01.16. -// - #ifndef OPENMW_PACKETPLAYERANIMFLAGS_HPP #define OPENMW_PACKETPLAYERANIMFLAGS_HPP diff --git a/components/openmw-mp/Packets/Player/PacketPlayerMap.cpp b/components/openmw-mp/Packets/Player/PacketPlayerMap.cpp deleted file mode 100644 index a0604895b..000000000 --- a/components/openmw-mp/Packets/Player/PacketPlayerMap.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include -#include "PacketPlayerMap.hpp" - -using namespace std; -using namespace mwmp; - -PacketPlayerMap::PacketPlayerMap(RakNet::RakPeerInterface *peer) : PlayerPacket(peer) -{ - packetID = ID_PLAYER_MAP; -} - -void PacketPlayerMap::Packet(RakNet::BitStream *bs, bool send) -{ - PlayerPacket::Packet(bs, send); - - uint32_t changesCount; - - if (send) - changesCount = static_cast(player->mapChanges.mapTiles.size()); - - RW(changesCount, send); - - if (!send) - { - player->mapChanges.mapTiles.clear(); - player->mapChanges.mapTiles.resize(changesCount); - } - - for (auto &&mapTile : player->mapChanges.mapTiles) - { - RW(mapTile.x, send); - RW(mapTile.y, send); - - uint32_t imageDataCount; - - if (send) - imageDataCount = static_cast(mapTile.imageData.size()); - - RW(imageDataCount, send); - - if (!send) - { - mapTile.imageData.clear(); - mapTile.imageData.resize(imageDataCount); - } - - for (auto &&imageChar : mapTile.imageData) - { - RW(imageChar, send); - } - } -} diff --git a/components/openmw-mp/Packets/Player/PacketPlayerMap.hpp b/components/openmw-mp/Packets/Player/PacketPlayerMap.hpp deleted file mode 100644 index 5c63eb9b4..000000000 --- a/components/openmw-mp/Packets/Player/PacketPlayerMap.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef OPENMW_PACKETPLAYERMAP_HPP -#define OPENMW_PACKETPLAYERMAP_HPP - -#include - -namespace mwmp -{ - class PacketPlayerMap final: public PlayerPacket - { - public: - PacketPlayerMap(RakNet::RakPeerInterface *peer); - - void Packet(RakNet::BitStream *bs, bool send) override; - }; -} - -#endif //OPENMW_PACKETPLAYERMAP_HPP diff --git a/components/openmw-mp/Packets/Worldstate/PacketWorldMap.hpp b/components/openmw-mp/Packets/Worldstate/PacketWorldMap.hpp new file mode 100644 index 000000000..b5496f58d --- /dev/null +++ b/components/openmw-mp/Packets/Worldstate/PacketWorldMap.hpp @@ -0,0 +1,17 @@ +#ifndef OPENMW_PACKETWORLDMAP_HPP +#define OPENMW_PACKETWORLDMAP_HPP + +#include + +namespace mwmp +{ + class PacketWorldMap : public WorldstatePacket + { + public: + PacketWorldMap(RakNet::RakPeerInterface *peer); + + virtual void Packet(RakNet::BitStream *bs, bool send); + }; +} + +#endif //OPENMW_PACKETWORLDMAP_HPP diff --git a/components/openmw-mp/Packets/Worldstate/PacketWorldTime.cpp b/components/openmw-mp/Packets/Worldstate/PacketWorldTime.cpp index d19831d90..62f5ff2ee 100644 --- a/components/openmw-mp/Packets/Worldstate/PacketWorldTime.cpp +++ b/components/openmw-mp/Packets/Worldstate/PacketWorldTime.cpp @@ -1,5 +1,5 @@ -#include "PacketWorldTime.hpp" #include +#include "PacketWorldTime.hpp" using namespace mwmp;