diff --git a/components/openmw-mp/Packets/Actor/ActorPacket.hpp b/components/openmw-mp/Packets/Actor/ActorPacket.hpp index 0caae13aa..ef8480ff8 100644 --- a/components/openmw-mp/Packets/Actor/ActorPacket.hpp +++ b/components/openmw-mp/Packets/Actor/ActorPacket.hpp @@ -24,7 +24,7 @@ namespace mwmp protected: BaseActorList *actorList; - + static const int maxActors = 3000; }; } diff --git a/components/openmw-mp/Packets/Actor/PacketActorAI.cpp b/components/openmw-mp/Packets/Actor/PacketActorAI.cpp index 0ea01b0f0..2bb2edfde 100644 --- a/components/openmw-mp/Packets/Actor/PacketActorAI.cpp +++ b/components/openmw-mp/Packets/Actor/PacketActorAI.cpp @@ -20,6 +20,12 @@ void PacketActorAI::Packet(RakNet::BitStream *bs, bool send) RW(actorList->count, send); + if (actorList->count > maxActors) + { + actorList->isValid = false; + return; + } + BaseActor actor; for (unsigned int i = 0; i < actorList->count; i++) diff --git a/components/openmw-mp/Packets/Actor/PacketActorAnimFlags.cpp b/components/openmw-mp/Packets/Actor/PacketActorAnimFlags.cpp index f16e19267..c2ab1f8e9 100644 --- a/components/openmw-mp/Packets/Actor/PacketActorAnimFlags.cpp +++ b/components/openmw-mp/Packets/Actor/PacketActorAnimFlags.cpp @@ -20,6 +20,12 @@ void PacketActorAnimFlags::Packet(RakNet::BitStream *bs, bool send) RW(actorList->count, send); + if (actorList->count > maxActors) + { + actorList->isValid = false; + return; + } + BaseActor actor; for (unsigned int i = 0; i < actorList->count; i++) diff --git a/components/openmw-mp/Packets/Actor/PacketActorAnimPlay.cpp b/components/openmw-mp/Packets/Actor/PacketActorAnimPlay.cpp index 37b681c3f..197ec687a 100644 --- a/components/openmw-mp/Packets/Actor/PacketActorAnimPlay.cpp +++ b/components/openmw-mp/Packets/Actor/PacketActorAnimPlay.cpp @@ -20,6 +20,12 @@ void PacketActorAnimPlay::Packet(RakNet::BitStream *bs, bool send) RW(actorList->count, send); + if (actorList->count > maxActors) + { + actorList->isValid = false; + return; + } + BaseActor actor; for (unsigned int i = 0; i < actorList->count; i++) diff --git a/components/openmw-mp/Packets/Actor/PacketActorAttack.cpp b/components/openmw-mp/Packets/Actor/PacketActorAttack.cpp index 8f9606302..e93bbe797 100644 --- a/components/openmw-mp/Packets/Actor/PacketActorAttack.cpp +++ b/components/openmw-mp/Packets/Actor/PacketActorAttack.cpp @@ -20,6 +20,12 @@ void PacketActorAttack::Packet(RakNet::BitStream *bs, bool send) RW(actorList->count, send); + if (actorList->count > maxActors) + { + actorList->isValid = false; + return; + } + BaseActor actor; for (unsigned int i = 0; i < actorList->count; i++) diff --git a/components/openmw-mp/Packets/Actor/PacketActorAuthority.cpp b/components/openmw-mp/Packets/Actor/PacketActorAuthority.cpp index 07ef7ed86..0678751e5 100644 --- a/components/openmw-mp/Packets/Actor/PacketActorAuthority.cpp +++ b/components/openmw-mp/Packets/Actor/PacketActorAuthority.cpp @@ -11,11 +11,4 @@ PacketActorAuthority::PacketActorAuthority(RakNet::RakPeerInterface *peer) : Act void PacketActorAuthority::Packet(RakNet::BitStream *bs, bool send) { ActorPacket::Packet(bs, send); - - if (send) - actorList->count = (unsigned int)(actorList->baseActors.size()); - else - actorList->baseActors.clear(); - - RW(actorList->count, send); } diff --git a/components/openmw-mp/Packets/Actor/PacketActorCellChange.cpp b/components/openmw-mp/Packets/Actor/PacketActorCellChange.cpp index 02d9bd234..5cfb7db90 100644 --- a/components/openmw-mp/Packets/Actor/PacketActorCellChange.cpp +++ b/components/openmw-mp/Packets/Actor/PacketActorCellChange.cpp @@ -20,6 +20,12 @@ void PacketActorCellChange::Packet(RakNet::BitStream *bs, bool send) RW(actorList->count, send); + if (actorList->count > maxActors) + { + actorList->isValid = false; + return; + } + BaseActor actor; for (unsigned int i = 0; i < actorList->count; i++) diff --git a/components/openmw-mp/Packets/Actor/PacketActorDeath.cpp b/components/openmw-mp/Packets/Actor/PacketActorDeath.cpp index 08439f40a..2cc10b672 100644 --- a/components/openmw-mp/Packets/Actor/PacketActorDeath.cpp +++ b/components/openmw-mp/Packets/Actor/PacketActorDeath.cpp @@ -20,6 +20,12 @@ void PacketActorDeath::Packet(RakNet::BitStream *bs, bool send) RW(actorList->count, send); + if (actorList->count > maxActors) + { + actorList->isValid = false; + return; + } + BaseActor actor; for (unsigned int i = 0; i < actorList->count; i++) diff --git a/components/openmw-mp/Packets/Actor/PacketActorEquipment.cpp b/components/openmw-mp/Packets/Actor/PacketActorEquipment.cpp index ae80f2e27..bfc5f61a6 100644 --- a/components/openmw-mp/Packets/Actor/PacketActorEquipment.cpp +++ b/components/openmw-mp/Packets/Actor/PacketActorEquipment.cpp @@ -20,6 +20,12 @@ void PacketActorEquipment::Packet(RakNet::BitStream *bs, bool send) RW(actorList->count, send); + if (actorList->count > maxActors) + { + actorList->isValid = false; + return; + } + BaseActor actor; for (unsigned int i = 0; i < actorList->count; i++) diff --git a/components/openmw-mp/Packets/Actor/PacketActorList.cpp b/components/openmw-mp/Packets/Actor/PacketActorList.cpp index 55b70508d..ff2c1199e 100644 --- a/components/openmw-mp/Packets/Actor/PacketActorList.cpp +++ b/components/openmw-mp/Packets/Actor/PacketActorList.cpp @@ -21,7 +21,7 @@ void PacketActorList::Packet(RakNet::BitStream *bs, bool send) RW(actorList->count, send); - if (actorList->count > 2000) + if (actorList->count > maxActors) { actorList->isValid = false; return; diff --git a/components/openmw-mp/Packets/Actor/PacketActorPosition.cpp b/components/openmw-mp/Packets/Actor/PacketActorPosition.cpp index e6f6cfa20..ac2015326 100644 --- a/components/openmw-mp/Packets/Actor/PacketActorPosition.cpp +++ b/components/openmw-mp/Packets/Actor/PacketActorPosition.cpp @@ -20,6 +20,12 @@ void PacketActorPosition::Packet(RakNet::BitStream *bs, bool send) RW(actorList->count, send); + if (actorList->count > maxActors) + { + actorList->isValid = false; + return; + } + BaseActor actor; for (unsigned int i = 0; i < actorList->count; i++) diff --git a/components/openmw-mp/Packets/Actor/PacketActorSpeech.cpp b/components/openmw-mp/Packets/Actor/PacketActorSpeech.cpp index 7c7c3802e..2e1b0c932 100644 --- a/components/openmw-mp/Packets/Actor/PacketActorSpeech.cpp +++ b/components/openmw-mp/Packets/Actor/PacketActorSpeech.cpp @@ -20,6 +20,12 @@ void PacketActorSpeech::Packet(RakNet::BitStream *bs, bool send) RW(actorList->count, send); + if (actorList->count > maxActors) + { + actorList->isValid = false; + return; + } + BaseActor actor; for (unsigned int i = 0; i < actorList->count; i++) diff --git a/components/openmw-mp/Packets/Actor/PacketActorStatsDynamic.cpp b/components/openmw-mp/Packets/Actor/PacketActorStatsDynamic.cpp index ef53923a0..2a02a4bf9 100644 --- a/components/openmw-mp/Packets/Actor/PacketActorStatsDynamic.cpp +++ b/components/openmw-mp/Packets/Actor/PacketActorStatsDynamic.cpp @@ -21,6 +21,12 @@ void PacketActorStatsDynamic::Packet(RakNet::BitStream *bs, bool send) RW(actorList->count, send); + if (actorList->count > maxActors) + { + actorList->isValid = false; + return; + } + BaseActor actor; for (unsigned int i = 0; i < actorList->count; i++) diff --git a/components/openmw-mp/Packets/Actor/PacketActorTest.cpp b/components/openmw-mp/Packets/Actor/PacketActorTest.cpp index 6920cb777..9765df15a 100644 --- a/components/openmw-mp/Packets/Actor/PacketActorTest.cpp +++ b/components/openmw-mp/Packets/Actor/PacketActorTest.cpp @@ -20,6 +20,12 @@ void PacketActorTest::Packet(RakNet::BitStream *bs, bool send) RW(actorList->count, send); + if (actorList->count > maxActors) + { + actorList->isValid = false; + return; + } + BaseActor actor; for (unsigned int i = 0; i < actorList->count; i++) diff --git a/components/openmw-mp/Packets/World/PacketContainer.cpp b/components/openmw-mp/Packets/World/PacketContainer.cpp index f6e495c9c..927c622d0 100644 --- a/components/openmw-mp/Packets/World/PacketContainer.cpp +++ b/components/openmw-mp/Packets/World/PacketContainer.cpp @@ -22,6 +22,12 @@ void PacketContainer::Packet(RakNet::BitStream *bs, bool send) RW(event->worldObjectCount, send); + if (event->worldObjectCount > maxObjects) + { + event->isValid = false; + return; + } + RW(event->cell.mData.mFlags, send); RW(event->cell.mData.mX, send); RW(event->cell.mData.mY, send); @@ -46,7 +52,7 @@ void PacketContainer::Packet(RakNet::BitStream *bs, bool send) RW(worldObject.mpNum, send); RW(worldObject.containerItemCount, send); - if (worldObject.containerItemCount > 2000 || worldObject.refId.empty() || (worldObject.refNumIndex != 0 && worldObject.mpNum != 0)) + if (worldObject.containerItemCount > maxObjects || worldObject.refId.empty() || (worldObject.refNumIndex != 0 && worldObject.mpNum != 0)) { event->isValid = false; return; diff --git a/components/openmw-mp/Packets/World/PacketDoorState.cpp b/components/openmw-mp/Packets/World/PacketDoorState.cpp index c96bcc8c5..ee40e6320 100644 --- a/components/openmw-mp/Packets/World/PacketDoorState.cpp +++ b/components/openmw-mp/Packets/World/PacketDoorState.cpp @@ -19,6 +19,12 @@ void PacketDoorState::Packet(RakNet::BitStream *bs, bool send) RW(event->worldObjectCount, send); + if (event->worldObjectCount > maxObjects) + { + event->isValid = false; + return; + } + RW(event->cell.mData.mFlags, send); RW(event->cell.mData.mX, send); RW(event->cell.mData.mY, send); diff --git a/components/openmw-mp/Packets/World/PacketMusicPlay.cpp b/components/openmw-mp/Packets/World/PacketMusicPlay.cpp index ba09db4dc..b378ff678 100644 --- a/components/openmw-mp/Packets/World/PacketMusicPlay.cpp +++ b/components/openmw-mp/Packets/World/PacketMusicPlay.cpp @@ -19,6 +19,12 @@ void PacketMusicPlay::Packet(RakNet::BitStream *bs, bool send) RW(event->worldObjectCount, send); + if (event->worldObjectCount > maxObjects) + { + event->isValid = false; + return; + } + WorldObject worldObject; for (unsigned int i = 0; i < event->worldObjectCount; i++) diff --git a/components/openmw-mp/Packets/World/PacketObjectAnimPlay.cpp b/components/openmw-mp/Packets/World/PacketObjectAnimPlay.cpp index e91121498..23d4d96dd 100644 --- a/components/openmw-mp/Packets/World/PacketObjectAnimPlay.cpp +++ b/components/openmw-mp/Packets/World/PacketObjectAnimPlay.cpp @@ -19,6 +19,12 @@ void PacketObjectAnimPlay::Packet(RakNet::BitStream *bs, bool send) RW(event->worldObjectCount, send); + if (event->worldObjectCount > maxObjects) + { + event->isValid = false; + return; + } + RW(event->cell.mData.mFlags, send); RW(event->cell.mData.mX, send); RW(event->cell.mData.mY, send); diff --git a/components/openmw-mp/Packets/World/PacketObjectDelete.cpp b/components/openmw-mp/Packets/World/PacketObjectDelete.cpp index 79c393c5e..04f4d7748 100644 --- a/components/openmw-mp/Packets/World/PacketObjectDelete.cpp +++ b/components/openmw-mp/Packets/World/PacketObjectDelete.cpp @@ -19,6 +19,12 @@ void PacketObjectDelete::Packet(RakNet::BitStream *bs, bool send) RW(event->worldObjectCount, send); + if (event->worldObjectCount > maxObjects) + { + event->isValid = false; + return; + } + RW(event->cell.mData.mFlags, send); RW(event->cell.mData.mX, send); RW(event->cell.mData.mY, send); diff --git a/components/openmw-mp/Packets/World/PacketObjectLock.cpp b/components/openmw-mp/Packets/World/PacketObjectLock.cpp index 200ab372f..147072439 100644 --- a/components/openmw-mp/Packets/World/PacketObjectLock.cpp +++ b/components/openmw-mp/Packets/World/PacketObjectLock.cpp @@ -19,6 +19,12 @@ void PacketObjectLock::Packet(RakNet::BitStream *bs, bool send) RW(event->worldObjectCount, send); + if (event->worldObjectCount > maxObjects) + { + event->isValid = false; + return; + } + RW(event->cell.mData.mFlags, send); RW(event->cell.mData.mX, send); RW(event->cell.mData.mY, send); diff --git a/components/openmw-mp/Packets/World/PacketObjectMove.cpp b/components/openmw-mp/Packets/World/PacketObjectMove.cpp index cd97d942d..172cf4ff6 100644 --- a/components/openmw-mp/Packets/World/PacketObjectMove.cpp +++ b/components/openmw-mp/Packets/World/PacketObjectMove.cpp @@ -19,6 +19,12 @@ void PacketObjectMove::Packet(RakNet::BitStream *bs, bool send) RW(event->worldObjectCount, send); + if (event->worldObjectCount > maxObjects) + { + event->isValid = false; + return; + } + RW(event->cell.mData.mFlags, send); RW(event->cell.mData.mX, send); RW(event->cell.mData.mY, send); diff --git a/components/openmw-mp/Packets/World/PacketObjectPlace.cpp b/components/openmw-mp/Packets/World/PacketObjectPlace.cpp index 4c2ac62e1..2b1f34c45 100644 --- a/components/openmw-mp/Packets/World/PacketObjectPlace.cpp +++ b/components/openmw-mp/Packets/World/PacketObjectPlace.cpp @@ -19,6 +19,12 @@ void PacketObjectPlace::Packet(RakNet::BitStream *bs, bool send) RW(event->worldObjectCount, send); + if (event->worldObjectCount > maxObjects) + { + event->isValid = false; + return; + } + RW(event->cell.mData.mFlags, send); RW(event->cell.mData.mX, send); RW(event->cell.mData.mY, send); diff --git a/components/openmw-mp/Packets/World/PacketObjectRotate.cpp b/components/openmw-mp/Packets/World/PacketObjectRotate.cpp index 8a9361d46..5ff5bc89c 100644 --- a/components/openmw-mp/Packets/World/PacketObjectRotate.cpp +++ b/components/openmw-mp/Packets/World/PacketObjectRotate.cpp @@ -19,6 +19,12 @@ void PacketObjectRotate::Packet(RakNet::BitStream *bs, bool send) RW(event->worldObjectCount, send); + if (event->worldObjectCount > maxObjects) + { + event->isValid = false; + return; + } + RW(event->cell.mData.mFlags, send); RW(event->cell.mData.mX, send); RW(event->cell.mData.mY, send); diff --git a/components/openmw-mp/Packets/World/PacketObjectScale.cpp b/components/openmw-mp/Packets/World/PacketObjectScale.cpp index 375f8181e..8273b4a05 100644 --- a/components/openmw-mp/Packets/World/PacketObjectScale.cpp +++ b/components/openmw-mp/Packets/World/PacketObjectScale.cpp @@ -19,6 +19,12 @@ void PacketObjectScale::Packet(RakNet::BitStream *bs, bool send) RW(event->worldObjectCount, send); + if (event->worldObjectCount > maxObjects) + { + event->isValid = false; + return; + } + RW(event->cell.mData.mFlags, send); RW(event->cell.mData.mX, send); RW(event->cell.mData.mY, send); diff --git a/components/openmw-mp/Packets/World/PacketObjectSpawn.cpp b/components/openmw-mp/Packets/World/PacketObjectSpawn.cpp index 848f95703..22a6ec8f5 100644 --- a/components/openmw-mp/Packets/World/PacketObjectSpawn.cpp +++ b/components/openmw-mp/Packets/World/PacketObjectSpawn.cpp @@ -19,6 +19,12 @@ void PacketObjectSpawn::Packet(RakNet::BitStream *bs, bool send) RW(event->worldObjectCount, send); + if (event->worldObjectCount > maxObjects) + { + event->isValid = false; + return; + } + RW(event->cell.mData.mFlags, send); RW(event->cell.mData.mX, send); RW(event->cell.mData.mY, send); diff --git a/components/openmw-mp/Packets/World/PacketObjectTrap.cpp b/components/openmw-mp/Packets/World/PacketObjectTrap.cpp index 762d4e646..bdf167a49 100644 --- a/components/openmw-mp/Packets/World/PacketObjectTrap.cpp +++ b/components/openmw-mp/Packets/World/PacketObjectTrap.cpp @@ -19,6 +19,12 @@ void PacketObjectTrap::Packet(RakNet::BitStream *bs, bool send) RW(event->worldObjectCount, send); + if (event->worldObjectCount > maxObjects) + { + event->isValid = false; + return; + } + RW(event->cell.mData.mFlags, send); RW(event->cell.mData.mX, send); RW(event->cell.mData.mY, send); diff --git a/components/openmw-mp/Packets/World/PacketScriptGlobalShort.cpp b/components/openmw-mp/Packets/World/PacketScriptGlobalShort.cpp index 07504f2b2..f6e1147ea 100644 --- a/components/openmw-mp/Packets/World/PacketScriptGlobalShort.cpp +++ b/components/openmw-mp/Packets/World/PacketScriptGlobalShort.cpp @@ -19,6 +19,12 @@ void PacketScriptGlobalShort::Packet(RakNet::BitStream *bs, bool send) RW(event->worldObjectCount, send); + if (event->worldObjectCount > maxObjects) + { + event->isValid = false; + return; + } + WorldObject worldObject; for (unsigned int i = 0; i < event->worldObjectCount; i++) diff --git a/components/openmw-mp/Packets/World/PacketScriptLocalFloat.cpp b/components/openmw-mp/Packets/World/PacketScriptLocalFloat.cpp index abfc04ef7..79f0ad565 100644 --- a/components/openmw-mp/Packets/World/PacketScriptLocalFloat.cpp +++ b/components/openmw-mp/Packets/World/PacketScriptLocalFloat.cpp @@ -19,6 +19,12 @@ void PacketScriptLocalFloat::Packet(RakNet::BitStream *bs, bool send) RW(event->worldObjectCount, send); + if (event->worldObjectCount > maxObjects) + { + event->isValid = false; + return; + } + RW(event->cell.mData.mFlags, send); RW(event->cell.mData.mX, send); RW(event->cell.mData.mY, send); diff --git a/components/openmw-mp/Packets/World/PacketScriptLocalShort.cpp b/components/openmw-mp/Packets/World/PacketScriptLocalShort.cpp index 9b0e9d54b..41f9d1afb 100644 --- a/components/openmw-mp/Packets/World/PacketScriptLocalShort.cpp +++ b/components/openmw-mp/Packets/World/PacketScriptLocalShort.cpp @@ -19,6 +19,12 @@ void PacketScriptLocalShort::Packet(RakNet::BitStream *bs, bool send) RW(event->worldObjectCount, send); + if (event->worldObjectCount > maxObjects) + { + event->isValid = false; + return; + } + RW(event->cell.mData.mFlags, send); RW(event->cell.mData.mX, send); RW(event->cell.mData.mY, send); diff --git a/components/openmw-mp/Packets/World/PacketScriptMemberShort.cpp b/components/openmw-mp/Packets/World/PacketScriptMemberShort.cpp index 6cb5d28fa..5151059c2 100644 --- a/components/openmw-mp/Packets/World/PacketScriptMemberShort.cpp +++ b/components/openmw-mp/Packets/World/PacketScriptMemberShort.cpp @@ -19,6 +19,12 @@ void PacketScriptMemberShort::Packet(RakNet::BitStream *bs, bool send) RW(event->worldObjectCount, send); + if (event->worldObjectCount > maxObjects) + { + event->isValid = false; + return; + } + WorldObject worldObject; for (unsigned int i = 0; i < event->worldObjectCount; i++) diff --git a/components/openmw-mp/Packets/World/PacketVideoPlay.cpp b/components/openmw-mp/Packets/World/PacketVideoPlay.cpp index 0ce7aa4ad..49c6ba506 100644 --- a/components/openmw-mp/Packets/World/PacketVideoPlay.cpp +++ b/components/openmw-mp/Packets/World/PacketVideoPlay.cpp @@ -19,6 +19,12 @@ void PacketVideoPlay::Packet(RakNet::BitStream *bs, bool send) RW(event->worldObjectCount, send); + if (event->worldObjectCount > maxObjects) + { + event->isValid = false; + return; + } + WorldObject worldObject; for (unsigned int i = 0; i < event->worldObjectCount; i++) diff --git a/components/openmw-mp/Packets/World/WorldPacket.hpp b/components/openmw-mp/Packets/World/WorldPacket.hpp index 6e9be13b8..340cca7a0 100644 --- a/components/openmw-mp/Packets/World/WorldPacket.hpp +++ b/components/openmw-mp/Packets/World/WorldPacket.hpp @@ -23,7 +23,7 @@ namespace mwmp protected: BaseEvent *event; - + static const int maxObjects = 3000; }; }