mirror of
https://github.com/glest/glest-source.git
synced 2025-08-31 19:51:44 +02:00
- bugfix for multi-build queued commands
This commit is contained in:
@@ -144,7 +144,7 @@ CommandResult Commander::tryGiveCommand(const Unit* unit, const CommandType *com
|
|||||||
|
|
||||||
CommandResult Commander::tryGiveCommand(const Selection *selection, CommandClass commandClass, const Vec2i &pos, const Unit *targetUnit, bool tryQueue) const{
|
CommandResult Commander::tryGiveCommand(const Selection *selection, CommandClass commandClass, const Vec2i &pos, const Unit *targetUnit, bool tryQueue) const{
|
||||||
|
|
||||||
if(!selection->isEmpty()){
|
if(selection->isEmpty() == false) {
|
||||||
Vec2i refPos, currPos;
|
Vec2i refPos, currPos;
|
||||||
CommandResultContainer results;
|
CommandResultContainer results;
|
||||||
|
|
||||||
|
@@ -400,7 +400,7 @@ void Gui::giveDefaultOrders(int x, int y){
|
|||||||
//compute target
|
//compute target
|
||||||
const Unit *targetUnit= NULL;
|
const Unit *targetUnit= NULL;
|
||||||
Vec2i targetPos;
|
Vec2i targetPos;
|
||||||
if(!computeTarget(Vec2i(x, y), targetPos, targetUnit)){
|
if(computeTarget(Vec2i(x, y), targetPos, targetUnit) == false) {
|
||||||
console->addStdMessage("InvalidPosition");
|
console->addStdMessage("InvalidPosition");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -445,9 +445,8 @@ void Gui::giveTwoClickOrders(int x, int y , bool prepared){
|
|||||||
if(prepared){
|
if(prepared){
|
||||||
targetPos=Vec2i(x, y);
|
targetPos=Vec2i(x, y);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
if(computeTarget(Vec2i(x, y), targetPos, targetUnit) == false) {
|
||||||
if(!computeTarget(Vec2i(x, y), targetPos, targetUnit)){
|
|
||||||
console->addStdMessage("InvalidPosition");
|
console->addStdMessage("InvalidPosition");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -455,7 +454,7 @@ void Gui::giveTwoClickOrders(int x, int y , bool prepared){
|
|||||||
|
|
||||||
bool queueKeyDown = isKeyDown(queueCommandKey);
|
bool queueKeyDown = isKeyDown(queueCommandKey);
|
||||||
//give orders to the units of this faction
|
//give orders to the units of this faction
|
||||||
if(!selectingBuilding){
|
if(selectingBuilding == false) {
|
||||||
if(selection.isUniform()) {
|
if(selection.isUniform()) {
|
||||||
result= commander->tryGiveCommand(&selection, activeCommandType,
|
result= commander->tryGiveCommand(&selection, activeCommandType,
|
||||||
targetPos, targetUnit,queueKeyDown);
|
targetPos, targetUnit,queueKeyDown);
|
||||||
@@ -475,7 +474,7 @@ void Gui::giveTwoClickOrders(int x, int y , bool prepared){
|
|||||||
//graphical result
|
//graphical result
|
||||||
addOrdersResultToConsole(activeCommandClass, result);
|
addOrdersResultToConsole(activeCommandClass, result);
|
||||||
if(result == crSuccess || result == crSomeFailed) {
|
if(result == crSuccess || result == crSomeFailed) {
|
||||||
if(!prepared){
|
if(prepared == false) {
|
||||||
mouse3d.enable();
|
mouse3d.enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -489,7 +488,7 @@ void Gui::giveTwoClickOrders(int x, int y , bool prepared){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Gui::centerCameraOnSelection() {
|
void Gui::centerCameraOnSelection() {
|
||||||
if(!selection.isEmpty()){
|
if(selection.isEmpty() == false) {
|
||||||
Vec3f refPos= selection.getRefPos();
|
Vec3f refPos= selection.getRefPos();
|
||||||
gameCamera->centerXZ(refPos.x, refPos.z);
|
gameCamera->centerXZ(refPos.x, refPos.z);
|
||||||
}
|
}
|
||||||
@@ -956,7 +955,7 @@ bool Gui::computeTarget(const Vec2i &screenPos, Vec2i &targetPos, const Unit *&t
|
|||||||
renderer.computeSelected(uc, screenPos, screenPos);
|
renderer.computeSelected(uc, screenPos, screenPos);
|
||||||
validPosObjWorld= false;
|
validPosObjWorld= false;
|
||||||
|
|
||||||
if(!uc.empty()){
|
if(uc.empty() == false) {
|
||||||
targetUnit= uc.front();
|
targetUnit= uc.front();
|
||||||
targetPos= targetUnit->getPos();
|
targetPos= targetUnit->getPos();
|
||||||
return true;
|
return true;
|
||||||
|
@@ -501,7 +501,7 @@ bool Unit::isInteresting(InterestingUnitType iut) const {
|
|||||||
switch(iut) {
|
switch(iut) {
|
||||||
case iutIdleHarvester:
|
case iutIdleHarvester:
|
||||||
if(type->hasCommandClass(ccHarvest)) {
|
if(type->hasCommandClass(ccHarvest)) {
|
||||||
if(!commands.empty()){
|
if(commands.empty() == false) {
|
||||||
const CommandType *ct= commands.front()->getCommandType();
|
const CommandType *ct= commands.front()->getCommandType();
|
||||||
if(ct != NULL){
|
if(ct != NULL){
|
||||||
return ct->getClass() == ccStop;
|
return ct->getClass() == ccStop;
|
||||||
@@ -706,7 +706,7 @@ Command *Unit::getCurrCommand() const{
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Unit::replaceCurrCommand(Command *cmd) {
|
void Unit::replaceCurrCommand(Command *cmd) {
|
||||||
assert(!commands.empty());
|
assert(commands.empty() == false);
|
||||||
commands.front() = cmd;
|
commands.front() = cmd;
|
||||||
this->setCurrentUnitTitle("");
|
this->setCurrentUnitTitle("");
|
||||||
}
|
}
|
||||||
@@ -749,25 +749,21 @@ CommandResult Unit::giveCommand(Command *command, bool tryQueue) {
|
|||||||
chrono.start();
|
chrono.start();
|
||||||
|
|
||||||
assert(command != NULL);
|
assert(command != NULL);
|
||||||
|
|
||||||
assert(command->getCommandType() != NULL);
|
assert(command->getCommandType() != NULL);
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Unit id = %d name = %s, Command [%s] tryQueue = %d\n",
|
|
||||||
// __FILE__,__FUNCTION__, __LINE__,this->id,(this->type != NULL ? this->type->getName().c_str() : "null"), (command != NULL ? command->toString().c_str() : "null"),tryQueue);
|
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
||||||
|
|
||||||
const int command_priority = command->getPriority();
|
const int command_priority = command->getPriority();
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
|
||||||
if(command->getCommandType()->isQueuable(tryQueue)) {
|
if(command->getCommandType()->isQueuable(tryQueue)) {
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] Command is Queable\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
//Delete all lower-prioirty commands
|
//Delete all lower-prioirty commands
|
||||||
for (list<Command*>::iterator i = commands.begin(); i != commands.end();) {
|
for (list<Command*>::iterator i = commands.begin(); i != commands.end();) {
|
||||||
if ((*i)->getPriority() < command_priority) {
|
if ((*i)->getPriority() < command_priority) {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] Deleting lower priority command [%s]\n",__FILE__,__FUNCTION__,__LINE__,(*i)->toString().c_str());
|
||||||
|
|
||||||
deleteQueuedCommand(*i);
|
deleteQueuedCommand(*i);
|
||||||
i = commands.erase(i);
|
i = commands.erase(i);
|
||||||
}
|
}
|
||||||
@@ -781,8 +777,10 @@ CommandResult Unit::giveCommand(Command *command, bool tryQueue) {
|
|||||||
//cancel current command if it is not queuable
|
//cancel current command if it is not queuable
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(!commands.empty() && !commands.back()->getCommandType()->isQueueAppendable()){
|
if(commands.empty() == false &&
|
||||||
|
commands.back()->getCommandType()->isQueueAppendable() == false) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] Cancel command because last one is NOT queable [%s]\n",__FILE__,__FUNCTION__,__LINE__,commands.back()->toString().c_str());
|
||||||
|
|
||||||
cancelCommand();
|
cancelCommand();
|
||||||
}
|
}
|
||||||
@@ -792,6 +790,8 @@ CommandResult Unit::giveCommand(Command *command, bool tryQueue) {
|
|||||||
else {
|
else {
|
||||||
//empty command queue
|
//empty command queue
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] Clear commands because current is NOT queable.\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
clearCommands();
|
clearCommands();
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
@@ -804,6 +804,7 @@ CommandResult Unit::giveCommand(Command *command, bool tryQueue) {
|
|||||||
//check command
|
//check command
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
CommandResult result= checkCommand(command);
|
CommandResult result= checkCommand(command);
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] checkCommand returned: [%d]\n",__FILE__,__FUNCTION__,__LINE__,result);
|
||||||
|
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
@@ -849,7 +850,7 @@ CommandResult Unit::finishCommand() {
|
|||||||
commands.erase(commands.begin());
|
commands.erase(commands.begin());
|
||||||
this->unitPath->clear();
|
this->unitPath->clear();
|
||||||
|
|
||||||
while (!commands.empty()) {
|
while (commands.empty() == false) {
|
||||||
if (commands.front()->getUnit() != NULL && livingUnitsp.find(commands.front()->getUnit()) == livingUnitsp.end()) {
|
if (commands.front()->getUnit() != NULL && livingUnitsp.find(commands.front()->getUnit()) == livingUnitsp.end()) {
|
||||||
delete commands.front();
|
delete commands.front();
|
||||||
commands.erase(commands.begin());
|
commands.erase(commands.begin());
|
||||||
@@ -1298,7 +1299,7 @@ string Unit::getDesc() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//command info
|
//command info
|
||||||
if(!commands.empty()){
|
if(commands.empty() == false) {
|
||||||
str+= "\n" + commands.front()->getCommandType()->getName();
|
str+= "\n" + commands.front()->getCommandType()->getName();
|
||||||
if(commands.size()>1){
|
if(commands.size()>1){
|
||||||
str+="\n"+lang.get("OrdersOnQueue")+": "+intToStr(commands.size());
|
str+="\n"+lang.get("OrdersOnQueue")+": "+intToStr(commands.size());
|
||||||
@@ -1437,7 +1438,7 @@ void Unit::updateTarget(){
|
|||||||
void Unit::clearCommands() {
|
void Unit::clearCommands() {
|
||||||
this->setCurrentUnitTitle("");
|
this->setCurrentUnitTitle("");
|
||||||
this->unitPath->clear();
|
this->unitPath->clear();
|
||||||
while(!commands.empty()){
|
while(commands.empty() == false) {
|
||||||
undoCommand(commands.back());
|
undoCommand(commands.back());
|
||||||
delete commands.back();
|
delete commands.back();
|
||||||
commands.pop_back();
|
commands.pop_back();
|
||||||
@@ -1445,8 +1446,7 @@ void Unit::clearCommands() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Unit::deleteQueuedCommand(Command *command) {
|
void Unit::deleteQueuedCommand(Command *command) {
|
||||||
if(getCurrCommand()==command)
|
if(getCurrCommand() == command) {
|
||||||
{
|
|
||||||
this->setCurrentUnitTitle("");
|
this->setCurrentUnitTitle("");
|
||||||
this->unitPath->clear();
|
this->unitPath->clear();
|
||||||
}
|
}
|
||||||
@@ -1465,15 +1465,17 @@ CommandResult Unit::checkCommand(Command *command) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//if not operative or has not command type => fail
|
//if not operative or has not command type => fail
|
||||||
if(!isOperative() || command->getUnit()==this || !getType()->hasCommandType(command->getCommandType())|| !this->getFaction()->reqsOk(command->getCommandType())){
|
if(isOperative() == false ||
|
||||||
|
command->getUnit() == this ||
|
||||||
|
getType()->hasCommandType(command->getCommandType()) == false ||
|
||||||
|
this->getFaction()->reqsOk(command->getCommandType()) == false) {
|
||||||
return crFailUndefined;
|
return crFailUndefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
//if pos is not inside the world (if comand has not a pos, pos is (0, 0) and is inside world
|
//if pos is not inside the world (if comand has not a pos, pos is (0, 0) and is inside world
|
||||||
if(!map->isInside(command->getPos())) {
|
if(map->isInside(command->getPos()) == false) {
|
||||||
|
|
||||||
return crFailUndefined;
|
return crFailUndefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -187,6 +187,8 @@ void UnitUpdater::updateUnitCommand(Unit *unit) {
|
|||||||
|
|
||||||
//if unit has command process it
|
//if unit has command process it
|
||||||
if(unit->anyCommand()) {
|
if(unit->anyCommand()) {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] unit [%s] has command [%s]\n",__FILE__,__FUNCTION__,__LINE__,unit->toString().c_str(), unit->getCurrCommand()->toString().c_str());
|
||||||
|
|
||||||
CommandClass cc = unit->getCurrCommand()->getCommandType()->commandTypeClass;
|
CommandClass cc = unit->getCurrCommand()->getCommandType()->commandTypeClass;
|
||||||
unit->getCurrCommand()->getCommandType()->update(this, unit);
|
unit->getCurrCommand()->getCommandType()->update(this, unit);
|
||||||
}
|
}
|
||||||
@@ -195,7 +197,7 @@ void UnitUpdater::updateUnitCommand(Unit *unit) {
|
|||||||
|
|
||||||
//if no commands stop and add stop command
|
//if no commands stop and add stop command
|
||||||
if(unit->anyCommand() == false && unit->isOperative()) {
|
if(unit->anyCommand() == false && unit->isOperative()) {
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
unit->setCurrSkill(scStop);
|
unit->setCurrSkill(scStop);
|
||||||
|
|
||||||
if(unit->getType()->hasCommandClass(ccStop)) {
|
if(unit->getType()->hasCommandClass(ccStop)) {
|
||||||
@@ -445,6 +447,7 @@ void UnitUpdater::updateBuild(Unit *unit) {
|
|||||||
chrono.start();
|
chrono.start();
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] unit [%s] will build using command [%s]\n",__FILE__,__FUNCTION__,__LINE__,unit->toString().c_str(), unit->getCurrCommand()->toString().c_str());
|
||||||
|
|
||||||
Command *command= unit->getCurrCommand();
|
Command *command= unit->getCurrCommand();
|
||||||
const BuildCommandType *bct= static_cast<const BuildCommandType*>(command->getCommandType());
|
const BuildCommandType *bct= static_cast<const BuildCommandType*>(command->getCommandType());
|
||||||
@@ -454,6 +457,7 @@ void UnitUpdater::updateBuild(Unit *unit) {
|
|||||||
|
|
||||||
if(unit->getCurrSkill()->getClass() != scBuild) {
|
if(unit->getCurrSkill()->getClass() != scBuild) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
//if not building
|
//if not building
|
||||||
const UnitType *ut= command->getUnitType();
|
const UnitType *ut= command->getUnitType();
|
||||||
@@ -486,6 +490,7 @@ void UnitUpdater::updateBuild(Unit *unit) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] tsValue = %d\n",__FILE__,__FUNCTION__,__LINE__,tsValue);
|
||||||
|
|
||||||
switch (tsValue) {
|
switch (tsValue) {
|
||||||
case tsMoving:
|
case tsMoving:
|
||||||
@@ -517,6 +522,8 @@ void UnitUpdater::updateBuild(Unit *unit) {
|
|||||||
throw runtime_error("detected unsupported pathfinder type!");
|
throw runtime_error("detected unsupported pathfinder type!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] canOccupyCell = %d\n",__FILE__,__FUNCTION__,__LINE__,canOccupyCell);
|
||||||
|
|
||||||
if (canOccupyCell == true) {
|
if (canOccupyCell == true) {
|
||||||
const UnitType *builtUnitType= command->getUnitType();
|
const UnitType *builtUnitType= command->getUnitType();
|
||||||
CardinalDir facing = command->getFacing();
|
CardinalDir facing = command->getFacing();
|
||||||
@@ -594,6 +601,7 @@ void UnitUpdater::updateBuild(Unit *unit) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] got BuildingNoPlace\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] got BuildingNoPlace\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] got BuildingNoPlace\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -603,6 +611,7 @@ void UnitUpdater::updateBuild(Unit *unit) {
|
|||||||
unit->cancelCommand();
|
unit->cancelCommand();
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] got tsBlocked\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] got tsBlocked\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] got tsBlocked\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -611,6 +620,7 @@ void UnitUpdater::updateBuild(Unit *unit) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] tsArrived unit = %s\n",__FILE__,__FUNCTION__,__LINE__,unit->toString().c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] tsArrived unit = %s\n",__FILE__,__FUNCTION__,__LINE__,unit->toString().c_str());
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] tsArrived unit = %s\n",__FILE__,__FUNCTION__,__LINE__,unit->toString().c_str());
|
||||||
|
|
||||||
//if building
|
//if building
|
||||||
Unit *builtUnit = map->getCell(unit->getTargetPos())->getUnit(fLand);
|
Unit *builtUnit = map->getCell(unit->getTargetPos())->getUnit(fLand);
|
||||||
@@ -622,13 +632,17 @@ void UnitUpdater::updateBuild(Unit *unit) {
|
|||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] builtUnit = %s\n",__FILE__,__FUNCTION__,__LINE__,builtUnit->toString().c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] builtUnit = %s\n",__FILE__,__FUNCTION__,__LINE__,builtUnit->toString().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] builtUnit = [%p]\n",__FILE__,__FUNCTION__,__LINE__,builtUnit);
|
||||||
|
|
||||||
//if unit is killed while building then u==NULL;
|
//if unit is killed while building then u==NULL;
|
||||||
if(builtUnit != NULL && builtUnit != command->getUnit()) {
|
if(builtUnit != NULL && builtUnit != command->getUnit()) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] builtUnit is not the command's unit!\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
unit->setCurrSkill(scStop);
|
unit->setCurrSkill(scStop);
|
||||||
}
|
}
|
||||||
else if(builtUnit == NULL || builtUnit->isBuilt()) {
|
else if(builtUnit == NULL || builtUnit->isBuilt()) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] builtUnit is NULL or ALREADY built\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
unit->finishCommand();
|
unit->finishCommand();
|
||||||
unit->setCurrSkill(scStop);
|
unit->setCurrSkill(scStop);
|
||||||
@@ -636,6 +650,7 @@ void UnitUpdater::updateBuild(Unit *unit) {
|
|||||||
}
|
}
|
||||||
else if(builtUnit == NULL || builtUnit->repair()) {
|
else if(builtUnit == NULL || builtUnit->repair()) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
//building finished
|
//building finished
|
||||||
unit->finishCommand();
|
unit->finishCommand();
|
||||||
@@ -1063,7 +1078,9 @@ Unit * UnitUpdater::findPeerUnitBuilder(Unit *unit) {
|
|||||||
if(command != NULL) {
|
if(command != NULL) {
|
||||||
const RepairCommandType *rct= dynamic_cast<const RepairCommandType*>(command->getCommandType());
|
const RepairCommandType *rct= dynamic_cast<const RepairCommandType*>(command->getCommandType());
|
||||||
if(rct != NULL && command->getStateType() == cst_linkedUnit) {
|
if(rct != NULL && command->getStateType() == cst_linkedUnit) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] looking for command->getStateValue() = %d\n",__FILE__,__FUNCTION__,__LINE__,command->getStateValue());
|
||||||
|
|
||||||
|
Unit *firstLinkedPeerRepairer = NULL;
|
||||||
|
|
||||||
for(int i = 0; i < unit->getFaction()->getUnitCount(); ++i) {
|
for(int i = 0; i < unit->getFaction()->getUnitCount(); ++i) {
|
||||||
Unit *peerUnit = unit->getFaction()->getUnit(i);
|
Unit *peerUnit = unit->getFaction()->getUnit(i);
|
||||||
@@ -1084,12 +1101,35 @@ Unit * UnitUpdater::findPeerUnitBuilder(Unit *unit) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] **peer NOT building**, peerUnit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,peerUnit->toString().c_str());
|
||||||
|
|
||||||
|
if(firstLinkedPeerRepairer == NULL) {
|
||||||
|
const RepairCommandType *prct = dynamic_cast<const RepairCommandType*>(peerCommand->getCommandType());
|
||||||
|
if(prct != NULL) {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
if(command->getStateValue() == peerUnit->getId()) {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
firstLinkedPeerRepairer = peerUnit;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(foundUnitBuilder == NULL) {
|
||||||
|
foundUnitBuilder = firstLinkedPeerRepairer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] returning foundUnitBuilder = [%s]\n",__FILE__,__FUNCTION__,__LINE__,(foundUnitBuilder != NULL ? foundUnitBuilder->toString().c_str() : "null"));
|
||||||
|
|
||||||
return foundUnitBuilder;
|
return foundUnitBuilder;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user