mirror of
				https://github.com/TES3MP/openmw-tes3mp.git
				synced 2025-10-31 18:56:43 +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; | ||||
|     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 | ||||
|  |  | |||
|  | @ -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(); | ||||
|  |  | |||
|  | @ -103,12 +103,6 @@ namespace mwmp | |||
|         int action; // 0 - Rank, 1 - Expulsion state, 2 - Both
 | ||||
|     }; | ||||
| 
 | ||||
|     struct TopicChanges | ||||
|     { | ||||
|         std::vector<Topic> topics; | ||||
|         unsigned int count; | ||||
|     }; | ||||
| 
 | ||||
|     struct BookChanges | ||||
|     { | ||||
|         std::vector<Book> books; | ||||
|  | @ -235,7 +229,7 @@ namespace mwmp | |||
|         std::vector<QuickKey> quickKeyChanges; | ||||
|         std::vector<JournalItem> journalChanges; | ||||
|         FactionChanges factionChanges; | ||||
|         TopicChanges topicChanges; | ||||
|         std::vector<Topic> topicChanges; | ||||
|         BookChanges bookChanges; | ||||
|         CellStateChanges cellStateChanges; | ||||
| 
 | ||||
|  |  | |||
|  | @ -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<uint32_t>(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); | ||||
|     } | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue