diff --git a/apps/openmw-mp/Script/Functions/Dialogue.cpp b/apps/openmw-mp/Script/Functions/Dialogue.cpp index 0659bcfa2..f2f2f8d8a 100644 --- a/apps/openmw-mp/Script/Functions/Dialogue.cpp +++ b/apps/openmw-mp/Script/Functions/Dialogue.cpp @@ -12,7 +12,7 @@ void DialogueFunctions::ClearTopicChanges(unsigned short pid) noexcept Player *player; GET_PLAYER(pid, player, ); - player->topicChanges.topics.clear(); + player->topicChanges.clear(); } unsigned int DialogueFunctions::GetTopicChangesSize(unsigned short pid) noexcept @@ -20,7 +20,7 @@ unsigned int DialogueFunctions::GetTopicChangesSize(unsigned short pid) noexcept Player *player; GET_PLAYER(pid, player, 0); - return player->topicChanges.count; + return player->topicChanges.size(); } void DialogueFunctions::AddTopic(unsigned short pid, const char* topicId) noexcept @@ -31,7 +31,7 @@ void DialogueFunctions::AddTopic(unsigned short pid, const char* topicId) noexce mwmp::Topic topic; topic.topicId = topicId; - player->topicChanges.topics.push_back(topic); + player->topicChanges.push_back(topic); } const char *DialogueFunctions::GetTopicId(unsigned short pid, unsigned int index) noexcept @@ -39,10 +39,10 @@ const char *DialogueFunctions::GetTopicId(unsigned short pid, unsigned int index Player *player; GET_PLAYER(pid, player, ""); - if (index >= player->topicChanges.count) + if (index >= player->topicChanges.size()) return "invalid"; - return player->topicChanges.topics.at(index).topicId.c_str(); + return player->topicChanges.at(index).topicId.c_str(); } void DialogueFunctions::SendTopicChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index f910d0e5b..4b779607e 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -779,7 +779,7 @@ void LocalPlayer::addJournalItems() void LocalPlayer::addTopics() { auto &env = MWBase::Environment::get(); - for (const auto &topic : topicChanges.topics) + for (const auto &topic : topicChanges) { std::string topicId = topic.topicId; @@ -1589,7 +1589,7 @@ void LocalPlayer::sendFactionReputation(const std::string& factionId, int reputa void LocalPlayer::sendTopic(const std::string& topicId) { - topicChanges.topics.clear(); + topicChanges.clear(); mwmp::Topic topic; @@ -1601,7 +1601,7 @@ void LocalPlayer::sendTopic(const std::string& topicId) LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Sending ID_PLAYER_TOPIC with topic %s", topic.topicId.c_str()); - topicChanges.topics.push_back(topic); + topicChanges.push_back(topic); getNetworking()->getPlayerPacket(ID_PLAYER_TOPIC)->setPlayer(this); getNetworking()->getPlayerPacket(ID_PLAYER_TOPIC)->Send(); diff --git a/components/openmw-mp/Base/BasePlayer.hpp b/components/openmw-mp/Base/BasePlayer.hpp index a277ac2a6..bbb966ac1 100644 --- a/components/openmw-mp/Base/BasePlayer.hpp +++ b/components/openmw-mp/Base/BasePlayer.hpp @@ -103,12 +103,6 @@ namespace mwmp int action; // 0 - Rank, 1 - Expulsion state, 2 - Both }; - struct TopicChanges - { - std::vector topics; - unsigned int count; - }; - struct BookChanges { std::vector books; @@ -235,7 +229,7 @@ namespace mwmp std::vector quickKeyChanges; std::vector journalChanges; FactionChanges factionChanges; - TopicChanges topicChanges; + std::vector topicChanges; BookChanges bookChanges; CellStateChanges cellStateChanges; diff --git a/components/openmw-mp/Packets/Player/PacketPlayerTopic.cpp b/components/openmw-mp/Packets/Player/PacketPlayerTopic.cpp index f53bf1847..3179c62a7 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerTopic.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerTopic.cpp @@ -13,23 +13,21 @@ void PacketPlayerTopic::Packet(RakNet::BitStream *bs, bool send) { PlayerPacket::Packet(bs, send); + uint32_t count; + if (send) - player->topicChanges.count = (unsigned int)(player->topicChanges.topics.size()); - else - player->topicChanges.topics.clear(); + count = static_cast(player->topicChanges.size()); - RW(player->topicChanges.count, send); + RW(count, send); - for (unsigned int i = 0; i < player->topicChanges.count; i++) + if (!send) { - Topic topic; - - if (send) - topic = player->topicChanges.topics.at(i); + player->topicChanges.clear(); + player->topicChanges.resize(count); + } + for (auto &&topic : player->topicChanges) + { RW(topic.topicId, send, true); - - if (!send) - player->topicChanges.topics.push_back(topic); } }