From a1a93ae3d81a065a85871184097fcd2f23e9a16a Mon Sep 17 00:00:00 2001 From: pavanvo Date: Tue, 6 Sep 2022 17:43:54 +0400 Subject: [PATCH] fix: add param nextUnitTypeId to NetworkCommand class to prevent collision morph with build --- source/glest_game/network/network_types.cpp | 15 +++------------ source/glest_game/network/network_types.h | 4 ++++ 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/source/glest_game/network/network_types.cpp b/source/glest_game/network/network_types.cpp index 3ba5f508..b88c6c87 100644 --- a/source/glest_game/network/network_types.cpp +++ b/source/glest_game/network/network_types.cpp @@ -28,12 +28,13 @@ namespace Glest{ namespace Game{ NetworkCommand::NetworkCommand(World *world, int networkCommandType, int unitId, int commandTypeId, const Vec2i &pos, int unitTypeId, - int targetId, int facing, bool wantQueue, + int nextUnitTypeId, int targetId, int facing, bool wantQueue, CommandStateType commandStateType, int commandStateValue, int unitCommandGroupId) : networkCommandType(networkCommandType) , unitId(unitId) , unitTypeId(unitTypeId) + , nextUnitTypeId(nextUnitTypeId) , commandTypeId(commandTypeId) , positionX(pos.x) , positionY(pos.y) @@ -57,11 +58,6 @@ NetworkCommand::NetworkCommand(World *world, int networkCommandType, int unitId, this->unitFactionUnitCount = unit->getFaction()->getUnitCount(); const CommandType *ct= unit->getType()->findCommandTypeById(this->commandTypeId); - if(unitTypeId > -1) { - const UnitType *unitType= world->findUnitTypeById(unit->getFaction()->getType(), this->unitTypeId); - auto mct= unitType->findCommandTypeById(this->commandTypeId); - if(mct) ct= mct; - } if(ct != NULL && ct->getClass() == ccBuild) { if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] %s\n",__FILE__,__FUNCTION__,__LINE__,toString().c_str()); @@ -82,12 +78,7 @@ void NetworkCommand::preprocessNetworkCommand(World *world) { if(unit != NULL) { const CommandType *ct= unit->getType()->findCommandTypeById(commandTypeId); - if(unitTypeId > -1) { - const UnitType *unitType= world->findUnitTypeById(unit->getFaction()->getType(), unitTypeId); - auto mct= unitType->findCommandTypeById(this->commandTypeId); - if(mct) ct= mct; - } - + if(ct != NULL && ct->getClass() == ccBuild && targetId >= 0) { CardinalDir::assertDirValid(targetId); } diff --git a/source/glest_game/network/network_types.h b/source/glest_game/network/network_types.h index 22493582..16435ca4 100644 --- a/source/glest_game/network/network_types.h +++ b/source/glest_game/network/network_types.h @@ -94,6 +94,7 @@ public: networkCommandType=0; unitId=0; unitTypeId=0; + nextUnitTypeId=0; commandTypeId=0; positionX=0; positionY=0; @@ -114,6 +115,7 @@ public: int commandTypeId= -1, const Vec2i &pos= Vec2i(0), int unitTypeId= -1, + int nextUnitTypeId= -1, int targetId= -1, int facing= -1, bool wantQueue = false, @@ -124,6 +126,7 @@ public: int16 networkCommandType; int32 unitId; int16 unitTypeId; + int16 nextUnitTypeId; int16 commandTypeId; int16 positionX; int16 positionY; @@ -141,6 +144,7 @@ public: int getCommandTypeId() const {return commandTypeId;} Vec2i getPosition() const {return Vec2i(positionX, positionY);} int getUnitTypeId() const {return unitTypeId;} + int getNextUnitTypeId() const {return nextUnitTypeId;} int getTargetId() const {return targetId;} int getWantQueue() const {return wantQueue;} int getFromFactionIndex() const {return fromFactionIndex;}