fix: add param nextUnitTypeId

to NetworkCommand class to prevent collision morph with build
This commit is contained in:
pavanvo 2022-09-06 17:43:54 +04:00
parent 8d141ca57f
commit a1a93ae3d8
No known key found for this signature in database
GPG Key ID: 34C1C36681B4AD84
2 changed files with 7 additions and 12 deletions

View File

@ -28,12 +28,13 @@ namespace Glest{ namespace Game{
NetworkCommand::NetworkCommand(World *world, int networkCommandType, int unitId, NetworkCommand::NetworkCommand(World *world, int networkCommandType, int unitId,
int commandTypeId, const Vec2i &pos, int unitTypeId, int commandTypeId, const Vec2i &pos, int unitTypeId,
int targetId, int facing, bool wantQueue, int nextUnitTypeId, int targetId, int facing, bool wantQueue,
CommandStateType commandStateType, CommandStateType commandStateType,
int commandStateValue, int unitCommandGroupId) int commandStateValue, int unitCommandGroupId)
: networkCommandType(networkCommandType) : networkCommandType(networkCommandType)
, unitId(unitId) , unitId(unitId)
, unitTypeId(unitTypeId) , unitTypeId(unitTypeId)
, nextUnitTypeId(nextUnitTypeId)
, commandTypeId(commandTypeId) , commandTypeId(commandTypeId)
, positionX(pos.x) , positionX(pos.x)
, positionY(pos.y) , positionY(pos.y)
@ -57,11 +58,6 @@ NetworkCommand::NetworkCommand(World *world, int networkCommandType, int unitId,
this->unitFactionUnitCount = unit->getFaction()->getUnitCount(); this->unitFactionUnitCount = unit->getFaction()->getUnitCount();
const CommandType *ct= unit->getType()->findCommandTypeById(this->commandTypeId); 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(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()); 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) { if(unit != NULL) {
const CommandType *ct= unit->getType()->findCommandTypeById(commandTypeId); 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) { if(ct != NULL && ct->getClass() == ccBuild && targetId >= 0) {
CardinalDir::assertDirValid(targetId); CardinalDir::assertDirValid(targetId);
} }

View File

@ -94,6 +94,7 @@ public:
networkCommandType=0; networkCommandType=0;
unitId=0; unitId=0;
unitTypeId=0; unitTypeId=0;
nextUnitTypeId=0;
commandTypeId=0; commandTypeId=0;
positionX=0; positionX=0;
positionY=0; positionY=0;
@ -114,6 +115,7 @@ public:
int commandTypeId= -1, int commandTypeId= -1,
const Vec2i &pos= Vec2i(0), const Vec2i &pos= Vec2i(0),
int unitTypeId= -1, int unitTypeId= -1,
int nextUnitTypeId= -1,
int targetId= -1, int targetId= -1,
int facing= -1, int facing= -1,
bool wantQueue = false, bool wantQueue = false,
@ -124,6 +126,7 @@ public:
int16 networkCommandType; int16 networkCommandType;
int32 unitId; int32 unitId;
int16 unitTypeId; int16 unitTypeId;
int16 nextUnitTypeId;
int16 commandTypeId; int16 commandTypeId;
int16 positionX; int16 positionX;
int16 positionY; int16 positionY;
@ -141,6 +144,7 @@ public:
int getCommandTypeId() const {return commandTypeId;} int getCommandTypeId() const {return commandTypeId;}
Vec2i getPosition() const {return Vec2i(positionX, positionY);} Vec2i getPosition() const {return Vec2i(positionX, positionY);}
int getUnitTypeId() const {return unitTypeId;} int getUnitTypeId() const {return unitTypeId;}
int getNextUnitTypeId() const {return nextUnitTypeId;}
int getTargetId() const {return targetId;} int getTargetId() const {return targetId;}
int getWantQueue() const {return wantQueue;} int getWantQueue() const {return wantQueue;}
int getFromFactionIndex() const {return fromFactionIndex;} int getFromFactionIndex() const {return fromFactionIndex;}