mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 20:49:56 +00:00
[General] Implement sending and reading of PlayerTopic packets
This commit is contained in:
parent
08de349133
commit
11369f6513
8 changed files with 85 additions and 5 deletions
|
@ -28,6 +28,7 @@
|
|||
*/
|
||||
#include "../mwmp/Main.hpp"
|
||||
#include "../mwmp/CellController.hpp"
|
||||
#include "../mwmp/LocalPlayer.hpp"
|
||||
#include "../mwmp/LocalActor.hpp"
|
||||
/*
|
||||
End of tes3mp addition
|
||||
|
@ -117,6 +118,17 @@ namespace MWDialogue
|
|||
if (tok->isImplicitKeyword() && mTranslationDataStorage.hasTranslation())
|
||||
continue;
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_PLAYER_TOPIC packet every time a new topic becomes known
|
||||
*/
|
||||
if (mActorKnownTopics.count(topicId) && !mKnownTopics.count(topicId))
|
||||
mwmp::Main::get().getLocalPlayer()->sendTopic(topicId);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
if (mActorKnownTopics.count( topicId ))
|
||||
mKnownTopics.insert( topicId );
|
||||
}
|
||||
|
|
|
@ -687,6 +687,16 @@ void LocalPlayer::addJournalItems()
|
|||
}
|
||||
}
|
||||
|
||||
void LocalPlayer::addTopics()
|
||||
{
|
||||
for (unsigned int i = 0; i < topicChanges.count; i++)
|
||||
{
|
||||
mwmp::Topic topic = topicChanges.topics.at(i);
|
||||
|
||||
MWBase::Environment::get().getDialogueManager()->addTopic(topic.topicId);
|
||||
}
|
||||
}
|
||||
|
||||
void LocalPlayer::removeItems()
|
||||
{
|
||||
MWWorld::Ptr ptrPlayer = getPlayerPtr();
|
||||
|
@ -1166,6 +1176,19 @@ void LocalPlayer::sendFaction(const std::string& factionId, int rank, bool isExp
|
|||
getNetworking()->getPlayerPacket(ID_PLAYER_FACTION)->Send();
|
||||
}
|
||||
|
||||
void LocalPlayer::sendTopic(const std::string& topicId)
|
||||
{
|
||||
topicChanges.topics.clear();
|
||||
|
||||
mwmp::Topic topic;
|
||||
topic.topicId = topicId;
|
||||
|
||||
topicChanges.topics.push_back(topic);
|
||||
|
||||
getNetworking()->getPlayerPacket(ID_PLAYER_TOPIC)->setPlayer(this);
|
||||
getNetworking()->getPlayerPacket(ID_PLAYER_TOPIC)->Send();
|
||||
}
|
||||
|
||||
void LocalPlayer::clearCellStates()
|
||||
{
|
||||
cellStateChanges.cellStates.clear();
|
||||
|
|
|
@ -42,6 +42,7 @@ namespace mwmp
|
|||
void addItems();
|
||||
void addSpells();
|
||||
void addJournalItems();
|
||||
void addTopics();
|
||||
|
||||
void removeItems();
|
||||
void removeSpells();
|
||||
|
@ -70,6 +71,7 @@ namespace mwmp
|
|||
void sendJournalEntry(const std::string& quest, int index, const MWWorld::Ptr& actor);
|
||||
void sendJournalIndex(const std::string& quest, int index);
|
||||
void sendFaction(const std::string& factionId, int rank, bool isExpelled);
|
||||
void sendTopic(const std::string& topic);
|
||||
|
||||
void clearCellStates();
|
||||
void clearCurrentContainer();
|
||||
|
|
|
@ -20,8 +20,8 @@ namespace mwmp
|
|||
{
|
||||
// Entire list of topics cannot currently be requested from players
|
||||
}
|
||||
//else
|
||||
//static_cast<LocalPlayer*>(player)->addTopics();
|
||||
else
|
||||
static_cast<LocalPlayer*>(player)->addTopics();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -127,6 +127,17 @@ namespace MWScript
|
|||
runtime.pop();
|
||||
|
||||
MWBase::Environment::get().getDialogueManager()->addTopic(topic);
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_PLAYER_TOPIC packet every time a topic is added
|
||||
through a script
|
||||
*/
|
||||
mwmp::Main::get().getLocalPlayer()->sendTopic(topic);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -63,6 +63,11 @@ namespace mwmp
|
|||
bool isExpelled;
|
||||
};
|
||||
|
||||
struct Topic
|
||||
{
|
||||
std::string topicId;
|
||||
};
|
||||
|
||||
struct CellState
|
||||
{
|
||||
ESM::Cell cell;
|
||||
|
@ -88,6 +93,12 @@ namespace mwmp
|
|||
unsigned int count;
|
||||
};
|
||||
|
||||
struct TopicChanges
|
||||
{
|
||||
std::vector<Topic> topics;
|
||||
unsigned int count;
|
||||
};
|
||||
|
||||
struct InventoryChanges
|
||||
{
|
||||
std::vector<Item> items;
|
||||
|
@ -171,6 +182,7 @@ namespace mwmp
|
|||
SpellbookChanges spellbookChanges;
|
||||
JournalChanges journalChanges;
|
||||
FactionChanges factionChanges;
|
||||
TopicChanges topicChanges;
|
||||
CellStateChanges cellStateChanges;
|
||||
ESM::ActiveSpells activeSpells;
|
||||
CurrentContainer currentContainer;
|
||||
|
|
|
@ -13,10 +13,10 @@ void PacketPlayerFaction::Packet(RakNet::BitStream *bs, bool send)
|
|||
{
|
||||
PlayerPacket::Packet(bs, send);
|
||||
|
||||
if (!send)
|
||||
player->factionChanges.factions.clear();
|
||||
else
|
||||
if (send)
|
||||
player->factionChanges.count = (unsigned int)(player->factionChanges.factions.size());
|
||||
else
|
||||
player->factionChanges.factions.clear();
|
||||
|
||||
RW(player->factionChanges.count, send);
|
||||
|
||||
|
|
|
@ -12,4 +12,24 @@ PacketPlayerTopic::PacketPlayerTopic(RakNet::RakPeerInterface *peer) : PlayerPac
|
|||
void PacketPlayerTopic::Packet(RakNet::BitStream *bs, bool send)
|
||||
{
|
||||
PlayerPacket::Packet(bs, send);
|
||||
|
||||
if (send)
|
||||
player->topicChanges.count = (unsigned int)(player->topicChanges.topics.size());
|
||||
else
|
||||
player->topicChanges.topics.clear();
|
||||
|
||||
RW(player->topicChanges.count, send);
|
||||
|
||||
for (unsigned int i = 0; i < player->topicChanges.count; i++)
|
||||
{
|
||||
Topic topic;
|
||||
|
||||
if (send)
|
||||
topic = player->topicChanges.topics.at(i);
|
||||
|
||||
RW(topic.topicId, send);
|
||||
|
||||
if (!send)
|
||||
player->topicChanges.topics.push_back(topic);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue