- minor feature request added from sourceforge, when command given cannot be executed, sometimes we show the requirements of the command so the user knows why it failed
This commit is contained in:
parent
35f6a6665b
commit
1dbcabf12c
|
@ -948,7 +948,7 @@ void Ai::massiveAttack(const Vec2i &pos, Field field, bool ultraAttack){
|
||||||
|
|
||||||
void Ai::returnBase(int unitIndex) {
|
void Ai::returnBase(int unitIndex) {
|
||||||
Vec2i pos;
|
Vec2i pos;
|
||||||
CommandResult r;
|
std::pair<CommandResult,string> r(crFailUndefined,"");
|
||||||
aiInterface->getFactionIndex();
|
aiInterface->getFactionIndex();
|
||||||
pos= Vec2i(
|
pos= Vec2i(
|
||||||
random.randRange(-villageRadius, villageRadius),
|
random.randRange(-villageRadius, villageRadius),
|
||||||
|
@ -1141,7 +1141,7 @@ void Ai::unblockUnits() {
|
||||||
unitGroupCommandId = aiInterface->getWorld()->getNextCommandGroupId();
|
unitGroupCommandId = aiInterface->getWorld()->getNextCommandGroupId();
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult r = aiInterface->giveCommand(adjacentUnit,ct, pos, unitGroupCommandId);
|
std::pair<CommandResult,string> r = aiInterface->giveCommand(adjacentUnit,ct, pos, unitGroupCommandId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,36 +126,37 @@ bool AiInterface::executeCommandOverNetwork() {
|
||||||
return faction->getCpuControl(enableServerControlledAI,isNetworkGame,role);
|
return faction->getCpuControl(enableServerControlledAI,isNetworkGame,role);
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult AiInterface::giveCommandSwitchTeamVote(const Faction* faction, SwitchTeamVote *vote) {
|
std::pair<CommandResult,string> AiInterface::giveCommandSwitchTeamVote(const Faction* faction, SwitchTeamVote *vote) {
|
||||||
assert(this->gameSettings != NULL);
|
assert(this->gameSettings != NULL);
|
||||||
|
|
||||||
commander->trySwitchTeamVote(faction,vote);
|
commander->trySwitchTeamVote(faction,vote);
|
||||||
return crSuccess;
|
return std::pair<CommandResult,string>(crSuccess,"");
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult AiInterface::giveCommand(int unitIndex, CommandClass commandClass, const Vec2i &pos){
|
std::pair<CommandResult,string> AiInterface::giveCommand(int unitIndex, CommandClass commandClass, const Vec2i &pos){
|
||||||
assert(this->gameSettings != NULL);
|
assert(this->gameSettings != NULL);
|
||||||
|
|
||||||
|
std::pair<CommandResult,string> result(crFailUndefined,"");
|
||||||
if(executeCommandOverNetwork() == true) {
|
if(executeCommandOverNetwork() == true) {
|
||||||
const Unit *unit = getMyUnit(unitIndex);
|
const Unit *unit = getMyUnit(unitIndex);
|
||||||
CommandResult result = commander->tryGiveCommand(unit, unit->getType()->getFirstCtOfClass(commandClass), pos, unit->getType(),CardinalDir::NORTH);
|
result = commander->tryGiveCommand(unit, unit->getType()->getFirstCtOfClass(commandClass), pos, unit->getType(),CardinalDir::NORTH);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Command *c= new Command (world->getFaction(factionIndex)->getUnit(unitIndex)->getType()->getFirstCtOfClass(commandClass), pos);
|
Command *c= new Command (world->getFaction(factionIndex)->getUnit(unitIndex)->getType()->getFirstCtOfClass(commandClass), pos);
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
CommandResult result = world->getFaction(factionIndex)->getUnit(unitIndex)->giveCommand(c);
|
result = world->getFaction(factionIndex)->getUnit(unitIndex)->giveCommand(c);
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult AiInterface::giveCommand(const Unit *unit, const CommandType *commandType, const Vec2i &pos, int unitGroupCommandId) {
|
std::pair<CommandResult,string> AiInterface::giveCommand(const Unit *unit, const CommandType *commandType, const Vec2i &pos, int unitGroupCommandId) {
|
||||||
assert(this->gameSettings != NULL);
|
assert(this->gameSettings != NULL);
|
||||||
|
|
||||||
|
std::pair<CommandResult,string> result(crFailUndefined,"");
|
||||||
if(unit == NULL) {
|
if(unit == NULL) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
snprintf(szBuf,8096,"In [%s::%s Line: %d] Can not find AI unit in AI factionIndex = %d. Game out of synch.",__FILE__,__FUNCTION__,__LINE__,factionIndex);
|
snprintf(szBuf,8096,"In [%s::%s Line: %d] Can not find AI unit in AI factionIndex = %d. Game out of synch.",__FILE__,__FUNCTION__,__LINE__,factionIndex);
|
||||||
|
@ -188,7 +189,7 @@ CommandResult AiInterface::giveCommand(const Unit *unit, const CommandType *comm
|
||||||
}
|
}
|
||||||
|
|
||||||
if(executeCommandOverNetwork() == true) {
|
if(executeCommandOverNetwork() == true) {
|
||||||
CommandResult result = commander->tryGiveCommand(unit, commandType, pos,
|
result = commander->tryGiveCommand(unit, commandType, pos,
|
||||||
unit->getType(),CardinalDir::NORTH, false, NULL,unitGroupCommandId);
|
unit->getType(),CardinalDir::NORTH, false, NULL,unitGroupCommandId);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -199,16 +200,17 @@ CommandResult AiInterface::giveCommand(const Unit *unit, const CommandType *comm
|
||||||
Unit *unitToCommand = faction->findUnit(unit->getId());
|
Unit *unitToCommand = faction->findUnit(unit->getId());
|
||||||
Command *cmd = new Command(commandType, pos);
|
Command *cmd = new Command(commandType, pos);
|
||||||
cmd->setUnitCommandGroupId(unitGroupCommandId);
|
cmd->setUnitCommandGroupId(unitGroupCommandId);
|
||||||
CommandResult result = unitToCommand->giveCommand(cmd);
|
result = unitToCommand->giveCommand(cmd);
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult AiInterface::giveCommand(int unitIndex, const CommandType *commandType, const Vec2i &pos, int unitGroupCommandId) {
|
std::pair<CommandResult,string> AiInterface::giveCommand(int unitIndex, const CommandType *commandType, const Vec2i &pos, int unitGroupCommandId) {
|
||||||
assert(this->gameSettings != NULL);
|
assert(this->gameSettings != NULL);
|
||||||
|
|
||||||
|
std::pair<CommandResult,string> result(crFailUndefined,"");
|
||||||
const Unit *unit = getMyUnit(unitIndex);
|
const Unit *unit = getMyUnit(unitIndex);
|
||||||
if(unit == NULL) {
|
if(unit == NULL) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
|
@ -238,7 +240,7 @@ CommandResult AiInterface::giveCommand(int unitIndex, const CommandType *command
|
||||||
|
|
||||||
if(executeCommandOverNetwork() == true) {
|
if(executeCommandOverNetwork() == true) {
|
||||||
const Unit *unit = getMyUnit(unitIndex);
|
const Unit *unit = getMyUnit(unitIndex);
|
||||||
CommandResult result = commander->tryGiveCommand(unit, commandType, pos, unit->getType(),CardinalDir::NORTH);
|
result = commander->tryGiveCommand(unit, commandType, pos, unit->getType(),CardinalDir::NORTH);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -246,16 +248,17 @@ CommandResult AiInterface::giveCommand(int unitIndex, const CommandType *command
|
||||||
|
|
||||||
Command *cmd = new Command(commandType, pos);
|
Command *cmd = new Command(commandType, pos);
|
||||||
cmd->setUnitCommandGroupId(unitGroupCommandId);
|
cmd->setUnitCommandGroupId(unitGroupCommandId);
|
||||||
CommandResult result = world->getFaction(factionIndex)->getUnit(unitIndex)->giveCommand(cmd);
|
result = world->getFaction(factionIndex)->getUnit(unitIndex)->giveCommand(cmd);
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult AiInterface::giveCommand(int unitIndex, const CommandType *commandType, const Vec2i &pos, const UnitType *ut) {
|
std::pair<CommandResult,string> AiInterface::giveCommand(int unitIndex, const CommandType *commandType, const Vec2i &pos, const UnitType *ut) {
|
||||||
assert(this->gameSettings != NULL);
|
assert(this->gameSettings != NULL);
|
||||||
|
|
||||||
|
std::pair<CommandResult,string> result(crFailUndefined,"");
|
||||||
const Unit *unit = getMyUnit(unitIndex);
|
const Unit *unit = getMyUnit(unitIndex);
|
||||||
if(unit == NULL) {
|
if(unit == NULL) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
|
@ -285,13 +288,13 @@ CommandResult AiInterface::giveCommand(int unitIndex, const CommandType *command
|
||||||
|
|
||||||
if(executeCommandOverNetwork() == true) {
|
if(executeCommandOverNetwork() == true) {
|
||||||
const Unit *unit = getMyUnit(unitIndex);
|
const Unit *unit = getMyUnit(unitIndex);
|
||||||
CommandResult result = commander->tryGiveCommand(unit, commandType, pos, ut,CardinalDir::NORTH);
|
result = commander->tryGiveCommand(unit, commandType, pos, ut,CardinalDir::NORTH);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
CommandResult result = world->getFaction(factionIndex)->getUnit(unitIndex)->giveCommand(new Command(commandType, pos, ut, CardinalDir::NORTH));
|
result = world->getFaction(factionIndex)->getUnit(unitIndex)->giveCommand(new Command(commandType, pos, ut, CardinalDir::NORTH));
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
@ -299,10 +302,11 @@ CommandResult AiInterface::giveCommand(int unitIndex, const CommandType *command
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult AiInterface::giveCommand(int unitIndex, const CommandType *commandType, Unit *u){
|
std::pair<CommandResult,string> AiInterface::giveCommand(int unitIndex, const CommandType *commandType, Unit *u){
|
||||||
assert(this->gameSettings != NULL);
|
assert(this->gameSettings != NULL);
|
||||||
assert(this->commander != NULL);
|
assert(this->commander != NULL);
|
||||||
|
|
||||||
|
std::pair<CommandResult,string> result(crFailUndefined,"");
|
||||||
const Unit *unit = getMyUnit(unitIndex);
|
const Unit *unit = getMyUnit(unitIndex);
|
||||||
if(unit == NULL) {
|
if(unit == NULL) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
|
@ -334,14 +338,14 @@ CommandResult AiInterface::giveCommand(int unitIndex, const CommandType *command
|
||||||
Unit *targetUnit = u;
|
Unit *targetUnit = u;
|
||||||
const Unit *unit = getMyUnit(unitIndex);
|
const Unit *unit = getMyUnit(unitIndex);
|
||||||
|
|
||||||
CommandResult result = commander->tryGiveCommand(unit, commandType, Vec2i(0), unit->getType(),CardinalDir::NORTH,false,targetUnit);
|
result = commander->tryGiveCommand(unit, commandType, Vec2i(0), unit->getType(),CardinalDir::NORTH,false,targetUnit);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
CommandResult result = world->getFaction(factionIndex)->getUnit(unitIndex)->giveCommand(new Command(commandType, u));
|
result = world->getFaction(factionIndex)->getUnit(unitIndex)->giveCommand(new Command(commandType, u));
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
|
|
@ -67,13 +67,13 @@ public:
|
||||||
void printLog(int logLevel, const string &s);
|
void printLog(int logLevel, const string &s);
|
||||||
|
|
||||||
//interact
|
//interact
|
||||||
CommandResult giveCommand(int unitIndex, CommandClass commandClass, const Vec2i &pos=Vec2i(0));
|
std::pair<CommandResult,string> giveCommand(int unitIndex, CommandClass commandClass, const Vec2i &pos=Vec2i(0));
|
||||||
CommandResult giveCommand(int unitIndex, const CommandType *commandType, const Vec2i &pos, const UnitType* unitType);
|
std::pair<CommandResult,string> giveCommand(int unitIndex, const CommandType *commandType, const Vec2i &pos, const UnitType* unitType);
|
||||||
CommandResult giveCommand(int unitIndex, const CommandType *commandType, const Vec2i &pos, int unitGroupCommandId);
|
std::pair<CommandResult,string> giveCommand(int unitIndex, const CommandType *commandType, const Vec2i &pos, int unitGroupCommandId);
|
||||||
CommandResult giveCommand(int unitIndex, const CommandType *commandType, Unit *u= NULL);
|
std::pair<CommandResult,string> giveCommand(int unitIndex, const CommandType *commandType, Unit *u= NULL);
|
||||||
CommandResult giveCommand(const Unit *unit, const CommandType *commandType, const Vec2i &pos, int unitGroupCommandId);
|
std::pair<CommandResult,string> giveCommand(const Unit *unit, const CommandType *commandType, const Vec2i &pos, int unitGroupCommandId);
|
||||||
|
|
||||||
CommandResult giveCommandSwitchTeamVote(const Faction* faction, SwitchTeamVote *vote);
|
std::pair<CommandResult,string> giveCommandSwitchTeamVote(const Faction* faction, SwitchTeamVote *vote);
|
||||||
|
|
||||||
//get data
|
//get data
|
||||||
const ControlType getControlType();
|
const ControlType getControlType();
|
||||||
|
|
|
@ -171,11 +171,12 @@ bool Commander::canSubmitCommandType(const Unit *unit, const CommandType *comman
|
||||||
return canSubmitCommand;
|
return canSubmitCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult Commander::tryGiveCommand(const Selection *selection, const CommandType *commandType,
|
std::pair<CommandResult,string> Commander::tryGiveCommand(const Selection *selection, const CommandType *commandType,
|
||||||
const Vec2i &pos, const UnitType* unitType,
|
const Vec2i &pos, const UnitType* unitType,
|
||||||
CardinalDir facing, bool tryQueue,Unit *targetUnit) const {
|
CardinalDir facing, bool tryQueue,Unit *targetUnit) const {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
std::pair<CommandResult,string> result(crFailUndefined,"");
|
||||||
if(!selection->isEmpty() && commandType != NULL) {
|
if(!selection->isEmpty() && commandType != NULL) {
|
||||||
Vec2i refPos;
|
Vec2i refPos;
|
||||||
CommandResultContainer results;
|
CommandResultContainer results;
|
||||||
|
@ -202,7 +203,7 @@ CommandResult Commander::tryGiveCommand(const Selection *selection, const Comman
|
||||||
const Unit *unit = selection->getUnit(i);
|
const Unit *unit = selection->getUnit(i);
|
||||||
|
|
||||||
|
|
||||||
CommandResult result = crFailUndefined;
|
std::pair<CommandResult,string> resultCur(crFailUndefined,"");
|
||||||
bool canSubmitCommand = canSubmitCommandType(unit, commandType);
|
bool canSubmitCommand = canSubmitCommandType(unit, commandType);
|
||||||
if(canSubmitCommand == true) {
|
if(canSubmitCommand == true) {
|
||||||
int unitId= unit->getId();
|
int unitId= unit->getId();
|
||||||
|
@ -238,21 +239,19 @@ CommandResult Commander::tryGiveCommand(const Selection *selection, const Comman
|
||||||
unitCommandGroupId);
|
unitCommandGroupId);
|
||||||
|
|
||||||
//every unit is ordered to a the position
|
//every unit is ordered to a the position
|
||||||
result= pushNetworkCommand(&networkCommand);
|
resultCur= pushNetworkCommand(&networkCommand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
results.push_back(result);
|
results.push_back(resultCur);
|
||||||
}
|
}
|
||||||
|
|
||||||
return computeResult(results);
|
return computeResult(results);
|
||||||
}
|
}
|
||||||
else{
|
return std::pair<CommandResult,string>(crFailUndefined,"");
|
||||||
return crFailUndefined;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult Commander::tryGiveCommand(const Unit* unit, const CommandType *commandType,
|
std::pair<CommandResult,string> Commander::tryGiveCommand(const Unit* unit, const CommandType *commandType,
|
||||||
const Vec2i &pos, const UnitType* unitType,
|
const Vec2i &pos, const UnitType* unitType,
|
||||||
CardinalDir facing, bool tryQueue,Unit *targetUnit,
|
CardinalDir facing, bool tryQueue,Unit *targetUnit,
|
||||||
int unitGroupCommandId) const {
|
int unitGroupCommandId) const {
|
||||||
|
@ -268,7 +267,7 @@ CommandResult Commander::tryGiveCommand(const Unit* unit, const CommandType *com
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
|
||||||
CommandResult result = crFailUndefined;
|
std::pair<CommandResult,string> result(crFailUndefined,"");
|
||||||
bool canSubmitCommand=canSubmitCommandType(unit, commandType);
|
bool canSubmitCommand=canSubmitCommandType(unit, commandType);
|
||||||
if(canSubmitCommand == true) {
|
if(canSubmitCommand == true) {
|
||||||
NetworkCommand networkCommand(this->world,nctGiveCommand, unit->getId(),
|
NetworkCommand networkCommand(this->world,nctGiveCommand, unit->getId(),
|
||||||
|
@ -286,9 +285,10 @@ CommandResult Commander::tryGiveCommand(const Unit* unit, const CommandType *com
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult Commander::tryGiveCommand(const Selection *selection, CommandClass commandClass,
|
std::pair<CommandResult,string> Commander::tryGiveCommand(const Selection *selection, CommandClass commandClass,
|
||||||
const Vec2i &pos, const Unit *targetUnit, bool tryQueue) const{
|
const Vec2i &pos, const Unit *targetUnit, bool tryQueue) const{
|
||||||
|
|
||||||
|
std::pair<CommandResult,string> result(crFailUndefined,"");
|
||||||
if(selection->isEmpty() == false) {
|
if(selection->isEmpty() == false) {
|
||||||
Vec2i refPos, currPos;
|
Vec2i refPos, currPos;
|
||||||
CommandResultContainer results;
|
CommandResultContainer results;
|
||||||
|
@ -305,7 +305,8 @@ CommandResult Commander::tryGiveCommand(const Selection *selection, CommandClass
|
||||||
const Unit *unit= selection->getUnit(i);
|
const Unit *unit= selection->getUnit(i);
|
||||||
const CommandType *ct= unit->getType()->getFirstCtOfClass(commandClass);
|
const CommandType *ct= unit->getType()->getFirstCtOfClass(commandClass);
|
||||||
if(ct != NULL) {
|
if(ct != NULL) {
|
||||||
CommandResult result = crFailUndefined;
|
std::pair<CommandResult,string> resultCur(crFailUndefined,"");
|
||||||
|
|
||||||
bool canSubmitCommand=canSubmitCommandType(unit, ct);
|
bool canSubmitCommand=canSubmitCommandType(unit, ct);
|
||||||
if(canSubmitCommand == true) {
|
if(canSubmitCommand == true) {
|
||||||
|
|
||||||
|
@ -318,24 +319,26 @@ CommandResult Commander::tryGiveCommand(const Selection *selection, CommandClass
|
||||||
tryQueue,cst_None,-1,unitCommandGroupId);
|
tryQueue,cst_None,-1,unitCommandGroupId);
|
||||||
|
|
||||||
//every unit is ordered to a different pos
|
//every unit is ordered to a different pos
|
||||||
result= pushNetworkCommand(&networkCommand);
|
resultCur= pushNetworkCommand(&networkCommand);
|
||||||
}
|
}
|
||||||
results.push_back(result);
|
results.push_back(resultCur);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
results.push_back(crFailUndefined);
|
results.push_back(std::pair<CommandResult,string>(crFailUndefined,""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return computeResult(results);
|
return computeResult(results);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
return crFailUndefined;
|
return std::pair<CommandResult,string>(crFailUndefined,"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult Commander::tryGiveCommand(const Selection *selection,
|
std::pair<CommandResult,string> Commander::tryGiveCommand(const Selection *selection,
|
||||||
const CommandType *commandType, const Vec2i &pos,
|
const CommandType *commandType, const Vec2i &pos,
|
||||||
const Unit *targetUnit, bool tryQueue) const {
|
const Unit *targetUnit, bool tryQueue) const {
|
||||||
|
std::pair<CommandResult,string> result(crFailUndefined,"");
|
||||||
|
|
||||||
if(!selection->isEmpty() && commandType!=NULL){
|
if(!selection->isEmpty() && commandType!=NULL){
|
||||||
Vec2i refPos;
|
Vec2i refPos;
|
||||||
CommandResultContainer results;
|
CommandResultContainer results;
|
||||||
|
@ -352,7 +355,8 @@ CommandResult Commander::tryGiveCommand(const Selection *selection,
|
||||||
const Unit *unit = selection->getUnit(i);
|
const Unit *unit = selection->getUnit(i);
|
||||||
assert(unit != NULL);
|
assert(unit != NULL);
|
||||||
|
|
||||||
CommandResult result = crFailUndefined;
|
std::pair<CommandResult,string> resultCur(crFailUndefined,"");
|
||||||
|
|
||||||
bool canSubmitCommand=canSubmitCommandType(unit, commandType);
|
bool canSubmitCommand=canSubmitCommandType(unit, commandType);
|
||||||
if(canSubmitCommand == true) {
|
if(canSubmitCommand == true) {
|
||||||
int targetId= targetUnit==NULL? Unit::invalidId: targetUnit->getId();
|
int targetId= targetUnit==NULL? Unit::invalidId: targetUnit->getId();
|
||||||
|
@ -363,24 +367,24 @@ CommandResult Commander::tryGiveCommand(const Selection *selection,
|
||||||
cst_None, -1, unitCommandGroupId);
|
cst_None, -1, unitCommandGroupId);
|
||||||
|
|
||||||
//every unit is ordered to a different position
|
//every unit is ordered to a different position
|
||||||
result= pushNetworkCommand(&networkCommand);
|
resultCur= pushNetworkCommand(&networkCommand);
|
||||||
}
|
}
|
||||||
results.push_back(result);
|
results.push_back(resultCur);
|
||||||
}
|
}
|
||||||
|
|
||||||
return computeResult(results);
|
return computeResult(results);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
return crFailUndefined;
|
return std::pair<CommandResult,string>(crFailUndefined,"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//auto command
|
//auto command
|
||||||
CommandResult Commander::tryGiveCommand(const Selection *selection, const Vec2i &pos,
|
std::pair<CommandResult,string> Commander::tryGiveCommand(const Selection *selection, const Vec2i &pos,
|
||||||
const Unit *targetUnit, bool tryQueue, int unitCommandGroupId) const {
|
const Unit *targetUnit, bool tryQueue, int unitCommandGroupId) const {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
CommandResult result = crFailUndefined;
|
std::pair<CommandResult,string> result(crFailUndefined,"");
|
||||||
|
|
||||||
if(selection->isEmpty() == false){
|
if(selection->isEmpty() == false){
|
||||||
Vec2i refPos, currPos;
|
Vec2i refPos, currPos;
|
||||||
|
@ -407,26 +411,27 @@ CommandResult Commander::tryGiveCommand(const Selection *selection, const Vec2i
|
||||||
int targetId= targetUnit==NULL? Unit::invalidId: targetUnit->getId();
|
int targetId= targetUnit==NULL? Unit::invalidId: targetUnit->getId();
|
||||||
int unitId= unit->getId();
|
int unitId= unit->getId();
|
||||||
|
|
||||||
CommandResult result = crFailUndefined;
|
std::pair<CommandResult,string> resultCur(crFailUndefined,"");
|
||||||
|
|
||||||
bool canSubmitCommand=canSubmitCommandType(unit, commandType);
|
bool canSubmitCommand=canSubmitCommandType(unit, commandType);
|
||||||
if(canSubmitCommand == true) {
|
if(canSubmitCommand == true) {
|
||||||
NetworkCommand networkCommand(this->world,nctGiveCommand,
|
NetworkCommand networkCommand(this->world,nctGiveCommand,
|
||||||
unitId, commandType->getId(), currPos, -1, targetId,
|
unitId, commandType->getId(), currPos, -1, targetId,
|
||||||
-1, tryQueue, cst_None, -1, unitCommandGroupId);
|
-1, tryQueue, cst_None, -1, unitCommandGroupId);
|
||||||
result= pushNetworkCommand(&networkCommand);
|
resultCur= pushNetworkCommand(&networkCommand);
|
||||||
}
|
}
|
||||||
results.push_back(result);
|
results.push_back(resultCur);
|
||||||
}
|
}
|
||||||
else if(unit->isMeetingPointSettable() == true) {
|
else if(unit->isMeetingPointSettable() == true) {
|
||||||
NetworkCommand command(this->world,nctSetMeetingPoint,
|
NetworkCommand command(this->world,nctSetMeetingPoint,
|
||||||
unit->getId(), -1, currPos,-1,-1,-1,false,
|
unit->getId(), -1, currPos,-1,-1,-1,false,
|
||||||
cst_None,-1,unitCommandGroupId);
|
cst_None,-1,unitCommandGroupId);
|
||||||
|
|
||||||
CommandResult result= pushNetworkCommand(&command);
|
std::pair<CommandResult,string> resultCur= pushNetworkCommand(&command);
|
||||||
results.push_back(result);
|
results.push_back(resultCur);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
results.push_back(crFailUndefined);
|
results.push_back(std::pair<CommandResult,string>(crFailUndefined,""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result = computeResult(results);
|
result = computeResult(results);
|
||||||
|
@ -491,25 +496,27 @@ void Commander::tryNetworkPlayerDisconnected(int factionIndex) const {
|
||||||
|
|
||||||
// ==================== PRIVATE ====================
|
// ==================== PRIVATE ====================
|
||||||
|
|
||||||
CommandResult Commander::computeResult(const CommandResultContainer &results) const {
|
std::pair<CommandResult,string> Commander::computeResult(const CommandResultContainer &results) const {
|
||||||
|
std::pair<CommandResult,string> result(crFailUndefined,"");
|
||||||
switch(results.size()) {
|
switch(results.size()) {
|
||||||
case 0:
|
case 0:
|
||||||
return crFailUndefined;
|
return std::pair<CommandResult,string>(crFailUndefined,"");
|
||||||
case 1:
|
case 1:
|
||||||
return results.front();
|
return results.front();
|
||||||
default:
|
default:
|
||||||
for(int i = 0; i < results.size(); ++i) {
|
for(int i = 0; i < results.size(); ++i) {
|
||||||
if(results[i] != crSuccess) {
|
if(results[i].first != crSuccess) {
|
||||||
return crSomeFailed;
|
return std::pair<CommandResult,string>(crSomeFailed,results[i].second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return crSuccess;
|
break;
|
||||||
}
|
}
|
||||||
|
return std::pair<CommandResult,string>(crSuccess,"");
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult Commander::pushNetworkCommand(const NetworkCommand* networkCommand) const {
|
std::pair<CommandResult,string> Commander::pushNetworkCommand(const NetworkCommand* networkCommand) const {
|
||||||
GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
|
GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
|
||||||
CommandResult cr= crSuccess;
|
std::pair<CommandResult,string> result(crSuccess,"");
|
||||||
|
|
||||||
//validate unit
|
//validate unit
|
||||||
const Unit* unit = NULL;
|
const Unit* unit = NULL;
|
||||||
|
@ -538,10 +545,10 @@ CommandResult Commander::pushNetworkCommand(const NetworkCommand* networkCommand
|
||||||
//calculate the result of the command
|
//calculate the result of the command
|
||||||
if(networkCommand->getNetworkCommandType() == nctGiveCommand) {
|
if(networkCommand->getNetworkCommandType() == nctGiveCommand) {
|
||||||
Command* command= buildCommand(networkCommand);
|
Command* command= buildCommand(networkCommand);
|
||||||
cr= unit->checkCommand(command);
|
result= unit->checkCommand(command);
|
||||||
delete command;
|
delete command;
|
||||||
}
|
}
|
||||||
return cr;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Commander::signalNetworkUpdate(Game *game) {
|
void Commander::signalNetworkUpdate(Game *game) {
|
||||||
|
|
|
@ -77,7 +77,7 @@ public:
|
||||||
|
|
||||||
class Commander : public CommanderNetworkCallbackInterface {
|
class Commander : public CommanderNetworkCallbackInterface {
|
||||||
private:
|
private:
|
||||||
typedef vector<CommandResult> CommandResultContainer;
|
typedef vector<std::pair<CommandResult,string> > CommandResultContainer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
World *world;
|
World *world;
|
||||||
|
@ -100,14 +100,14 @@ public:
|
||||||
bool hasReplayCommandListForFrame() const;
|
bool hasReplayCommandListForFrame() const;
|
||||||
int getReplayCommandListForFrameCount() const;
|
int getReplayCommandListForFrameCount() const;
|
||||||
|
|
||||||
CommandResult tryGiveCommand(const Selection *selection, const CommandType *commandType,
|
std::pair<CommandResult,string> tryGiveCommand(const Selection *selection, const CommandType *commandType,
|
||||||
const Vec2i &pos, const UnitType* unitType,
|
const Vec2i &pos, const UnitType* unitType,
|
||||||
CardinalDir facing, bool tryQueue,Unit *targetUnit=NULL) const;
|
CardinalDir facing, bool tryQueue,Unit *targetUnit=NULL) const;
|
||||||
|
|
||||||
CommandResult tryGiveCommand(const Unit* unit, const CommandType *commandType, const Vec2i &pos, const UnitType* unitType, CardinalDir facing, bool tryQueue = false,Unit *targetUnit=NULL,int unitGroupCommandId=-1) const;
|
std::pair<CommandResult,string> tryGiveCommand(const Unit* unit, const CommandType *commandType, const Vec2i &pos, const UnitType* unitType, CardinalDir facing, bool tryQueue = false,Unit *targetUnit=NULL,int unitGroupCommandId=-1) const;
|
||||||
CommandResult tryGiveCommand(const Selection *selection, CommandClass commandClass, const Vec2i &pos= Vec2i(0), const Unit *targetUnit= NULL, bool tryQueue = false) const;
|
std::pair<CommandResult,string> tryGiveCommand(const Selection *selection, CommandClass commandClass, const Vec2i &pos= Vec2i(0), const Unit *targetUnit= NULL, bool tryQueue = false) const;
|
||||||
CommandResult tryGiveCommand(const Selection *selection, const CommandType *commandType, const Vec2i &pos= Vec2i(0), const Unit *targetUnit= NULL, bool tryQueue = false) const;
|
std::pair<CommandResult,string> tryGiveCommand(const Selection *selection, const CommandType *commandType, const Vec2i &pos= Vec2i(0), const Unit *targetUnit= NULL, bool tryQueue = false) const;
|
||||||
CommandResult tryGiveCommand(const Selection *selection, const Vec2i &pos, const Unit *targetUnit= NULL, bool tryQueue = false, int unitCommandGroupId = -1) const;
|
std::pair<CommandResult,string> tryGiveCommand(const Selection *selection, const Vec2i &pos, const Unit *targetUnit= NULL, bool tryQueue = false, int unitCommandGroupId = -1) const;
|
||||||
CommandResult tryCancelCommand(const Selection *selection) const;
|
CommandResult tryCancelCommand(const Selection *selection) const;
|
||||||
void trySetMeetingPoint(const Unit* unit, const Vec2i &pos) const;
|
void trySetMeetingPoint(const Unit* unit, const Vec2i &pos) const;
|
||||||
void trySwitchTeam(const Faction* faction, int teamIndex) const;
|
void trySwitchTeam(const Faction* faction, int teamIndex) const;
|
||||||
|
@ -120,10 +120,10 @@ public:
|
||||||
Command* buildCommand(const NetworkCommand* networkCommand) const;
|
Command* buildCommand(const NetworkCommand* networkCommand) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CommandResult pushNetworkCommand(const NetworkCommand* networkCommand) const;
|
std::pair<CommandResult,string> pushNetworkCommand(const NetworkCommand* networkCommand) const;
|
||||||
//void giveNetworkCommandSpecial(const NetworkCommand* networkCommand) const;
|
//void giveNetworkCommandSpecial(const NetworkCommand* networkCommand) const;
|
||||||
|
|
||||||
CommandResult computeResult(const CommandResultContainer &results) const;
|
std::pair<CommandResult,string> computeResult(const CommandResultContainer &results) const;
|
||||||
void giveNetworkCommand(NetworkCommand* networkCommand) const;
|
void giveNetworkCommand(NetworkCommand* networkCommand) const;
|
||||||
|
|
||||||
virtual void commanderNetworkUpdateTask(int id);
|
virtual void commanderNetworkUpdateTask(int id);
|
||||||
|
|
|
@ -58,6 +58,15 @@ void Console::addStdMessage(const string &s,bool clearOtherLines) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Console::addStdMessage(const string &s,string failText, bool clearOtherLines) {
|
||||||
|
if(clearOtherLines == true) {
|
||||||
|
addLineOnly(Lang::getInstance().get(s) + failText);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
addLine(Lang::getInstance().get(s) + failText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Console::addStdScenarioMessage(const string &s,bool clearOtherLines) {
|
void Console::addStdScenarioMessage(const string &s,bool clearOtherLines) {
|
||||||
if(clearOtherLines == true) {
|
if(clearOtherLines == true) {
|
||||||
addLineOnly(Lang::getInstance().getScenarioString(s));
|
addLineOnly(Lang::getInstance().getScenarioString(s));
|
||||||
|
|
|
@ -107,6 +107,8 @@ public:
|
||||||
|
|
||||||
void clearStoredLines();
|
void clearStoredLines();
|
||||||
void addStdMessage(const string &s, bool clearOtherLines=false);
|
void addStdMessage(const string &s, bool clearOtherLines=false);
|
||||||
|
void addStdMessage(const string &s, string failText, bool clearOtherLines=false);
|
||||||
|
|
||||||
void addStdScenarioMessage(const string &s,bool clearOtherLines=false);
|
void addStdScenarioMessage(const string &s,bool clearOtherLines=false);
|
||||||
void addLineOnly(string line);
|
void addLineOnly(string line);
|
||||||
void addLine(string line, bool playSound= false,int playerIndex=-1,Vec3f textColor=Vec3f(1.f, 1.f, 1.f),bool teamMode=false,bool clearOtherLines=false);
|
void addLine(string line, bool playSound= false,int playerIndex=-1,Vec3f textColor=Vec3f(1.f, 1.f, 1.f),bool teamMode=false,bool clearOtherLines=false);
|
||||||
|
|
|
@ -423,7 +423,7 @@ void Gui::onSelectionChanged(){
|
||||||
void Gui::giveOneClickOrders(){
|
void Gui::giveOneClickOrders(){
|
||||||
//printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
CommandResult result;
|
std::pair<CommandResult,string> result(crFailUndefined,"");
|
||||||
bool queueKeyDown = isKeyDown(queueCommandKey);
|
bool queueKeyDown = isKeyDown(queueCommandKey);
|
||||||
if(selection.isUniform()){
|
if(selection.isUniform()){
|
||||||
result= commander->tryGiveCommand(&selection, activeCommandType, Vec2i(0), (Unit*)NULL, queueKeyDown);
|
result= commander->tryGiveCommand(&selection, activeCommandType, Vec2i(0), (Unit*)NULL, queueKeyDown);
|
||||||
|
@ -458,11 +458,11 @@ void Gui::giveDefaultOrders(int x, int y,const Unit *targetUnit, bool paintMouse
|
||||||
bool queueKeyDown = isKeyDown(queueCommandKey);
|
bool queueKeyDown = isKeyDown(queueCommandKey);
|
||||||
Vec2i targetPos=Vec2i(x, y);
|
Vec2i targetPos=Vec2i(x, y);
|
||||||
//give order
|
//give order
|
||||||
CommandResult result= commander->tryGiveCommand(&selection, targetPos, targetUnit, queueKeyDown);
|
std::pair<CommandResult,string> result= commander->tryGiveCommand(&selection, targetPos, targetUnit, queueKeyDown);
|
||||||
|
|
||||||
//graphical result
|
//graphical result
|
||||||
addOrdersResultToConsole(activeCommandClass, result);
|
addOrdersResultToConsole(activeCommandClass, result);
|
||||||
if(result == crSuccess || result == crSomeFailed) {
|
if(result.first == crSuccess || result.first == crSomeFailed) {
|
||||||
if(paintMouse3d)
|
if(paintMouse3d)
|
||||||
mouse3d.enable();
|
mouse3d.enable();
|
||||||
|
|
||||||
|
@ -480,7 +480,7 @@ void Gui::giveDefaultOrders(int x, int y,const Unit *targetUnit, bool paintMouse
|
||||||
|
|
||||||
void Gui::giveTwoClickOrders(int x, int y , bool prepared) {
|
void Gui::giveTwoClickOrders(int x, int y , bool prepared) {
|
||||||
//printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
CommandResult result;
|
std::pair<CommandResult,string> result(crFailUndefined,"");
|
||||||
|
|
||||||
//compute target
|
//compute target
|
||||||
const Unit *targetUnit= NULL;
|
const Unit *targetUnit= NULL;
|
||||||
|
@ -516,7 +516,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.first == crSuccess || result.first == crSomeFailed) {
|
||||||
if(prepared == false) {
|
if(prepared == false) {
|
||||||
mouse3d.enable();
|
mouse3d.enable();
|
||||||
}
|
}
|
||||||
|
@ -950,24 +950,24 @@ int Gui::computePosDisplay(int x, int y){
|
||||||
return posDisplay;
|
return posDisplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gui::addOrdersResultToConsole(CommandClass cc, CommandResult result){
|
void Gui::addOrdersResultToConsole(CommandClass cc, std::pair<CommandResult,string> result) {
|
||||||
|
|
||||||
switch(result){
|
switch(result.first) {
|
||||||
case crSuccess:
|
case crSuccess:
|
||||||
break;
|
break;
|
||||||
case crFailReqs:
|
case crFailReqs:
|
||||||
switch(cc){
|
switch(cc){
|
||||||
case ccBuild:
|
case ccBuild:
|
||||||
console->addStdMessage("BuildingNoReqs");
|
console->addStdMessage("BuildingNoReqs",result.second);
|
||||||
break;
|
break;
|
||||||
case ccProduce:
|
case ccProduce:
|
||||||
console->addStdMessage("UnitNoReqs");
|
console->addStdMessage("UnitNoReqs",result.second);
|
||||||
break;
|
break;
|
||||||
case ccMorph:
|
case ccMorph:
|
||||||
console->addStdMessage("MorphNoReqs");
|
console->addStdMessage("MorphNoReqs",result.second);
|
||||||
break;
|
break;
|
||||||
case ccUpgrade:
|
case ccUpgrade:
|
||||||
console->addStdMessage("UpgradeNoReqs");
|
console->addStdMessage("UpgradeNoReqs",result.second);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -976,16 +976,16 @@ void Gui::addOrdersResultToConsole(CommandClass cc, CommandResult result){
|
||||||
case crFailRes:
|
case crFailRes:
|
||||||
switch(cc){
|
switch(cc){
|
||||||
case ccBuild:
|
case ccBuild:
|
||||||
console->addStdMessage("BuildingNoRes");
|
console->addStdMessage("BuildingNoRes",result.second);
|
||||||
break;
|
break;
|
||||||
case ccProduce:
|
case ccProduce:
|
||||||
console->addStdMessage("UnitNoRes");
|
console->addStdMessage("UnitNoRes",result.second);
|
||||||
break;
|
break;
|
||||||
case ccMorph:
|
case ccMorph:
|
||||||
console->addStdMessage("MorphNoRes");
|
console->addStdMessage("MorphNoRes",result.second);
|
||||||
break;
|
break;
|
||||||
case ccUpgrade:
|
case ccUpgrade:
|
||||||
console->addStdMessage("UpgradeNoRes");
|
console->addStdMessage("UpgradeNoRes",result.second);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -993,11 +993,11 @@ void Gui::addOrdersResultToConsole(CommandClass cc, CommandResult result){
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case crFailUndefined:
|
case crFailUndefined:
|
||||||
console->addStdMessage("InvalidOrder");
|
console->addStdMessage("InvalidOrder",result.second);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case crSomeFailed:
|
case crSomeFailed:
|
||||||
console->addStdMessage("SomeOrdersFailed");
|
console->addStdMessage("SomeOrdersFailed",result.second);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,7 +226,7 @@ private:
|
||||||
void mouseDownDisplayUnitBuild(int posDisplay);
|
void mouseDownDisplayUnitBuild(int posDisplay);
|
||||||
void computeInfoString(int posDisplay);
|
void computeInfoString(int posDisplay);
|
||||||
string computeDefaultInfoString();
|
string computeDefaultInfoString();
|
||||||
void addOrdersResultToConsole(CommandClass cc, CommandResult rr);
|
void addOrdersResultToConsole(CommandClass cc, std::pair<CommandResult,string> result);
|
||||||
bool isSharedCommandClass(CommandClass commandClass);
|
bool isSharedCommandClass(CommandClass commandClass);
|
||||||
void computeSelected(bool doubleCkick,bool force);
|
void computeSelected(bool doubleCkick,bool force);
|
||||||
bool computeTarget(const Vec2i &screenPos, Vec2i &targetPos, const Unit *&targetUnit);
|
bool computeTarget(const Vec2i &screenPos, Vec2i &targetPos, const Unit *&targetUnit);
|
||||||
|
|
|
@ -1357,9 +1357,10 @@ int Unit::getCountOfProducedUnits(const UnitType *ut) const{
|
||||||
}
|
}
|
||||||
|
|
||||||
//give one command (clear, and push back)
|
//give one command (clear, and push back)
|
||||||
CommandResult Unit::giveCommand(Command *command, bool tryQueue) {
|
std::pair<CommandResult,string> Unit::giveCommand(Command *command, bool tryQueue) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"\n======================\nUnit Command tryQueue = %d\nUnit Info:\n%s\nCommand Info:\n%s\n",tryQueue,this->toString().c_str(),command->toString().c_str());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"\n======================\nUnit Command tryQueue = %d\nUnit Info:\n%s\nCommand Info:\n%s\n",tryQueue,this->toString().c_str(),command->toString().c_str());
|
||||||
|
|
||||||
|
std::pair<CommandResult,string> result(crFailUndefined,"");
|
||||||
changedActiveCommand = false;
|
changedActiveCommand = false;
|
||||||
|
|
||||||
Chrono chrono;
|
Chrono chrono;
|
||||||
|
@ -1457,21 +1458,21 @@ CommandResult Unit::giveCommand(Command *command, bool tryQueue) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
|
||||||
//check command
|
//check command
|
||||||
CommandResult result= checkCommand(command);
|
result= checkCommand(command);
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] checkCommand returned: [%d]\n",__FILE__,__FUNCTION__,__LINE__,result);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] checkCommand returned: [%d]\n",__FILE__,__FUNCTION__,__LINE__,result.first);
|
||||||
|
|
||||||
//printf("In [%s::%s] Line: %d check command returned %d, commands.size() = %d\n[%s]\n\n",__FILE__,__FUNCTION__,__LINE__,result,commands.size(),command->toString().c_str());
|
//printf("In [%s::%s] Line: %d check command returned %d, commands.size() = %d\n[%s]\n\n",__FILE__,__FUNCTION__,__LINE__,result,commands.size(),command->toString().c_str());
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
|
||||||
if(result == crSuccess) {
|
if(result.first == crSuccess) {
|
||||||
applyCommand(command);
|
applyCommand(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
|
||||||
//push back command
|
//push back command
|
||||||
if(result == crSuccess) {
|
if(result.first == crSuccess) {
|
||||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||||
MutexSafeWrapper safeMutex(mutexCommands,mutexOwnerId);
|
MutexSafeWrapper safeMutex(mutexCommands,mutexOwnerId);
|
||||||
|
|
||||||
|
@ -2811,7 +2812,9 @@ void Unit::deleteQueuedCommand(Command *command) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CommandResult Unit::checkCommand(Command *command) const {
|
std::pair<CommandResult,string> Unit::checkCommand(Command *command) const {
|
||||||
|
std::pair<CommandResult,string> result(crSuccess,"");
|
||||||
|
|
||||||
if(command == NULL) {
|
if(command == NULL) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
snprintf(szBuf,8096,"In [%s::%s Line: %d] ERROR: command == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
|
snprintf(szBuf,8096,"In [%s::%s Line: %d] ERROR: command == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
|
||||||
|
@ -2832,14 +2835,16 @@ CommandResult Unit::checkCommand(Command *command) const {
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return crFailUndefined;
|
result.first = crFailUndefined;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//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()) == false) {
|
if(map->isInside(command->getPos()) == false) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__, __LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__, __LINE__);
|
||||||
return crFailUndefined;
|
result.first = crFailUndefined;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//check produced
|
//check produced
|
||||||
|
@ -2852,12 +2857,21 @@ CommandResult Unit::checkCommand(Command *command) const {
|
||||||
const ProducibleType *produced= command->getCommandType()->getProduced();
|
const ProducibleType *produced= command->getCommandType()->getProduced();
|
||||||
if(produced != NULL) {
|
if(produced != NULL) {
|
||||||
if(ignoreCheckCommand == false && faction->reqsOk(produced) == false) {
|
if(ignoreCheckCommand == false && faction->reqsOk(produced) == false) {
|
||||||
return crFailReqs;
|
//printf("To produce this unit you need:\n%s\n",produced->getUnitAndUpgradeReqDesc().c_str());
|
||||||
|
result.first = crFailReqs;
|
||||||
|
|
||||||
|
Lang &lang= Lang::getInstance();
|
||||||
|
result.second = " - " + lang.get("Reqs") + " : " + produced->getUnitAndUpgradeReqDesc(false);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ignoreCheckCommand == false &&
|
if(ignoreCheckCommand == false &&
|
||||||
faction->checkCosts(produced,command->getCommandType()) == false) {
|
faction->checkCosts(produced,command->getCommandType()) == false) {
|
||||||
return crFailRes;
|
//printf("To produce this unit you need:\n%s\n",produced->getResourceReqDesc().c_str());
|
||||||
|
result.first = crFailRes;
|
||||||
|
Lang &lang= Lang::getInstance();
|
||||||
|
result.second = " - " + lang.get("Reqs") + " : " + produced->getResourceReqDesc(false);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2872,10 +2886,18 @@ CommandResult Unit::checkCommand(Command *command) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(faction->reqsOk(builtUnit) == false) {
|
if(faction->reqsOk(builtUnit) == false) {
|
||||||
return crFailReqs;
|
//printf("To build this unit you need:\n%s\n",builtUnit->getUnitAndUpgradeReqDesc().c_str());
|
||||||
|
result.first = crFailReqs;
|
||||||
|
Lang &lang= Lang::getInstance();
|
||||||
|
result.second = " - " + lang.get("Reqs") + " : " + builtUnit->getUnitAndUpgradeReqDesc(false);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
if(faction->checkCosts(builtUnit,NULL) == false) {
|
if(faction->checkCosts(builtUnit,NULL) == false) {
|
||||||
return crFailRes;
|
//printf("To build this unit you need:\n%s\n",builtUnit->getResourceReqDesc().c_str());
|
||||||
|
result.first = crFailRes;
|
||||||
|
Lang &lang= Lang::getInstance();
|
||||||
|
result.second = " - " + lang.get("Reqs") + " : " + builtUnit->getResourceReqDesc(false);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//upgrade command specific, check that upgrade is not upgraded
|
//upgrade command specific, check that upgrade is not upgraded
|
||||||
|
@ -2890,11 +2912,12 @@ CommandResult Unit::checkCommand(Command *command) const {
|
||||||
|
|
||||||
if(faction->getUpgradeManager()->isUpgradingOrUpgraded(uct->getProducedUpgrade())){
|
if(faction->getUpgradeManager()->isUpgradingOrUpgraded(uct->getProducedUpgrade())){
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__, __LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__, __LINE__);
|
||||||
return crFailUndefined;
|
result.first = crFailUndefined;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return crSuccess;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unit::applyCommand(Command *command){
|
void Unit::applyCommand(Command *command){
|
||||||
|
|
|
@ -597,7 +597,7 @@ public:
|
||||||
void replaceCurrCommand(Command *cmd);
|
void replaceCurrCommand(Command *cmd);
|
||||||
int getCountOfProducedUnits(const UnitType *ut) const;
|
int getCountOfProducedUnits(const UnitType *ut) const;
|
||||||
unsigned int getCommandSize() const;
|
unsigned int getCommandSize() const;
|
||||||
CommandResult giveCommand(Command *command, bool tryQueue = false); //give a command
|
std::pair<CommandResult,string> giveCommand(Command *command, bool tryQueue = false); //give a command
|
||||||
CommandResult finishCommand(); //command finished
|
CommandResult finishCommand(); //command finished
|
||||||
CommandResult cancelCommand(); //cancel canceled
|
CommandResult cancelCommand(); //cancel canceled
|
||||||
|
|
||||||
|
@ -633,7 +633,7 @@ public:
|
||||||
void computeTotalUpgrade();
|
void computeTotalUpgrade();
|
||||||
void incKills(int team);
|
void incKills(int team);
|
||||||
bool morph(const MorphCommandType *mct);
|
bool morph(const MorphCommandType *mct);
|
||||||
CommandResult checkCommand(Command *command) const;
|
std::pair<CommandResult,string> checkCommand(Command *command) const;
|
||||||
void applyCommand(Command *command);
|
void applyCommand(Command *command);
|
||||||
|
|
||||||
void setModelFacing(CardinalDir value);
|
void setModelFacing(CardinalDir value);
|
||||||
|
|
|
@ -124,31 +124,60 @@ const Resource *ProducibleType::getCost(const ResourceType *rt) const{
|
||||||
string ProducibleType::getReqDesc() const {
|
string ProducibleType::getReqDesc() const {
|
||||||
return getReqDesc(false);
|
return getReqDesc(false);
|
||||||
}
|
}
|
||||||
string ProducibleType::getReqDesc(bool ignoreResourceRequirements) const {
|
|
||||||
string str= getName(true) + " " + Lang::getInstance().get("Reqs") + ":\n";
|
string ProducibleType::getResourceReqDesc(bool lineBreaks) const {
|
||||||
if(ignoreResourceRequirements == false) {
|
string str= "";
|
||||||
for(int i=0; i<getCostCount(); ++i){
|
for(int i=0; i<getCostCount(); ++i){
|
||||||
if(getCost(i)->getAmount()!=0){
|
if(getCost(i)->getAmount()!=0){
|
||||||
str+= getCost(i)->getType()->getName(true);
|
str+= getCost(i)->getType()->getName(true);
|
||||||
str+= ": "+ intToStr(getCost(i)->getAmount());
|
str+= ": "+ intToStr(getCost(i)->getAmount());
|
||||||
|
if(lineBreaks == true) {
|
||||||
str+= "\n";
|
str+= "\n";
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
str+= " ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
string ProducibleType::getUnitAndUpgradeReqDesc(bool lineBreaks) const {
|
||||||
|
string str= "";
|
||||||
for(int i=0; i<getUnitReqCount(); ++i){
|
for(int i=0; i<getUnitReqCount(); ++i){
|
||||||
str+= getUnitReq(i)->getName(true);
|
str+= getUnitReq(i)->getName(true);
|
||||||
str+= "\n";
|
if(lineBreaks == true) {
|
||||||
|
str+= "\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
str+= " ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i=0; i<getUpgradeReqCount(); ++i){
|
for(int i=0; i<getUpgradeReqCount(); ++i){
|
||||||
str+= getUpgradeReq(i)->getName(true);
|
str+= getUpgradeReq(i)->getName(true);
|
||||||
str+= "\n";
|
if(lineBreaks == true) {
|
||||||
|
str+= "\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
str+= " ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string ProducibleType::getReqDesc(bool ignoreResourceRequirements) const {
|
||||||
|
string str= getName(true) + " " + Lang::getInstance().get("Reqs") + ":\n";
|
||||||
|
if(ignoreResourceRequirements == false) {
|
||||||
|
str+= getResourceReqDesc();
|
||||||
|
}
|
||||||
|
|
||||||
|
str+= getUnitAndUpgradeReqDesc();
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
//void ProducibleType::saveGame(XmlNode *rootNode) const {
|
//void ProducibleType::saveGame(XmlNode *rootNode) const {
|
||||||
// RequirableType::saveGame(rootNode);
|
// RequirableType::saveGame(rootNode);
|
||||||
//
|
//
|
||||||
|
|
|
@ -119,6 +119,8 @@ public:
|
||||||
void checkCostStrings(TechTree *techTree);
|
void checkCostStrings(TechTree *techTree);
|
||||||
|
|
||||||
virtual string getReqDesc() const;
|
virtual string getReqDesc() const;
|
||||||
|
string getResourceReqDesc(bool lineBreaks=true) const;
|
||||||
|
string getUnitAndUpgradeReqDesc(bool lineBreaks=true) const;
|
||||||
string getReqDesc(bool ignoreResourceRequirements) const;
|
string getReqDesc(bool ignoreResourceRequirements) const;
|
||||||
|
|
||||||
// virtual void saveGame(XmlNode *rootNode) const;
|
// virtual void saveGame(XmlNode *rootNode) const;
|
||||||
|
|
|
@ -1499,8 +1499,8 @@ void UnitUpdater::updateRepair(Unit *unit, int frameIndex) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
Command* command= this->game->getCommander()->buildCommand(&networkCommand);
|
Command* command= this->game->getCommander()->buildCommand(&networkCommand);
|
||||||
CommandResult cr= unit->checkCommand(command);
|
std::pair<CommandResult,string> cr= unit->checkCommand(command);
|
||||||
if(cr == crSuccess) {
|
if(cr.first == crSuccess) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
unit->replaceCurrCommand(command);
|
unit->replaceCurrCommand(command);
|
||||||
}
|
}
|
||||||
|
|
|
@ -869,7 +869,7 @@ void World::morphToUnit(int unitId,const string &morphName,bool ignoreRequiremen
|
||||||
if(mct != NULL && mct->getName() == morphName) {
|
if(mct != NULL && mct->getName() == morphName) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] unit [%d] morphName [%s] comparing mct [%s]\n",__FILE__,__FUNCTION__,__LINE__,unitId,morphName.c_str(),mct->getName().c_str());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] unit [%d] morphName [%s] comparing mct [%s]\n",__FILE__,__FUNCTION__,__LINE__,unitId,morphName.c_str(),mct->getName().c_str());
|
||||||
|
|
||||||
CommandResult cr = crFailUndefined;
|
std::pair<CommandResult,string> cr(crFailUndefined,"");
|
||||||
try {
|
try {
|
||||||
if(unit->getFaction()->reqsOk(mct) == false && ignoreRequirements == true) {
|
if(unit->getFaction()->reqsOk(mct) == false && ignoreRequirements == true) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] unit [%d] morphName [%s] comparing mct [%s] mct->getUpgradeReqCount() = %d\n",__FILE__,__FUNCTION__,__LINE__,unitId,morphName.c_str(),mct->getName().c_str(),mct->getUpgradeReqCount());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] unit [%d] morphName [%s] comparing mct [%s] mct->getUpgradeReqCount() = %d\n",__FILE__,__FUNCTION__,__LINE__,unitId,morphName.c_str(),mct->getName().c_str(),mct->getUpgradeReqCount());
|
||||||
|
@ -886,14 +886,14 @@ void World::morphToUnit(int unitId,const string &morphName,bool ignoreRequiremen
|
||||||
throw megaglest_runtime_error(ex.what());
|
throw megaglest_runtime_error(ex.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cr == crSuccess) {
|
if(cr.first == crSuccess) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] unit [%d] morphName [%s] comparing mct [%s] returned = %d\n",__FILE__,__FUNCTION__,__LINE__,unitId,morphName.c_str(),mct->getName().c_str(),cr);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] unit [%d] morphName [%s] comparing mct [%s] returned = %d\n",__FILE__,__FUNCTION__,__LINE__,unitId,morphName.c_str(),mct->getName().c_str(),cr.first);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue