diff --git a/source/glest_game/game/commander.cpp b/source/glest_game/game/commander.cpp index 0f8c8ddd..b8a3ac42 100644 --- a/source/glest_game/game/commander.cpp +++ b/source/glest_game/game/commander.cpp @@ -40,8 +40,12 @@ void Commander::init(World *world){ this->world= world; } -CommandResult Commander::tryGiveCommand(const Unit* unit, const CommandType *commandType, const Vec2i &pos, const UnitType* unitType, CardinalDir facing, bool tryQueue) const{ - +CommandResult Commander::tryGiveCommand(const Unit* unit, const CommandType *commandType, const Vec2i &pos, const UnitType* unitType, CardinalDir facing, bool tryQueue) const { + assert(this->world != NULL); + assert(unit != NULL); + assert(commandType != NULL); + assert(unitType != NULL); + NetworkCommand networkCommand(this->world,nctGiveCommand, unit->getId(), commandType->getId(), pos, unitType->getId(), -1, facing, tryQueue); return pushNetworkCommand(&networkCommand); } @@ -364,7 +368,7 @@ void Commander::giveNetworkCommand(NetworkCommand* networkCommand) const { Command* Commander::buildCommand(const NetworkCommand* networkCommand) const{ assert(networkCommand->getNetworkCommandType()==nctGiveCommand); - SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] networkCommand [%s]\n",__FILE__,__FUNCTION__,__LINE__,networkCommand->toString().c_str()); if(world == NULL) { char szBuf[1024]=""; @@ -396,7 +400,7 @@ Command* Commander::buildCommand(const NetworkCommand* networkCommand) const{ } if(unit->getFaction()->getIndex() != networkCommand->getUnitFactionIndex()) { - char szBuf[1024]=""; + char szBuf[4096]=""; sprintf(szBuf,"In [%s::%s Line: %d]\nUnit / Faction mismatch for network command = [%s]\n%s\nfor unit = %d\n[%s]\n[%s]\nactual local factionIndex = %d.\nGame out of synch.", __FILE__,__FUNCTION__,__LINE__,networkCommand->toString().c_str(),unit->getType()->getCommandTypeListDesc().c_str(),unit->getId(), unit->getFullName().c_str(),unit->getDesc().c_str(),unit->getFaction()->getIndex()); @@ -415,7 +419,7 @@ Command* Commander::buildCommand(const NetworkCommand* networkCommand) const{ //validate command type if(ct == NULL) { - char szBuf[1024]=""; + char szBuf[4096]=""; sprintf(szBuf,"In [%s::%s Line: %d]\nCan not find command type for network command = [%s]\n%s\nfor unit = %d\n[%s]\n[%s]\nactual local factionIndex = %d.\nGame out of synch.", __FILE__,__FUNCTION__,__LINE__,networkCommand->toString().c_str(),unit->getType()->getCommandTypeListDesc().c_str(),unit->getId(), unit->getFullName().c_str(),unit->getDesc().c_str(),unit->getFaction()->getIndex()); diff --git a/source/glest_game/type_instances/command.cpp b/source/glest_game/type_instances/command.cpp index 351fe335..b7c355e3 100644 --- a/source/glest_game/type_instances/command.cpp +++ b/source/glest_game/type_instances/command.cpp @@ -14,6 +14,7 @@ #include "command_type.h" #include "util.h" #include "conversion.h" +#include "unit_type.h" #include "leak_dumper.h" using namespace Shared::Util; @@ -48,6 +49,10 @@ Command::Command(const CommandType *ct, const Vec2i &pos, const UnitType *unitTy this->pos= pos; this->unitType= unitType; this->facing = facing; + + if(this->unitType != NULL) { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] unitType = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->unitType->toString().c_str()); + } } // =============== set =============== diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index 17a72788..33d9868d 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -40,6 +40,11 @@ namespace Glest{ namespace Game{ const int UnitPath::maxBlockCount= 10; +UnitPath::UnitPath() { + this->blockCount = 0; + this->pathQueue.clear(); +} + bool UnitPath::isEmpty(){ return pathQueue.empty(); } diff --git a/source/glest_game/type_instances/unit.h b/source/glest_game/type_instances/unit.h index 467c1e2a..c5da8833 100644 --- a/source/glest_game/type_instances/unit.h +++ b/source/glest_game/type_instances/unit.h @@ -98,7 +98,7 @@ public: /// Holds the next cells of a Unit movement // ===================================================== -class UnitPath{ +class UnitPath { private: static const int maxBlockCount; @@ -107,6 +107,7 @@ private: vector pathQueue; public: + UnitPath(); bool isBlocked(); bool isEmpty();