mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-04-01 20:06:41 +00:00
[General] Modernize packet style for PlayerTopic
This commit is contained in:
parent
0206d1813c
commit
d66bca8605
4 changed files with 19 additions and 27 deletions
|
@ -12,7 +12,7 @@ void DialogueFunctions::ClearTopicChanges(unsigned short pid) noexcept
|
||||||
Player *player;
|
Player *player;
|
||||||
GET_PLAYER(pid, player, );
|
GET_PLAYER(pid, player, );
|
||||||
|
|
||||||
player->topicChanges.topics.clear();
|
player->topicChanges.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int DialogueFunctions::GetTopicChangesSize(unsigned short pid) noexcept
|
unsigned int DialogueFunctions::GetTopicChangesSize(unsigned short pid) noexcept
|
||||||
|
@ -20,7 +20,7 @@ unsigned int DialogueFunctions::GetTopicChangesSize(unsigned short pid) noexcept
|
||||||
Player *player;
|
Player *player;
|
||||||
GET_PLAYER(pid, player, 0);
|
GET_PLAYER(pid, player, 0);
|
||||||
|
|
||||||
return player->topicChanges.count;
|
return player->topicChanges.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogueFunctions::AddTopic(unsigned short pid, const char* topicId) noexcept
|
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;
|
mwmp::Topic topic;
|
||||||
topic.topicId = topicId;
|
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
|
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;
|
Player *player;
|
||||||
GET_PLAYER(pid, player, "");
|
GET_PLAYER(pid, player, "");
|
||||||
|
|
||||||
if (index >= player->topicChanges.count)
|
if (index >= player->topicChanges.size())
|
||||||
return "invalid";
|
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
|
void DialogueFunctions::SendTopicChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
|
||||||
|
|
|
@ -779,7 +779,7 @@ void LocalPlayer::addJournalItems()
|
||||||
void LocalPlayer::addTopics()
|
void LocalPlayer::addTopics()
|
||||||
{
|
{
|
||||||
auto &env = MWBase::Environment::get();
|
auto &env = MWBase::Environment::get();
|
||||||
for (const auto &topic : topicChanges.topics)
|
for (const auto &topic : topicChanges)
|
||||||
{
|
{
|
||||||
std::string topicId = topic.topicId;
|
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)
|
void LocalPlayer::sendTopic(const std::string& topicId)
|
||||||
{
|
{
|
||||||
topicChanges.topics.clear();
|
topicChanges.clear();
|
||||||
|
|
||||||
mwmp::Topic topic;
|
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());
|
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)->setPlayer(this);
|
||||||
getNetworking()->getPlayerPacket(ID_PLAYER_TOPIC)->Send();
|
getNetworking()->getPlayerPacket(ID_PLAYER_TOPIC)->Send();
|
||||||
|
|
|
@ -103,12 +103,6 @@ namespace mwmp
|
||||||
int action; // 0 - Rank, 1 - Expulsion state, 2 - Both
|
int action; // 0 - Rank, 1 - Expulsion state, 2 - Both
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TopicChanges
|
|
||||||
{
|
|
||||||
std::vector<Topic> topics;
|
|
||||||
unsigned int count;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct BookChanges
|
struct BookChanges
|
||||||
{
|
{
|
||||||
std::vector<Book> books;
|
std::vector<Book> books;
|
||||||
|
@ -235,7 +229,7 @@ namespace mwmp
|
||||||
std::vector<QuickKey> quickKeyChanges;
|
std::vector<QuickKey> quickKeyChanges;
|
||||||
std::vector<JournalItem> journalChanges;
|
std::vector<JournalItem> journalChanges;
|
||||||
FactionChanges factionChanges;
|
FactionChanges factionChanges;
|
||||||
TopicChanges topicChanges;
|
std::vector<Topic> topicChanges;
|
||||||
BookChanges bookChanges;
|
BookChanges bookChanges;
|
||||||
CellStateChanges cellStateChanges;
|
CellStateChanges cellStateChanges;
|
||||||
|
|
||||||
|
|
|
@ -13,23 +13,21 @@ void PacketPlayerTopic::Packet(RakNet::BitStream *bs, bool send)
|
||||||
{
|
{
|
||||||
PlayerPacket::Packet(bs, send);
|
PlayerPacket::Packet(bs, send);
|
||||||
|
|
||||||
|
uint32_t count;
|
||||||
|
|
||||||
if (send)
|
if (send)
|
||||||
player->topicChanges.count = (unsigned int)(player->topicChanges.topics.size());
|
count = static_cast<uint32_t>(player->topicChanges.size());
|
||||||
else
|
|
||||||
player->topicChanges.topics.clear();
|
|
||||||
|
|
||||||
RW(player->topicChanges.count, send);
|
RW(count, send);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < player->topicChanges.count; i++)
|
if (!send)
|
||||||
{
|
{
|
||||||
Topic topic;
|
player->topicChanges.clear();
|
||||||
|
player->topicChanges.resize(count);
|
||||||
if (send)
|
}
|
||||||
topic = player->topicChanges.topics.at(i);
|
|
||||||
|
|
||||||
|
for (auto &&topic : player->topicChanges)
|
||||||
|
{
|
||||||
RW(topic.topicId, send, true);
|
RW(topic.topicId, send, true);
|
||||||
|
|
||||||
if (!send)
|
|
||||||
player->topicChanges.topics.push_back(topic);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue