mirror of
				https://github.com/TES3MP/openmw-tes3mp.git
				synced 2025-10-31 19:56:42 +00:00 
			
		
		
		
	[General] Reduce packets size and add integrity checks
This commit is contained in:
		
							parent
							
								
									fa2bf0663e
								
							
						
					
					
						commit
						f9ff5f10df
					
				
					 4 changed files with 19 additions and 4 deletions
				
			
		|  | @ -233,15 +233,15 @@ namespace mwmp | |||
| 
 | ||||
|         // Track only the indexes of the attributes that have been changed,
 | ||||
|         // with the attribute values themselves being stored in creatureStats.mAttributes
 | ||||
|         std::vector<int> attributeIndexChanges; | ||||
|         std::vector<uint8_t> attributeIndexChanges; | ||||
| 
 | ||||
|         // Track only the indexes of the skills that have been changed,
 | ||||
|         // with the skill values themselves being stored in npcStats.mSkills
 | ||||
|         std::vector<int> skillIndexChanges; | ||||
|         std::vector<uint8_t> skillIndexChanges; | ||||
| 
 | ||||
|         // Track only the indexes of the dynamic states that have been changed,
 | ||||
|         // with the dynamicStats themselves being stored in creatureStats.mDynamic
 | ||||
|         std::vector<int> statsDynamicIndexChanges; | ||||
|         std::vector<uint8_t> statsDynamicIndexChanges; | ||||
| 
 | ||||
|         // Track only the indexes of the equipment items that have been changed,
 | ||||
|         // with the items themselves being stored in equipmentItems
 | ||||
|  |  | |||
|  | @ -39,6 +39,12 @@ void PacketPlayerAttribute::Packet(RakNet::BitStream *bs, bool send) | |||
|         { | ||||
|             RW(attributeIndex, send); | ||||
| 
 | ||||
|             if (attributeIndex >= 8) | ||||
|             { | ||||
|                 packetValid = false; | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             RW(player->creatureStats.mAttributes[attributeIndex], send); | ||||
|             RW(player->npcStats.mSkillIncrease[attributeIndex], send); | ||||
|         } | ||||
|  |  | |||
|  | @ -38,6 +38,11 @@ void PacketPlayerSkill::Packet(RakNet::BitStream *bs, bool send) | |||
|         for (auto &&skillId : player->skillIndexChanges) | ||||
|         { | ||||
|             RW(skillId, send); | ||||
|             if (skillId >= 27) | ||||
|             { | ||||
|                 packetValid = false; | ||||
|                 return; | ||||
|             } | ||||
|             RW(player->npcStats.mSkills[skillId], send); | ||||
|         } | ||||
|     } | ||||
|  |  | |||
|  | @ -37,7 +37,11 @@ void PacketPlayerStatsDynamic::Packet(RakNet::BitStream *bs, bool send) | |||
|         for (auto &&statsDynamicIndex : player->statsDynamicIndexChanges) | ||||
|         { | ||||
|             RW(statsDynamicIndex, send); | ||||
| 
 | ||||
|             if (statsDynamicIndex >= 3) | ||||
|             { | ||||
|                 packetValid = false; | ||||
|                 return; | ||||
|             } | ||||
|             RW(player->creatureStats.mDynamic[statsDynamicIndex], send); | ||||
|         } | ||||
|     } | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue