From 73b968318285f45d07ffb8c895943165610ded06 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sat, 27 May 2017 16:58:59 +0300 Subject: [PATCH] [General] Make most ActorPackets smaller by not including refIds in them --- apps/openmw/mwmp/ActorList.cpp | 28 ------------------- apps/openmw/mwmp/ActorList.hpp | 2 -- apps/openmw/mwmp/CellController.cpp | 24 ++++++++-------- apps/openmw/mwmp/CellController.hpp | 10 +++---- .../Packets/Actor/PacketActorAnimFlags.cpp | 1 - .../Packets/Actor/PacketActorAnimPlay.cpp | 1 - .../Packets/Actor/PacketActorAttack.cpp | 2 -- .../Packets/Actor/PacketActorCellChange.cpp | 1 - .../Packets/Actor/PacketActorEquipment.cpp | 1 - .../Packets/Actor/PacketActorPosition.cpp | 1 - .../Packets/Actor/PacketActorSpeech.cpp | 1 - .../Packets/Actor/PacketActorStatsDynamic.cpp | 1 - .../Packets/Actor/PacketActorTest.cpp | 1 - 13 files changed, 16 insertions(+), 58 deletions(-) diff --git a/apps/openmw/mwmp/ActorList.cpp b/apps/openmw/mwmp/ActorList.cpp index 46fb862a3..f83b79230 100644 --- a/apps/openmw/mwmp/ActorList.cpp +++ b/apps/openmw/mwmp/ActorList.cpp @@ -168,34 +168,6 @@ void ActorList::sendCellChangeActors() } } -// TODO: Finish this -void ActorList::editActorsInCell(MWWorld::CellStore* cellStore) -{ - BaseActor actor; - - for (unsigned int i = 0; i < count; i++) - { - actor = baseActors.at(i); - - LOG_APPEND(Log::LOG_VERBOSE, "- cellRef: %s, %i, %i", actor.refId.c_str(), actor.refNumIndex, actor.mpNum); - - return; - - MWWorld::Ptr ptrFound = cellStore->searchExact(actor.refId, actor.refNumIndex, actor.mpNum); - - if (ptrFound) - { - LOG_APPEND(Log::LOG_VERBOSE, "-- Found %s, %i, %i", ptrFound.getCellRef().getRefId().c_str(), - ptrFound.getCellRef().getRefNum(), ptrFound.getCellRef().getMpNum()); - } - else - { - LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "-- Could not find %s, %i, %i", ptrFound.getCellRef().getRefId().c_str(), - ptrFound.getCellRef().getRefNum(), ptrFound.getCellRef().getMpNum()); - } - } -} - void ActorList::sendActorsInCell(MWWorld::CellStore* cellStore) { reset(); diff --git a/apps/openmw/mwmp/ActorList.hpp b/apps/openmw/mwmp/ActorList.hpp index dec817dd2..4f8d4b831 100644 --- a/apps/openmw/mwmp/ActorList.hpp +++ b/apps/openmw/mwmp/ActorList.hpp @@ -39,8 +39,6 @@ namespace mwmp void sendAttackActors(); void sendCellChangeActors(); - void editActorsInCell(MWWorld::CellStore* cellStore); - void sendActorsInCell(MWWorld::CellStore* cellStore); private: diff --git a/apps/openmw/mwmp/CellController.cpp b/apps/openmw/mwmp/CellController.cpp index 8fb5d7942..b0c9e8d92 100644 --- a/apps/openmw/mwmp/CellController.cpp +++ b/apps/openmw/mwmp/CellController.cpp @@ -208,9 +208,9 @@ bool CellController::isLocalActor(MWWorld::Ptr ptr) return (localActorsToCells.count(mapIndex) > 0); } -bool CellController::isLocalActor(std::string refId, int refNumIndex, int mpNum) +bool CellController::isLocalActor(int refNumIndex, int mpNum) { - std::string mapIndex = generateMapIndex(refId, refNumIndex, mpNum); + std::string mapIndex = generateMapIndex(refNumIndex, mpNum); return (localActorsToCells.count(mapIndex) > 0); } @@ -222,9 +222,9 @@ LocalActor *CellController::getLocalActor(MWWorld::Ptr ptr) return cellsInitialized.at(cellIndex)->getLocalActor(actorIndex); } -LocalActor *CellController::getLocalActor(std::string refId, int refNumIndex, int mpNum) +LocalActor *CellController::getLocalActor(int refNumIndex, int mpNum) { - std::string actorIndex = generateMapIndex(refId, refNumIndex, mpNum); + std::string actorIndex = generateMapIndex(refNumIndex, mpNum); std::string cellIndex = localActorsToCells.at(actorIndex); return cellsInitialized.at(cellIndex)->getLocalActor(actorIndex); @@ -240,9 +240,9 @@ void CellController::removeDedicatedActorRecord(std::string actorIndex) dedicatedActorsToCells.erase(actorIndex); } -bool CellController::isDedicatedActor(std::string refId, int refNumIndex, int mpNum) +bool CellController::isDedicatedActor(int refNumIndex, int mpNum) { - std::string mapIndex = generateMapIndex(refId, refNumIndex, mpNum); + std::string mapIndex = generateMapIndex(refNumIndex, mpNum); return (dedicatedActorsToCells.count(mapIndex) > 0); } @@ -264,18 +264,17 @@ DedicatedActor *CellController::getDedicatedActor(MWWorld::Ptr ptr) return cellsInitialized.at(cellIndex)->getDedicatedActor(actorIndex); } -DedicatedActor *CellController::getDedicatedActor(std::string refId, int refNumIndex, int mpNum) +DedicatedActor *CellController::getDedicatedActor(int refNumIndex, int mpNum) { - std::string actorIndex = generateMapIndex(refId, refNumIndex, mpNum); + std::string actorIndex = generateMapIndex(refNumIndex, mpNum); std::string cellIndex = dedicatedActorsToCells.at(actorIndex); return cellsInitialized.at(cellIndex)->getDedicatedActor(actorIndex); } -std::string CellController::generateMapIndex(std::string refId, int refNumIndex, int mpNum) +std::string CellController::generateMapIndex(int refNumIndex, int mpNum) { std::string mapIndex = ""; - mapIndex += refId; mapIndex += "-" + Utils::toString(refNumIndex); mapIndex += "-" + Utils::toString(mpNum); return mapIndex; @@ -283,13 +282,12 @@ std::string CellController::generateMapIndex(std::string refId, int refNumIndex, std::string CellController::generateMapIndex(MWWorld::Ptr ptr) { - return generateMapIndex(ptr.getCellRef().getRefId(), - ptr.getCellRef().getRefNum().mIndex, ptr.getCellRef().getMpNum()); + return generateMapIndex(ptr.getCellRef().getRefNum().mIndex, ptr.getCellRef().getMpNum()); } std::string CellController::generateMapIndex(BaseActor baseActor) { - return generateMapIndex(baseActor.refId, baseActor.refNumIndex, baseActor.mpNum); + return generateMapIndex(baseActor.refNumIndex, baseActor.mpNum); } bool CellController::hasLocalAuthority(const ESM::Cell& cell) diff --git a/apps/openmw/mwmp/CellController.hpp b/apps/openmw/mwmp/CellController.hpp index a8ec70db6..902313703 100644 --- a/apps/openmw/mwmp/CellController.hpp +++ b/apps/openmw/mwmp/CellController.hpp @@ -33,19 +33,19 @@ namespace mwmp void removeLocalActorRecord(std::string actorIndex); bool isLocalActor(MWWorld::Ptr ptr); - bool isLocalActor(std::string refId, int refNumIndex, int mpNum); + bool isLocalActor(int refNumIndex, int mpNum); virtual LocalActor *getLocalActor(MWWorld::Ptr ptr); - virtual LocalActor *getLocalActor(std::string refId, int refNumIndex, int mpNum); + virtual LocalActor *getLocalActor(int refNumIndex, int mpNum); void setDedicatedActorRecord(std::string actorIndex, std::string cellIndex); void removeDedicatedActorRecord(std::string actorIndex); bool isDedicatedActor(MWWorld::Ptr ptr); - bool isDedicatedActor(std::string refId, int refNumIndex, int mpNum); + bool isDedicatedActor(int refNumIndex, int mpNum); virtual DedicatedActor *getDedicatedActor(MWWorld::Ptr ptr); - virtual DedicatedActor *getDedicatedActor(std::string refId, int refNumIndex, int mpNum); + virtual DedicatedActor *getDedicatedActor(int refNumIndex, int mpNum); - std::string generateMapIndex(std::string refId, int refNumindex, int mpNum); + std::string generateMapIndex(int refNumindex, int mpNum); std::string generateMapIndex(MWWorld::Ptr ptr); std::string generateMapIndex(mwmp::BaseActor baseActor); diff --git a/components/openmw-mp/Packets/Actor/PacketActorAnimFlags.cpp b/components/openmw-mp/Packets/Actor/PacketActorAnimFlags.cpp index ba21f8078..34c084d1d 100644 --- a/components/openmw-mp/Packets/Actor/PacketActorAnimFlags.cpp +++ b/components/openmw-mp/Packets/Actor/PacketActorAnimFlags.cpp @@ -34,7 +34,6 @@ void PacketActorAnimFlags::Packet(RakNet::BitStream *bs, bool send) actor = actorList->baseActors.at(i); } - RW(actor.refId, send); RW(actor.refNumIndex, send); RW(actor.mpNum, send); diff --git a/components/openmw-mp/Packets/Actor/PacketActorAnimPlay.cpp b/components/openmw-mp/Packets/Actor/PacketActorAnimPlay.cpp index 81e03404e..325a89295 100644 --- a/components/openmw-mp/Packets/Actor/PacketActorAnimPlay.cpp +++ b/components/openmw-mp/Packets/Actor/PacketActorAnimPlay.cpp @@ -34,7 +34,6 @@ void PacketActorAnimPlay::Packet(RakNet::BitStream *bs, bool send) actor = actorList->baseActors.at(i); } - RW(actor.refId, send); RW(actor.refNumIndex, send); RW(actor.mpNum, send); diff --git a/components/openmw-mp/Packets/Actor/PacketActorAttack.cpp b/components/openmw-mp/Packets/Actor/PacketActorAttack.cpp index 1c2a62fc5..af4364eb2 100644 --- a/components/openmw-mp/Packets/Actor/PacketActorAttack.cpp +++ b/components/openmw-mp/Packets/Actor/PacketActorAttack.cpp @@ -34,11 +34,9 @@ void PacketActorAttack::Packet(RakNet::BitStream *bs, bool send) actor = actorList->baseActors.at(i); } - RW(actor.refId, send); RW(actor.refNumIndex, send); RW(actor.mpNum, send); - RW(actor.attack.target.refId, send); RW(actor.attack.target.refNumIndex, send); RW(actor.attack.target.mpNum, send); RW(actor.attack.target.guid, send); diff --git a/components/openmw-mp/Packets/Actor/PacketActorCellChange.cpp b/components/openmw-mp/Packets/Actor/PacketActorCellChange.cpp index a862f040a..601de950d 100644 --- a/components/openmw-mp/Packets/Actor/PacketActorCellChange.cpp +++ b/components/openmw-mp/Packets/Actor/PacketActorCellChange.cpp @@ -34,7 +34,6 @@ void PacketActorCellChange::Packet(RakNet::BitStream *bs, bool send) actor = actorList->baseActors.at(i); } - RW(actor.refId, send); RW(actor.refNumIndex, send); RW(actor.mpNum, send); diff --git a/components/openmw-mp/Packets/Actor/PacketActorEquipment.cpp b/components/openmw-mp/Packets/Actor/PacketActorEquipment.cpp index b999f5eb4..56570c564 100644 --- a/components/openmw-mp/Packets/Actor/PacketActorEquipment.cpp +++ b/components/openmw-mp/Packets/Actor/PacketActorEquipment.cpp @@ -34,7 +34,6 @@ void PacketActorEquipment::Packet(RakNet::BitStream *bs, bool send) actor = actorList->baseActors.at(i); } - RW(actor.refId, send); RW(actor.refNumIndex, send); RW(actor.mpNum, send); diff --git a/components/openmw-mp/Packets/Actor/PacketActorPosition.cpp b/components/openmw-mp/Packets/Actor/PacketActorPosition.cpp index 990e7fe49..aa495822d 100644 --- a/components/openmw-mp/Packets/Actor/PacketActorPosition.cpp +++ b/components/openmw-mp/Packets/Actor/PacketActorPosition.cpp @@ -34,7 +34,6 @@ void PacketActorPosition::Packet(RakNet::BitStream *bs, bool send) actor = actorList->baseActors.at(i); } - RW(actor.refId, send); RW(actor.refNumIndex, send); RW(actor.mpNum, send); diff --git a/components/openmw-mp/Packets/Actor/PacketActorSpeech.cpp b/components/openmw-mp/Packets/Actor/PacketActorSpeech.cpp index 4cfa68ed0..a77f0abff 100644 --- a/components/openmw-mp/Packets/Actor/PacketActorSpeech.cpp +++ b/components/openmw-mp/Packets/Actor/PacketActorSpeech.cpp @@ -34,7 +34,6 @@ void PacketActorSpeech::Packet(RakNet::BitStream *bs, bool send) actor = actorList->baseActors.at(i); } - RW(actor.refId, send); RW(actor.refNumIndex, send); RW(actor.mpNum, send); diff --git a/components/openmw-mp/Packets/Actor/PacketActorStatsDynamic.cpp b/components/openmw-mp/Packets/Actor/PacketActorStatsDynamic.cpp index 8bcd97b4e..56dc7c833 100644 --- a/components/openmw-mp/Packets/Actor/PacketActorStatsDynamic.cpp +++ b/components/openmw-mp/Packets/Actor/PacketActorStatsDynamic.cpp @@ -35,7 +35,6 @@ void PacketActorStatsDynamic::Packet(RakNet::BitStream *bs, bool send) actor = actorList->baseActors.at(i); } - RW(actor.refId, send); RW(actor.refNumIndex, send); RW(actor.mpNum, send); diff --git a/components/openmw-mp/Packets/Actor/PacketActorTest.cpp b/components/openmw-mp/Packets/Actor/PacketActorTest.cpp index 8d07763b2..9fe8983e1 100644 --- a/components/openmw-mp/Packets/Actor/PacketActorTest.cpp +++ b/components/openmw-mp/Packets/Actor/PacketActorTest.cpp @@ -34,7 +34,6 @@ void PacketActorTest::Packet(RakNet::BitStream *bs, bool send) actor = actorList->baseActors.at(i); } - RW(actor.refId, send); RW(actor.refNumIndex, send); RW(actor.mpNum, send);