full support for translated techtrees

This commit is contained in:
Mark Vejvoda 2013-06-13 08:55:48 +00:00
parent 1f96dae8c7
commit 0ead6a36dc
36 changed files with 326 additions and 301 deletions

View File

@ -66,7 +66,7 @@ ProduceTask::ProduceTask(const ResourceType *resourceType) : Task() {
string ProduceTask::toString() const{
string str= "Produce ";
if(unitType!=NULL){
str+= unitType->getName(true);
str+= unitType->getName(false);
}
return str;
}
@ -81,11 +81,11 @@ void ProduceTask::saveGame(XmlNode *rootNode) const {
produceTaskNode->addAttribute("unitClass",intToStr(unitClass), mapTagReplacements);
// const UnitType *unitType;
if(unitType != NULL) {
produceTaskNode->addAttribute("unitType",unitType->getName(), mapTagReplacements);
produceTaskNode->addAttribute("unitType",unitType->getName(false), mapTagReplacements);
}
// const ResourceType *resourceType;
if(resourceType != NULL) {
produceTaskNode->addAttribute("resourceType",resourceType->getName(), mapTagReplacements);
produceTaskNode->addAttribute("resourceType",resourceType->getName(false), mapTagReplacements);
}
}
@ -144,7 +144,7 @@ BuildTask::BuildTask(const UnitType *unitType, const Vec2i &pos){
string BuildTask::toString() const{
string str= "Build ";
if(unitType!=NULL){
str+= unitType->getName(true);
str+= unitType->getName(false);
}
return str;
}
@ -157,7 +157,7 @@ void BuildTask::saveGame(XmlNode *rootNode) const {
// const UnitType *unitType;
if(unitType != NULL) {
buildTaskNode->addAttribute("unitType",unitType->getName(), mapTagReplacements);
buildTaskNode->addAttribute("unitType",unitType->getName(false), mapTagReplacements);
}
// const ResourceType *resourceType;
if(resourceType != NULL) {
@ -487,7 +487,7 @@ const ResourceType *Ai::getNeededResource(int unitIndex) {
}
char szBuf[8096]="";
snprintf(szBuf,8096,"Unit [%d - %s] looking for resources (not static or consumable)",unit->getId(),unit->getType()->getName().c_str());
snprintf(szBuf,8096,"Unit [%d - %s] looking for resources (not static or consumable)",unit->getId(),unit->getType()->getName(false).c_str());
aiInterface->printLog(3, szBuf);
snprintf(szBuf,8096,"[resource type count %d] Needed resource [%s].",tt->getResourceTypeCount(),(neededResource != NULL ? neededResource->getName().c_str() : "<none>"));
aiInterface->printLog(3, szBuf);

View File

@ -398,7 +398,7 @@ std::pair<CommandResult,string> AiInterface::giveCommand(const Unit *unit, const
char szBuf[8096]="";
snprintf(szBuf,8096,"In [%s::%s Line: %d]\nCan not find AI command type for:\nunit = %d\n[%s]\n[%s]\nactual local factionIndex = %d.\nGame out of synch.",
__FILE__,__FUNCTION__,__LINE__,
unit->getId(), unit->getFullName().c_str(),unit->getDesc().c_str(),
unit->getId(), unit->getFullName(false).c_str(),unit->getDesc(false).c_str(),
unit->getFaction()->getIndex());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n",szBuf);
@ -448,7 +448,7 @@ std::pair<CommandResult,string> AiInterface::giveCommand(int unitIndex, const Co
char szBuf[8096]="";
snprintf(szBuf,8096,"In [%s::%s Line: %d]\nCan not find AI command type for:\nunit = %d\n[%s]\n[%s]\nactual local factionIndex = %d.\nGame out of synch.",
__FILE__,__FUNCTION__,__LINE__,
unit->getId(), unit->getFullName().c_str(),unit->getDesc().c_str(),
unit->getId(), unit->getFullName(false).c_str(),unit->getDesc(false).c_str(),
unit->getFaction()->getIndex());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n",szBuf);
@ -496,7 +496,7 @@ std::pair<CommandResult,string> AiInterface::giveCommand(int unitIndex, const Co
char szBuf[8096]="";
snprintf(szBuf,8096,"In [%s::%s Line: %d]\nCan not find AI command type for:\nunit = %d\n[%s]\n[%s]\nactual local factionIndex = %d.\nGame out of synch.",
__FILE__,__FUNCTION__,__LINE__,
unit->getId(), unit->getFullName().c_str(),unit->getDesc().c_str(),
unit->getId(), unit->getFullName(false).c_str(),unit->getDesc(false).c_str(),
unit->getFaction()->getIndex());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n",szBuf);
@ -544,7 +544,7 @@ std::pair<CommandResult,string> AiInterface::giveCommand(int unitIndex, const Co
char szBuf[8096]="";
snprintf(szBuf,8096,"In [%s::%s Line: %d]\nCan not find AI command type for:\nunit = %d\n[%s]\n[%s]\nactual local factionIndex = %d.\nGame out of synch.",
__FILE__,__FUNCTION__,__LINE__,
unit->getId(), unit->getFullName().c_str(),unit->getDesc().c_str(),
unit->getId(), unit->getFullName(false).c_str(),unit->getDesc(false).c_str(),
unit->getFaction()->getIndex());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n",szBuf);

View File

@ -667,10 +667,10 @@ void AiRuleProduce::execute() {
AiInterface *aiInterface= ai->getAiInterface();
if(produceTask!=NULL) {
if(ai->outputAIBehaviourToConsole()) printf("AiRuleProduce producing [%s]\n",(produceTask->getUnitType() != NULL ? produceTask->getUnitType()->getName().c_str() : "null"));
if(ai->outputAIBehaviourToConsole()) printf("AiRuleProduce producing [%s]\n",(produceTask->getUnitType() != NULL ? produceTask->getUnitType()->getName(false).c_str() : "null"));
if(aiInterface->isLogLevelEnabled(4) == true) {
char szBuf[8096]="";
snprintf(szBuf,8096,"AiRuleProduce producing [%s]",(produceTask->getUnitType() != NULL ? produceTask->getUnitType()->getName().c_str() : "null"));
snprintf(szBuf,8096,"AiRuleProduce producing [%s]",(produceTask->getUnitType() != NULL ? produceTask->getUnitType()->getName(false).c_str() : "null"));
aiInterface->printLog(4, szBuf);
}
@ -761,7 +761,7 @@ void AiRuleProduce::produceGeneric(const ProduceTask *pt) {
const Resource *r= producedUnit->getCost(pt->getResourceType());
if(r != NULL) {
if(ai->outputAIBehaviourToConsole()) printf("produceGeneric r = [%s][%d] Testing AI RULE Name[%s]\n",r->getDescription().c_str(),r->getAmount(), this->getName().c_str());
if(ai->outputAIBehaviourToConsole()) printf("produceGeneric r = [%s][%d] Testing AI RULE Name[%s]\n",r->getDescription(false).c_str(),r->getAmount(), this->getName().c_str());
}
if(r != NULL && r->getAmount() < 0) {
@ -1196,7 +1196,7 @@ bool AiRuleBuild::test(){
void AiRuleBuild::execute() {
if(buildTask!=NULL) {
if(ai->outputAIBehaviourToConsole()) printf("BUILD AiRuleBuild Unit Name[%s]\n",(buildTask->getUnitType() != NULL ? buildTask->getUnitType()->getName().c_str() : "null"));
if(ai->outputAIBehaviourToConsole()) printf("BUILD AiRuleBuild Unit Name[%s]\n",(buildTask->getUnitType() != NULL ? buildTask->getUnitType()->getName(false).c_str() : "null"));
//generic build task, build random building that can be built
if(buildTask->getUnitType() == NULL) {
@ -1457,7 +1457,7 @@ void AiRuleBuild::buildSpecific(const BuildTask *bt) {
}
bool AiRuleBuild::isDefensive(const UnitType *building){
if(ai->outputAIBehaviourToConsole()) printf("BUILD isDefensive check for Unit Name[%s] result = %d\n",building->getName().c_str(),building->hasSkillClass(scAttack));
if(ai->outputAIBehaviourToConsole()) printf("BUILD isDefensive check for Unit Name[%s] result = %d\n",building->getName(false).c_str(),building->hasSkillClass(scAttack));
return building->hasSkillClass(scAttack);
}
@ -1465,12 +1465,12 @@ bool AiRuleBuild::isDefensive(const UnitType *building){
bool AiRuleBuild::isResourceProducer(const UnitType *building){
for(int i= 0; i<building->getCostCount(); i++){
if(building->getCost(i)->getAmount()<0){
if(ai->outputAIBehaviourToConsole()) printf("BUILD isResourceProducer check for Unit Name[%s] result = true\n",building->getName().c_str());
if(ai->outputAIBehaviourToConsole()) printf("BUILD isResourceProducer check for Unit Name[%s] result = true\n",building->getName(false).c_str());
return true;
}
}
if(ai->outputAIBehaviourToConsole()) printf("BUILD isResourceProducer check for Unit Name[%s] result = false\n",building->getName().c_str());
if(ai->outputAIBehaviourToConsole()) printf("BUILD isResourceProducer check for Unit Name[%s] result = false\n",building->getName(false).c_str());
return false;
}
@ -1482,13 +1482,13 @@ bool AiRuleBuild::isWarriorProducer(const UnitType *building){
const UnitType *ut= static_cast<const ProduceCommandType*>(ct)->getProducedUnit();
if(ut->isOfClass(ucWarrior)){
if(ai->outputAIBehaviourToConsole()) printf("BUILD isWarriorProducer check for Unit Name[%s] result = true\n",building->getName().c_str());
if(ai->outputAIBehaviourToConsole()) printf("BUILD isWarriorProducer check for Unit Name[%s] result = true\n",building->getName(false).c_str());
return true;
}
}
}
if(ai->outputAIBehaviourToConsole()) printf("BUILD isWarriorProducer check for Unit Name[%s] result = false\n",building->getName().c_str());
if(ai->outputAIBehaviourToConsole()) printf("BUILD isWarriorProducer check for Unit Name[%s] result = false\n",building->getName(false).c_str());
return false;
}

View File

@ -312,7 +312,7 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
if(unit->getUsePathfinderExtendedMaxNodes() == true) {
const bool showConsoleDebugInfo = Config::getInstance().getBool("EnablePathfinderDistanceOutput","false");
if(showConsoleDebugInfo || SystemFlags::VERBOSE_MODE_ENABLED) {
printf("\n\n\n\n### Continued call to AStar with LARGE maxnodes for unit [%d - %s]\n\n",unit->getId(),unit->getFullName().c_str());
printf("\n\n\n\n### Continued call to AStar with LARGE maxnodes for unit [%d - %s]\n\n",unit->getId(),unit->getFullName(false).c_str());
}
maxNodeCount= PathFinder::pathFindNodesAbsoluteMax;
@ -339,7 +339,7 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
uint32 searched_node_count = 0;
minorDebugPathfinder = false;
if(minorDebugPathfinder) printf("Legacy Pathfind Unit [%d - %s] from = %s to = %s frameIndex = %d\n",unit->getId(),unit->getType()->getName().c_str(),unit->getPos().getString().c_str(),finalPos.getString().c_str(),frameIndex);
if(minorDebugPathfinder) printf("Legacy Pathfind Unit [%d - %s] from = %s to = %s frameIndex = %d\n",unit->getId(),unit->getType()->getName(false).c_str(),unit->getPos().getString().c_str(),finalPos.getString().c_str(),frameIndex);
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0) {
char szBuf[8096]="";
@ -370,7 +370,7 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
path->isStuck() == true) {
//printf("$$$$ Unit START BAILOUT ATTEMPT for [%d - %s]\n",unit->getId(),unit->getFullName().c_str());
if(minorDebugPathfinder) printf("Pathfind Unit [%d - %s] START BAILOUT ATTEMPT frameIndex = %d\n",unit->getId(),unit->getType()->getName().c_str(),frameIndex);
if(minorDebugPathfinder) printf("Pathfind Unit [%d - %s] START BAILOUT ATTEMPT frameIndex = %d\n",unit->getId(),unit->getType()->getName(false).c_str(),frameIndex);
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0) {
char szBuf[8096]="";
@ -411,7 +411,7 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
if(showConsoleDebugInfo && unitImmediatelyBlocked) {
printf("**Check if src blocked [%d], unit [%d - %s] from [%s] to [%s] unitImmediatelyBlocked = %d, failureCount = %d [%d]\n",
unitImmediatelyBlocked, unit->getId(),unit->getFullName().c_str(), unitPos.getString().c_str(), finalPos.getString().c_str(), unitImmediatelyBlocked,failureCount,cellCount);
unitImmediatelyBlocked, unit->getId(),unit->getFullName(false).c_str(), unitPos.getString().c_str(), finalPos.getString().c_str(), unitImmediatelyBlocked,failureCount,cellCount);
}
if(unitImmediatelyBlocked == false) {
@ -521,7 +521,7 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
unit->setCurrSkill(scStop);
}
if(minorDebugPathfinderPerformance && chrono.getMillis() >= 1) printf("Unit [%d - %s] astar #2 took [%lld] msecs, ts = %d searched_node_count = %d.\n",unit->getId(),unit->getType()->getName().c_str(),(long long int)chrono.getMillis(),ts,searched_node_count);
if(minorDebugPathfinderPerformance && chrono.getMillis() >= 1) printf("Unit [%d - %s] astar #2 took [%lld] msecs, ts = %d searched_node_count = %d.\n",unit->getId(),unit->getType()->getName(false).c_str(),(long long int)chrono.getMillis(),ts,searched_node_count);
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0) {
char szBuf[8096]="";
@ -546,9 +546,9 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
unit->setCurrSkill(scStop);
}
if(minorDebugPathfinder) printf("Pathfind Unit [%d - %s] INT BAILOUT ATTEMPT BLOCKED frameIndex = %d\n",unit->getId(),unit->getType()->getName().c_str(),frameIndex);
if(minorDebugPathfinder) printf("Pathfind Unit [%d - %s] INT BAILOUT ATTEMPT BLOCKED frameIndex = %d\n",unit->getId(),unit->getType()->getName(false).c_str(),frameIndex);
if(minorDebugPathfinderPerformance && chrono.getMillis() >= 1) printf("Unit [%d - %s] astar #3 took [%lld] msecs, ts = %d searched_node_count = %d.\n",unit->getId(),unit->getType()->getName().c_str(),(long long int)chrono.getMillis(),ts,searched_node_count);
if(minorDebugPathfinderPerformance && chrono.getMillis() >= 1) printf("Unit [%d - %s] astar #3 took [%lld] msecs, ts = %d searched_node_count = %d.\n",unit->getId(),unit->getType()->getName(false).c_str(),(long long int)chrono.getMillis(),ts,searched_node_count);
return tsBlocked;
}
}
@ -559,7 +559,7 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
break;
}
if(minorDebugPathfinderPerformance && chrono.getMillis() >= 1) printf("Unit [%d - %s] astar took [%lld] msecs, ts = %d searched_node_count = %d.\n",unit->getId(),unit->getType()->getName().c_str(),(long long int)chrono.getMillis(),ts,searched_node_count);
if(minorDebugPathfinderPerformance && chrono.getMillis() >= 1) printf("Unit [%d - %s] astar took [%lld] msecs, ts = %d searched_node_count = %d.\n",unit->getId(),unit->getType()->getName(false).c_str(),(long long int)chrono.getMillis(),ts,searched_node_count);
return ts;
}
@ -1096,7 +1096,7 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
// Check the previous path find cache for the unit to see if its good to
// use
if(showConsoleDebugInfo || tryLastPathCache) {
if(showConsoleDebugInfo && dist > 60) printf("Distance from [%d - %s] to destination is %.2f tryLastPathCache = %d\n",unit->getId(),unit->getFullName().c_str(), dist,tryLastPathCache);
if(showConsoleDebugInfo && dist > 60) printf("Distance from [%d - %s] to destination is %.2f tryLastPathCache = %d\n",unit->getId(),unit->getFullName(false).c_str(), dist,tryLastPathCache);
if(tryLastPathCache == true && path != NULL) {
UnitPathBasic *basicPathFinder = dynamic_cast<UnitPathBasic *>(path);
@ -1327,10 +1327,10 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
unit->logSynchData(extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__,szBuf);
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled == true && chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] **Check if dest blocked, distance for unit [%d - %s] from [%s] to [%s] is %.2f took msecs: %lld nodeLimitReached = %d, failureCount = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,unit->getId(),unit->getFullName().c_str(), unitPos.getString().c_str(), finalPos.getString().c_str(), dist,(long long int)chrono.getMillis(),nodeLimitReached,failureCount);
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled == true && chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] **Check if dest blocked, distance for unit [%d - %s] from [%s] to [%s] is %.2f took msecs: %lld nodeLimitReached = %d, failureCount = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,unit->getId(),unit->getFullName(false).c_str(), unitPos.getString().c_str(), finalPos.getString().c_str(), dist,(long long int)chrono.getMillis(),nodeLimitReached,failureCount);
if(showConsoleDebugInfo && nodeLimitReached) {
printf("**Check if src blocked [%d - %d], unit [%d - %s] from [%s] to [%s] distance %.2f took msecs: %lld nodeLimitReached = %d, failureCount = %d [%d]\n",
nodeLimitReached, inBailout, unit->getId(),unit->getFullName().c_str(), unitPos.getString().c_str(), finalPos.getString().c_str(), dist,(long long int)chrono.getMillis(),nodeLimitReached,failureCount,cellCount);
nodeLimitReached, inBailout, unit->getId(),unit->getFullName(false).c_str(), unitPos.getString().c_str(), finalPos.getString().c_str(), dist,(long long int)chrono.getMillis(),nodeLimitReached,failureCount,cellCount);
}
if(nodeLimitReached == false) {
@ -1360,10 +1360,10 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
unit->logSynchData(extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__,szBuf);
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled == true && chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] **Check if dest blocked, distance for unit [%d - %s] from [%s] to [%s] is %.2f took msecs: %lld nodeLimitReached = %d, failureCount = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,unit->getId(),unit->getFullName().c_str(), unitPos.getString().c_str(), finalPos.getString().c_str(), dist,(long long int)chrono.getMillis(),nodeLimitReached,failureCount);
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled == true && chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] **Check if dest blocked, distance for unit [%d - %s] from [%s] to [%s] is %.2f took msecs: %lld nodeLimitReached = %d, failureCount = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,unit->getId(),unit->getFullName(false).c_str(), unitPos.getString().c_str(), finalPos.getString().c_str(), dist,(long long int)chrono.getMillis(),nodeLimitReached,failureCount);
if(showConsoleDebugInfo && nodeLimitReached) {
printf("**Check if dest blocked [%d - %d], unit [%d - %s] from [%s] to [%s] distance %.2f took msecs: %lld nodeLimitReached = %d, failureCount = %d [%d]\n",
nodeLimitReached, inBailout, unit->getId(),unit->getFullName().c_str(), unitPos.getString().c_str(), finalPos.getString().c_str(), dist,(long long int)chrono.getMillis(),nodeLimitReached,failureCount,cellCount);
nodeLimitReached, inBailout, unit->getId(),unit->getFullName(false).c_str(), unitPos.getString().c_str(), finalPos.getString().c_str(), dist,(long long int)chrono.getMillis(),nodeLimitReached,failureCount,cellCount);
}
}
}
@ -1431,7 +1431,7 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
}
if(showConsoleDebugInfo || SystemFlags::VERBOSE_MODE_ENABLED) {
printf("\n\n\n\n$$$ Calling AStar with LARGE maxnodes for unit [%d - %s]\n\n",unit->getId(),unit->getFullName().c_str());
printf("\n\n\n\n$$$ Calling AStar with LARGE maxnodes for unit [%d - %s]\n\n",unit->getId(),unit->getFullName(false).c_str());
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0) {
@ -1465,7 +1465,7 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled == true && chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld nodeLimitReached = %d whileLoopCount = %d nodePoolCount = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis(),nodeLimitReached,whileLoopCount,factions[unitFactionIndex].nodePoolCount);
if(showConsoleDebugInfo && chrono.getMillis() > 2) {
printf("Distance for unit [%d - %s] from [%s] to [%s] is %.2f took msecs: %lld nodeLimitReached = %d whileLoopCount = %d nodePoolCount = %d\n",unit->getId(),unit->getFullName().c_str(), unitPos.getString().c_str(), finalPos.getString().c_str(), dist,(long long int)chrono.getMillis(),nodeLimitReached,whileLoopCount,factions[unitFactionIndex].nodePoolCount);
printf("Distance for unit [%d - %s] from [%s] to [%s] is %.2f took msecs: %lld nodeLimitReached = %d whileLoopCount = %d nodePoolCount = %d\n",unit->getId(),unit->getFullName(false).c_str(), unitPos.getString().c_str(), finalPos.getString().c_str(), dist,(long long int)chrono.getMillis(),nodeLimitReached,whileLoopCount,factions[unitFactionIndex].nodePoolCount);
}
Node *lastNode= node;

View File

@ -943,7 +943,7 @@ Command* Commander::buildCommand(const NetworkCommand* networkCommand) const {
char szBuf[8096]="";
snprintf(szBuf,8096,"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());
__FILE__,__FUNCTION__,__LINE__,networkCommand->toString().c_str(),unit->getType()->getCommandTypeListDesc().c_str(),unit->getId(), unit->getFullName(false).c_str(),unit->getDesc(false).c_str(),unit->getFaction()->getIndex());
SystemFlags::OutputDebug(SystemFlags::debugError,"%s\n",szBuf);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n",szBuf);
@ -995,8 +995,8 @@ Command* Commander::buildCommand(const NetworkCommand* networkCommand) const {
char szBuf[8096]="";
snprintf(szBuf,8096,"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.\nUnit Type Info:\n[%s]\nNetwork unit type:\n[%s]\nisCancelPreMorphCommand: %d\nGame out of synch.",
extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,networkCommand->toString().c_str(),unit->getType()->getCommandTypeListDesc().c_str(),
unit->getId(), unit->getFullName().c_str(),unit->getDesc().c_str(),unit->getFaction()->getIndex(),unit->getType()->toString().c_str(),
(unitType != NULL ? unitType->getName().c_str() : "null"),isCancelPreMorphCommand);
unit->getId(), unit->getFullName(false).c_str(),unit->getDesc(false).c_str(),unit->getFaction()->getIndex(),unit->getType()->toString().c_str(),
(unitType != NULL ? unitType->getName(false).c_str() : "null"),isCancelPreMorphCommand);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n",szBuf);
SystemFlags::OutputDebug(SystemFlags::debugError,"%s\n",szBuf);
@ -1005,7 +1005,7 @@ Command* Commander::buildCommand(const NetworkCommand* networkCommand) const {
GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
if(gameNetworkInterface != NULL) {
char szMsg[8096]="";
snprintf(szMsg,8096,"Player detected an error: Can not find command type: %d for unitId: %d [%s]. isCancelPreMorphCommand: %d Game out of synch.",networkCommand->getCommandTypeId(),networkCommand->getUnitId(),(unitType != NULL ? unitType->getName().c_str() : "null"),isCancelPreMorphCommand);
snprintf(szMsg,8096,"Player detected an error: Can not find command type: %d for unitId: %d [%s]. isCancelPreMorphCommand: %d Game out of synch.",networkCommand->getCommandTypeId(),networkCommand->getUnitId(),(unitType != NULL ? unitType->getName(false).c_str() : "null"),isCancelPreMorphCommand);
gameNetworkInterface->sendTextMessage(szMsg,-1, true, "");
}

View File

@ -448,6 +448,10 @@ Game::~Game() {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
}
bool Game::showTranslatedTechTree() const {
return this->gameSettings.getNetworkAllowNativeLanguageTechtree();
}
bool Game::quitTriggered() {
return quitTriggeredIndicator;
}
@ -866,8 +870,11 @@ string Game::findFactionLogoFile(const GameSettings *settings, Logger *logger,
logger->setState(Lang::getInstance().get("Loading"));
if(scenarioName.empty()) {
string scenarioDir = extractDirectoryPathFromFile(settings->getScenarioDir());
TechTree techTree(Config::getInstance().getPathListForType(ptTechs,scenarioDir));
logger->setSubtitle(formatString(mapName) + " - " +
formatString(tilesetName) + " - " + formatString(techName));
formatString(tilesetName) + " - " + formatString(techTree.getTranslatedName(techName)));
}
else {
logger->setSubtitle(formatString(scenarioName));

View File

@ -325,6 +325,8 @@ public:
void highlightUnit(int unitId,float radius, float thickness, Vec4f color);
void unhighlightUnit(int unitId);
bool showTranslatedTechTree() const;
private:
//render
void render3d();

View File

@ -523,7 +523,7 @@ void ScriptManager::onUnitCreated(const Unit* unit){
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(this->rootNode == NULL) {
lastCreatedUnitName= unit->getType()->getName();
lastCreatedUnitName= unit->getType()->getName(false);
lastCreatedUnitId= unit->getId();
luaScript.beginCall("unitCreated");
luaScript.endCall();
@ -540,10 +540,10 @@ void ScriptManager::onUnitDied(const Unit* unit){
Unit *killer = world->findUnitById(unit->getLastAttackerUnitId());
if(killer != NULL) {
lastAttackingUnitName= killer->getType()->getName();
lastAttackingUnitName= killer->getType()->getName(false);
lastAttackingUnitId= killer->getId();
lastDeadUnitKillerName= killer->getType()->getName();
lastDeadUnitKillerName= killer->getType()->getName(false);
lastDeadUnitKillerId= killer->getId();
}
else {
@ -552,10 +552,10 @@ void ScriptManager::onUnitDied(const Unit* unit){
}
}
lastAttackedUnitName= unit->getType()->getName();
lastAttackedUnitName= unit->getType()->getName(false);
lastAttackedUnitId= unit->getId();
lastDeadUnitName= unit->getType()->getName();
lastDeadUnitName= unit->getType()->getName(false);
lastDeadUnitId= unit->getId();
lastDeadUnitCauseOfDeath = unit->getCauseOfDeath();
@ -568,7 +568,7 @@ void ScriptManager::onUnitAttacked(const Unit* unit) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(this->rootNode == NULL) {
lastAttackedUnitName= unit->getType()->getName();
lastAttackedUnitName= unit->getType()->getName(false);
lastAttackedUnitId= unit->getId();
luaScript.beginCall("unitAttacked");
luaScript.endCall();
@ -579,7 +579,7 @@ void ScriptManager::onUnitAttacking(const Unit* unit) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(this->rootNode == NULL) {
lastAttackingUnitName= unit->getType()->getName();
lastAttackingUnitName= unit->getType()->getName(false);
lastAttackingUnitId= unit->getId();
luaScript.beginCall("unitAttacking");
luaScript.endCall();
@ -1720,7 +1720,7 @@ int ScriptManager::isFreeCellsOrHasUnit(int field, int unitId, Vec2i pos) {
Unit* unit= world->findUnitById(unitId);
int result = world->getMap()->isFreeCellsOrHasUnit(pos,unit->getType()->getSize(),static_cast<Field>(field),unit,NULL,true);
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s] unitId = %d, [%s] pos [%s] field = %d result = %d\n",__FUNCTION__,unitId,unit->getType()->getName().c_str(),pos.getString().c_str(),field,result);
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s] unitId = %d, [%s] pos [%s] field = %d result = %d\n",__FUNCTION__,unitId,unit->getType()->getName(false).c_str(),pos.getString().c_str(),field,result);
return result;
}

View File

@ -284,7 +284,7 @@ void Lang::loadScenarioStrings(string scenarioDir, string scenarioName, bool isT
void Lang::loadTechTreeStrings(string techTree,bool forceLoad) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] techTree = [%s]\n",__FILE__,__FUNCTION__,__LINE__,techTree.c_str());
printf("Load techtree strings techTree [%s] techNameLoaded [%s] forceLoad: %d\n",techTree.c_str(),techNameLoaded.c_str(),forceLoad);
//printf("Load techtree strings techTree [%s] techNameLoaded [%s] forceLoad: %d\n",techTree.c_str(),techNameLoaded.c_str(),forceLoad);
if(forceLoad == false && techTree == techNameLoaded) {
return;
}
@ -509,6 +509,8 @@ string Lang::getTechTreeString(const string &s,const char *defaultValue) {
try{
string result = "";
//printf("getTechTreeString [%s] allowNativeLanguageTechtree: %d techTreeStrings.hasString(s): %d path [%s]\n",s.c_str(),allowNativeLanguageTechtree,techTreeStrings.hasString(s),techTreeStrings.getpath().c_str());
if(allowNativeLanguageTechtree == true &&
(techTreeStrings.hasString(s) == true || defaultValue == NULL)) {
if(techTreeStrings.hasString(s) == false && techTreeStringsDefault.hasString(s) == true) {

View File

@ -8479,7 +8479,7 @@ void Renderer::renderUnitTitles3D(Font3D *font, Vec3f color) {
//unitRenderedList[unit->getId()] = true;
}
else {
string str = unit->getFullName() + " - " + intToStr(unit->getId()) + " [" + unit->getPosNotThreadSafe().getString() + "]";
string str = unit->getFullName(unit->showTranslatedTechTree()) + " - " + intToStr(unit->getId()) + " [" + unit->getPosNotThreadSafe().getString() + "]";
Vec3f screenPos = unit->getScreenPos();
// #ifdef USE_STREFLOP
// renderText3D(str, font, color, streflop::fabs(static_cast<streflop::Simple>(screenPos.x)) + 5, streflop::fabs(static_cast<streflop::Simple>(screenPos.y)) + 5, false);
@ -8543,7 +8543,7 @@ void Renderer::renderUnitTitles(Font2D *font, Vec3f color) {
//unitRenderedList[unit->getId()] = true;
}
else {
string str = unit->getFullName() + " - " + intToStr(unit->getId()) + " [" + unit->getPosNotThreadSafe().getString() + "]";
string str = unit->getFullName(unit->showTranslatedTechTree()) + " - " + intToStr(unit->getId()) + " [" + unit->getPosNotThreadSafe().getString() + "]";
Vec3f screenPos = unit->getScreenPos();
//#ifdef USE_STREFLOP
// renderText(str, font, color, streflop::fabs(static_cast<streflop::Simple>(screenPos.x)) + 5, streflop::fabs(static_cast<streflop::Simple>(screenPos.y)) + 5, false);

View File

@ -713,7 +713,7 @@ string Gui::computeDefaultInfoString() {
if(selection.isUniform()) {
if(selection.isObserver() || selection.isCommandable()) {
// default is the description extension
result = selection.getFrontUnit()->getDescExtension();
result = selection.getFrontUnit()->getDescExtension(game->showTranslatedTechTree());
}
}
return result;
@ -744,7 +744,7 @@ void Gui::computeInfoString(int posDisplay){
if(ct!=NULL){
if(unit->getFaction()->reqsOk(ct)){
display.setInfoText(ct->getDesc(unit->getTotalUpgrade()));
display.setInfoText(ct->getDesc(unit->getTotalUpgrade(),game->showTranslatedTechTree()));
}
else{
if(ct->getClass()==ccUpgrade){
@ -756,10 +756,10 @@ void Gui::computeInfoString(int posDisplay){
else if(unit->getFaction()->getUpgradeManager()->isUpgraded(uct->getProducedUpgrade())){
text=lang.get("AlreadyUpgraded")+"\n\n";
}
display.setInfoText(text+ct->getReqDesc());
display.setInfoText(text+ct->getReqDesc(game->showTranslatedTechTree()));
}
else{
display.setInfoText(ct->getReqDesc());
display.setInfoText(ct->getReqDesc(game->showTranslatedTechTree()));
}
}
}
@ -782,7 +782,7 @@ void Gui::computeInfoString(int posDisplay){
else{
if(activeCommandType!=NULL && activeCommandType->getClass()==ccBuild){
const BuildCommandType *bct= static_cast<const BuildCommandType*>(activeCommandType);
display.setInfoText(bct->getBuilding(posDisplay)->getReqDesc());
display.setInfoText(bct->getBuilding(posDisplay)->getReqDesc(game->showTranslatedTechTree()));
}
}
}
@ -800,7 +800,7 @@ void Gui::computeDisplay(){
const Object *selectedResourceObject =getSelectedResourceObject();
if(selection.isEmpty() && selectedResourceObject != NULL && selectedResourceObject->getResource() != NULL) {
Resource *r = selectedResourceObject->getResource();
display.setTitle(r->getType()->getName(true));
display.setTitle(r->getType()->getName(game->showTranslatedTechTree()));
display.setText(lang.get("Amount")+ ": "+intToStr(r->getAmount())+" / "+intToStr(r->getType()->getDefResPerPatch()));
//display.setProgressBar(r->);
display.setUpImage(0, r->getType()->getImage());
@ -808,8 +808,8 @@ void Gui::computeDisplay(){
else {
//title, text and progress bar
if(selection.getCount() == 1){
display.setTitle(selection.getFrontUnit()->getFullName());
display.setText(selection.getFrontUnit()->getDesc());
display.setTitle(selection.getFrontUnit()->getFullName(game->showTranslatedTechTree()));
display.setText(selection.getFrontUnit()->getDesc(game->showTranslatedTechTree()));
display.setProgressBar(selection.getFrontUnit()->getProductionPercent());
}
@ -1267,12 +1267,12 @@ void Gui::saveGame(XmlNode *rootNode) const {
// const UnitType *choosenBuildingType;
if(choosenBuildingType != NULL) {
const Faction* thisFaction= world->getThisFaction();
guiNode->addAttribute("choosenBuildingType",choosenBuildingType->getName(), mapTagReplacements);
guiNode->addAttribute("choosenBuildingType",choosenBuildingType->getName(false), mapTagReplacements);
guiNode->addAttribute("choosenBuildingTypeFactionIndex",intToStr(thisFaction->getIndex()), mapTagReplacements);
}
// const CommandType *activeCommandType;
if(activeCommandType != NULL) {
guiNode->addAttribute("activeCommandType",activeCommandType->getName(), mapTagReplacements);
guiNode->addAttribute("activeCommandType",activeCommandType->getName(false), mapTagReplacements);
}
// CommandClass activeCommandClass;

View File

@ -1878,9 +1878,12 @@ void MenuStateConnectedGame::reloadFactions(bool keepExistingSelectedItem, strin
}
factionFiles= results;
vector<string> translatedFactionNames;
for(int i= 0; i<results.size(); ++i){
results[i]= formatString(results[i]);
translatedFactionNames.push_back(techTree->getTranslatedFactionName(techTreeFiles[listBoxTechTree.getSelectedItemIndex()],factionFiles[i]));
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"Tech [%s] has faction [%s]\n",techTreeFiles[listBoxTechTree.getSelectedItemIndex()].c_str(),results[i].c_str());
}
@ -1890,7 +1893,7 @@ void MenuStateConnectedGame::reloadFactions(bool keepExistingSelectedItem, strin
string originalValue = (listBoxFactions[i].getItemCount() > 0 ? listBoxFactions[i].getSelectedItem() : "");
listBoxFactions[i].setItems(results);
listBoxFactions[i].setItems(results,translatedFactionNames);
if( keepExistingSelectedItem == false ||
(checkBoxAllowObservers.getValue() == true &&
originalValue == formatString(GameConstants::OBSERVER_SLOTNAME)) ) {
@ -3349,8 +3352,13 @@ bool MenuStateConnectedGame::loadFactions(const GameSettings *gameSettings, bool
}
results.push_back(Lang::getInstance().get("DataMissing","",true));
factionFiles = results;
vector<string> translatedFactionNames;
for(int i= 0; i < factionFiles.size(); ++i) {
translatedFactionNames.push_back(techTree->getTranslatedFactionName(gameSettings->getTech(),factionFiles[i]));
}
for(int i=0; i<GameConstants::maxPlayers; ++i){
listBoxFactions[i].setItems(results);
listBoxFactions[i].setItems(results,translatedFactionNames);
}
if(lastMissingTechtree != gameSettings->getTech() &&
@ -3385,13 +3393,18 @@ bool MenuStateConnectedGame::loadFactions(const GameSettings *gameSettings, bool
results.push_back(formatString(GameConstants::RANDOMFACTION_SLOTNAME));
factionFiles= results;
vector<string> translatedFactionNames;
for(int i= 0; i < factionFiles.size(); ++i) {
translatedFactionNames.push_back(techTree->getTranslatedFactionName(gameSettings->getTech(),factionFiles[i]));
}
for(int i= 0; i<results.size(); ++i){
results[i]= formatString(results[i]);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"Tech [%s] has faction [%s]\n",gameSettings->getTech().c_str(),results[i].c_str());
}
for(int i=0; i<GameConstants::maxPlayers; ++i){
listBoxFactions[i].setItems(results);
listBoxFactions[i].setItems(results,translatedFactionNames);
}
foundFactions = (results.empty() == false);

View File

@ -134,7 +134,7 @@ std::string Command::toString() const {
if(unitType != NULL) {
result += ", unitTypeId = " + intToStr(unitType->getId());
result += ", unitTypeDesc = " + unitType->getReqDesc();
result += ", unitTypeDesc = " + unitType->getReqDesc(false);
}
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__, __LINE__);

View File

@ -38,14 +38,14 @@ bool CommandGroupUnitSorterId::operator()(const int l, const int r) {
printf("Error lUnit == NULL for id = %d factionIndex = %d\n",l,faction->getIndex());
for(unsigned int i = 0; i < faction->getUnitCount(); ++i) {
printf("%u / %d id = %d [%s]\n",i,faction->getUnitCount(),faction->getUnit(i)->getId(),faction->getUnit(i)->getType()->getName().c_str());
printf("%u / %d id = %d [%s]\n",i,faction->getUnitCount(),faction->getUnit(i)->getId(),faction->getUnit(i)->getType()->getName(false).c_str());
}
}
if(!rUnit) {
printf("Error rUnit == NULL for id = %d factionIndex = %d\n",r,faction->getIndex());
for(unsigned int i = 0; i < faction->getUnitCount(); ++i) {
printf("%u / %d id = %d [%s]\n",i,faction->getUnitCount(),faction->getUnit(i)->getId(),faction->getUnit(i)->getType()->getName().c_str());
printf("%u / %d id = %d [%s]\n",i,faction->getUnitCount(),faction->getUnit(i)->getId(),faction->getUnit(i)->getType()->getName(false).c_str());
}
}
@ -71,9 +71,9 @@ bool CommandGroupUnitSorter::compare(const Unit *l, const Unit *r) {
if(l == NULL || r == NULL)
printf("Unit l [%s - %d] r [%s - %d]\n",
(l != NULL ? l->getType()->getName().c_str() : "null"),
(l != NULL ? l->getType()->getName(false).c_str() : "null"),
(l != NULL ? l->getId() : -1),
(r != NULL ? r->getType()->getName().c_str() : "null"),
(r != NULL ? r->getType()->getName(false).c_str() : "null"),
(r != NULL ? r->getId() : -1));
@ -178,10 +178,10 @@ void Faction::sortUnitsByCommandGroups() {
for(unsigned int i = 0; i < units.size(); ++i) {
int unitId = units[i]->getId();
if(this->findUnit(unitId) == NULL) {
printf("#1 Error unitId not found for id = %d [%s] factionIndex = %d\n",unitId,units[i]->getType()->getName().c_str(),this->getIndex());
printf("#1 Error unitId not found for id = %d [%s] factionIndex = %d\n",unitId,units[i]->getType()->getName(false).c_str(),this->getIndex());
for(unsigned int j = 0; j < units.size(); ++j) {
printf("%u / %d id = %d [%s]\n",j,(int)units.size(),units[j]->getId(),units[j]->getType()->getName().c_str());
printf("%u / %d id = %d [%s]\n",j,(int)units.size(),units[j]->getId(),units[j]->getType()->getName(false).c_str());
}
}
unitIds.push_back(unitId);
@ -198,7 +198,7 @@ void Faction::sortUnitsByCommandGroups() {
printf("#2 Error unitId not found for id = %d factionIndex = %d\n",unitId,this->getIndex());
for(unsigned int j = 0; j < units.size(); ++j) {
printf("%u / %d id = %d [%s]\n",j,(int)units.size(),units[j]->getId(),units[j]->getType()->getName().c_str());
printf("%u / %d id = %d [%s]\n",j,(int)units.size(),units[j]->getId(),units[j]->getType()->getName(false).c_str());
}
}
@ -850,14 +850,14 @@ bool Faction::applyCosts(const ProducibleType *p,const CommandType *ct) {
const Resource *r= p->getCost(i);
if(r == NULL) {
char szBuf[8096]="";
snprintf(szBuf,8096,"cannot apply costs for p [%s] %d of %d costs resource is null",p->getName().c_str(),i,p->getCostCount());
snprintf(szBuf,8096,"cannot apply costs for p [%s] %d of %d costs resource is null",p->getName(false).c_str(),i,p->getCostCount());
throw megaglest_runtime_error(szBuf);
}
const ResourceType *rt= r->getType();
if(rt == NULL) {
char szBuf[8096]="";
snprintf(szBuf,8096,"cannot apply costs for p [%s] %d of %d costs resourcetype [%s] is null",p->getName().c_str(),i,p->getCostCount(),r->getDescription().c_str());
snprintf(szBuf,8096,"cannot apply costs for p [%s] %d of %d costs resourcetype [%s] is null",p->getName(false).c_str(),i,p->getCostCount(),r->getDescription(false).c_str());
throw megaglest_runtime_error(szBuf);
}
int cost= r->getAmount();
@ -903,7 +903,7 @@ void Faction::applyStaticCosts(const ProducibleType *p,const CommandType *ct) {
const ResourceType *rt= p->getCost(i)->getType();
//assert(rt != NULL);
if(rt == NULL) {
throw megaglest_runtime_error(string(__FUNCTION__) + " rt == NULL for ProducibleType [" + p->getName() + "] index: " + intToStr(i));
throw megaglest_runtime_error(string(__FUNCTION__) + " rt == NULL for ProducibleType [" + p->getName(false) + "] index: " + intToStr(i));
}
if(rt->getClass() == rcStatic) {
int cost= p->getCost(i)->getAmount();
@ -1865,7 +1865,7 @@ bool Faction::canCreateUnit(const UnitType *ut, bool checkBuild, bool checkProdu
if( produceUnit != NULL &&
ut->getId() != unitType2->getId() &&
ut->getName() == produceUnit->getName()) {
ut->getName(false) == produceUnit->getName(false)) {
foundUnit = true;
break;
}
@ -1879,7 +1879,7 @@ bool Faction::canCreateUnit(const UnitType *ut, bool checkBuild, bool checkProdu
if( buildUnit != NULL &&
ut->getId() != unitType2->getId() &&
ut->getName() == buildUnit->getName()) {
ut->getName(false) == buildUnit->getName(false)) {
foundUnit = true;
break;
}
@ -1892,7 +1892,7 @@ bool Faction::canCreateUnit(const UnitType *ut, bool checkBuild, bool checkProdu
if( morphUnit != NULL &&
ut->getId() != unitType2->getId() &&
ut->getName() == morphUnit->getName()) {
ut->getName(false) == morphUnit->getName(false)) {
foundUnit = true;
break;
}
@ -2012,12 +2012,12 @@ std::string Faction::toString() const {
result += "ResourceCount = " + intToStr(resources.size()) + "\n";
for(int idx = 0; idx < resources.size(); idx ++) {
result += "index = " + intToStr(idx) + " " + resources[idx].getDescription() + "\n";
result += "index = " + intToStr(idx) + " " + resources[idx].getDescription(false) + "\n";
}
result += "StoreCount = " + intToStr(store.size()) + "\n";
for(int idx = 0; idx < store.size(); idx ++) {
result += "index = " + intToStr(idx) + " " + store[idx].getDescription() + "\n";
result += "index = " + intToStr(idx) + " " + store[idx].getDescription(false) + "\n";
}
result += "Allies = " + intToStr(allies.size()) + "\n";

View File

@ -228,7 +228,7 @@ void Object::setVisible( bool visible)
string Object::getUniquePickName() const {
string result = "";
if(resource != NULL) {
result += resource->getDescription() + " : ";
result += resource->getDescription(false) + " : ";
}
result += mapPos.getString();
return result;

View File

@ -57,10 +57,10 @@ void Resource::init(const ResourceType *rt, const Vec2i &pos) {
addItemToVault(&this->balance,this->balance);
}
string Resource::getDescription() const {
string Resource::getDescription(bool translatedValue) const {
string str;
str+= type->getName(true);
str+= type->getName(translatedValue);
str+="\n";
str+= intToStr(amount);
str+="/";

View File

@ -56,7 +56,7 @@ public:
int getAmount() const;
int getBalance() const;
string getDescription() const;
string getDescription(bool translatedValue) const;
void setAmount(int amount);
void setBalance(int balance);

View File

@ -866,15 +866,15 @@ const Level *Unit::getNextLevel() const{
return NULL;
}
string Unit::getFullName() const{
string Unit::getFullName(bool translatedValue) const{
string str="";
if(level != NULL){
str += (level->getName(true) + " ");
str += (level->getName(translatedValue) + " ");
}
if(type == NULL) {
throw megaglest_runtime_error("type == NULL in Unit::getFullName()!");
}
str += type->getName(true);
str += type->getName(translatedValue);
return str;
}
@ -1726,7 +1726,7 @@ void Unit::kill() {
void Unit::undertake() {
try {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] about to undertake unit id = %d [%s] [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,this->id, this->getFullName().c_str(),this->getDesc().c_str());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] about to undertake unit id = %d [%s] [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,this->id, this->getFullName(false).c_str(),this->getDesc(false).c_str());
// Remove any units that were previously in attack-boost range
if(currentAttackBoostOriginatorEffect.currentAttackBoostUnits.empty() == false && currentAttackBoostOriginatorEffect.skillType != NULL) {
@ -2001,12 +2001,12 @@ int64 Unit::getUpdatedProgress(int64 currentProgress, int64 updateFPS, int64 spe
void Unit::updateAttackBoostProgress(const Game* game) {
const bool debugBoost = false;
if(debugBoost) printf("===================== START Unit [%d - %s] skill: %s affected unit size: " MG_SIZE_T_SPECIFIER "\n",
this->id,this->getType()->getName().c_str(),currSkill->getBoostDesc().c_str(),
this->id,this->getType()->getName(false).c_str(),currSkill->getBoostDesc(false).c_str(),
currentAttackBoostOriginatorEffect.currentAttackBoostUnits.size());
if (currSkill != currentAttackBoostOriginatorEffect.skillType) {
if(debugBoost) printf("Line: %d new [%s]\n",__LINE__,(currentAttackBoostOriginatorEffect.skillType != NULL ? currentAttackBoostOriginatorEffect.skillType->getBoostDesc().c_str() : ""));
if(debugBoost) printf("Line: %d new [%s]\n",__LINE__,(currentAttackBoostOriginatorEffect.skillType != NULL ? currentAttackBoostOriginatorEffect.skillType->getBoostDesc(false).c_str() : ""));
if (currentAttackBoostOriginatorEffect.currentAppliedEffect != NULL) {
delete currentAttackBoostOriginatorEffect.currentAppliedEffect;
@ -2051,7 +2051,7 @@ void Unit::updateAttackBoostProgress(const Game* game) {
vector<Unit *> candidates = unitUpdater->findUnitsInRange(this,
attackBoost->radius);
if(debugBoost) printf("Line: %d candidates unit size: " MG_SIZE_T_SPECIFIER " attackBoost: %s\n",__LINE__,candidates.size(),attackBoost->getDesc().c_str());
if(debugBoost) printf("Line: %d candidates unit size: " MG_SIZE_T_SPECIFIER " attackBoost: %s\n",__LINE__,candidates.size(),attackBoost->getDesc(false).c_str());
for (unsigned int i = 0; i < candidates.size(); ++i) {
Unit *affectedUnit = candidates[i];
@ -2108,7 +2108,7 @@ void Unit::updateAttackBoostProgress(const Game* game) {
vector<int> candidateValidIdList;
candidateValidIdList.reserve(candidates.size());
if(debugBoost) printf("Line: %d candidates unit size: " MG_SIZE_T_SPECIFIER " attackBoost: %s\n",__LINE__,candidates.size(),attackBoost->getDesc().c_str());
if(debugBoost) printf("Line: %d candidates unit size: " MG_SIZE_T_SPECIFIER " attackBoost: %s\n",__LINE__,candidates.size(),attackBoost->getDesc(false).c_str());
for (unsigned int i = 0; i < candidates.size(); ++i) {
Unit *affectedUnit = candidates[i];
@ -2160,7 +2160,7 @@ void Unit::updateAttackBoostProgress(const Game* game) {
this);
if(debugBoost) printf("Removed attack boost from Unit [%d - %s] since they are NO LONGER in range\n",
affectedUnit->id,affectedUnit->getType()->getName().c_str());
affectedUnit->id,affectedUnit->getType()->getName(false).c_str());
}
currentAttackBoostOriginatorEffect.currentAttackBoostUnits.erase(
@ -2212,7 +2212,7 @@ void Unit::updateAttackBoostProgress(const Game* game) {
if(debugBoost) {
if (currSkill->isAttackBoostEnabled() == true) {
printf("Unit [%d - %s] has attackboost enabled: %s\n",this->id,this->getType()->getName().c_str(),currSkill->getBoostDesc().c_str());
printf("Unit [%d - %s] has attackboost enabled: %s\n",this->id,this->getType()->getName(false).c_str(),currSkill->getBoostDesc(false).c_str());
if (currentAttackBoostOriginatorEffect.currentAttackBoostUnits.empty() == false) {
printf("Found affected units currentAttackBoostOriginatorEffect.skillType [%p]\n",currentAttackBoostOriginatorEffect.skillType);
@ -2508,7 +2508,7 @@ bool Unit::applyAttackBoost(const AttackBoost *boost, const Unit *source) {
}
if(shouldApplyAttackBoost == true) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("=== APPLYING ATTACK BOOST START to unit [%s - %d] from unit [%s - %d] hp: %d\n",this->getType()->getName().c_str(),this->getId(),source->getType()->getName().c_str(),source->getId(),hp);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("=== APPLYING ATTACK BOOST START to unit [%s - %d] from unit [%s - %d] hp: %d\n",this->getType()->getName(false).c_str(),this->getId(),source->getType()->getName(false).c_str(),source->getId(),hp);
UnitAttackBoostEffect *effect = new UnitAttackBoostEffect();
effect->boost = boost;
@ -2617,7 +2617,7 @@ bool Unit::applyAttackBoost(const AttackBoost *boost, const Unit *source) {
//printf("APPLYING ATTACK BOOST END to unit [%s - %d] from unit [%s - %d]\n",this->getType()->getName().c_str(),this->getId(),source->getType()->getName().c_str(),source->getId());
}
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("APPLIED ATTACK BOOST START to unit [%s - %d] from unit [%s - %d] hp: %d\n",this->getType()->getName().c_str(),this->getId(),source->getType()->getName().c_str(),source->getId(),hp);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("APPLIED ATTACK BOOST START to unit [%s - %d] from unit [%s - %d] hp: %d\n",this->getType()->getName(false).c_str(),this->getId(),source->getType()->getName(false).c_str(),source->getId(),hp);
return shouldApplyAttackBoost;
}
@ -2629,7 +2629,7 @@ void Unit::deapplyAttackBoost(const AttackBoost *boost, const Unit *source) {
throw megaglest_runtime_error(szBuf);
}
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("=== DE-APPLYING ATTACK BOOST START to unit [%s - %d] from unit [%s - %d] hp: %d\n",this->getType()->getName().c_str(),this->getId(),source->getType()->getName().c_str(),source->getId(),hp);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("=== DE-APPLYING ATTACK BOOST START to unit [%s - %d] from unit [%s - %d] hp: %d\n",this->getType()->getName(false).c_str(),this->getId(),source->getType()->getName(false).c_str(),source->getId(),hp);
bool wasAlive = alive;
int originalHp = hp;
@ -2725,7 +2725,7 @@ void Unit::deapplyAttackBoost(const AttackBoost *boost, const Unit *source) {
}
}
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("DE-APPLIED ATTACK BOOST START to unit [%s - %d] from unit [%s - %d] hp: %d\n",this->getType()->getName().c_str(),this->getId(),source->getType()->getName().c_str(),source->getId(),hp);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("DE-APPLIED ATTACK BOOST START to unit [%s - %d] from unit [%s - %d] hp: %d\n",this->getType()->getName(false).c_str(),this->getId(),source->getType()->getName(false).c_str(),source->getId(),hp);
//printf("DE-APPLYING ATTACK BOOST END to unit [%s - %d] from unit [%s - %d]\n",this->getType()->getName().c_str(),this->getId(),source->getType()->getName().c_str(),source->getId());
}
@ -2981,7 +2981,7 @@ bool Unit::decHp(int i) {
return false;
}
string Unit::getDescExtension() const{
string Unit::getDescExtension(bool translatedValue) const{
Lang &lang= Lang::getInstance();
string str= "\n";
@ -2992,7 +2992,7 @@ string Unit::getDescExtension() const{
if(i == 0){
str+= "\n" + lang.get("OrdersOnQueue") + ": ";
}
str+= "\n#" + intToStr(i + 1) + " " + ct->getName(true);
str+= "\n#" + intToStr(i + 1) + " " + ct->getName(translatedValue);
++it;
}
}
@ -3000,13 +3000,10 @@ string Unit::getDescExtension() const{
return str;
}
string Unit::getDesc() const {
string Unit::getDesc(bool translatedValue) const {
Lang &lang= Lang::getInstance();
//pos
//str+="Pos: "+v2iToStr(pos)+"\n";
//hp
string str= "\n";
@ -3042,7 +3039,7 @@ string Unit::getDesc() const {
if(totalUpgrade.getArmor()!=0){
str+="+"+intToStr(totalUpgrade.getArmor());
}
str+= " ("+getType()->getArmorType()->getName(true)+")";
str+= " ("+getType()->getArmorType()->getName(translatedValue)+")";
//sight
str+="\n"+ lang.get("Sight")+ ": " + intToStr(getType()->getSight());
@ -3055,7 +3052,7 @@ string Unit::getDesc() const {
if(enemyKills > 0 || nextLevel != NULL) {
str+= "\n" + lang.get("Kills") +": " + intToStr(enemyKills);
if(nextLevel != NULL) {
str+= " (" + nextLevel->getName(true) + ": " + intToStr(nextLevel->getKills()) + ")";
str+= " (" + nextLevel->getName(translatedValue) + ": " + intToStr(nextLevel->getKills()) + ")";
}
}
@ -3063,7 +3060,7 @@ string Unit::getDesc() const {
//load
if(loadCount!=0){
str+= "\n" + lang.get("Load")+ ": " + intToStr(loadCount) +" " + loadType->getName(true);
str+= "\n" + lang.get("Load")+ ": " + intToStr(loadCount) +" " + loadType->getName(translatedValue);
}
//consumable production
@ -3072,13 +3069,13 @@ string Unit::getDesc() const {
if(r->getType()->getClass() == rcConsumable) {
str+= "\n";
str+= r->getAmount() < 0 ? lang.get("Produce")+": ": lang.get("Consume")+": ";
str+= intToStr(abs(r->getAmount())) + " " + r->getType()->getName(true);
str+= intToStr(abs(r->getAmount())) + " " + r->getType()->getName(translatedValue);
}
}
//command info
if(commands.empty() == false) {
str+= "\n" + commands.front()->getCommandType()->getName(true);
str+= "\n" + commands.front()->getCommandType()->getName(translatedValue);
if(commands.size() > 1) {
str+= "\n" + lang.get("OrdersOnQueue") + ": " + intToStr(commands.size());
}
@ -3089,7 +3086,7 @@ string Unit::getDesc() const {
for(int i = 0; i < getType()->getStoredResourceCount(); ++i) {
const Resource *r= getType()->getStoredResource(i);
str+= "\n" + lang.get("Store") + ": ";
str+= intToStr(r->getAmount()) + " " + r->getType()->getName(true);
str+= intToStr(r->getAmount()) + " " + r->getType()->getName(translatedValue);
}
}
}
@ -3403,7 +3400,7 @@ std::pair<CommandResult,string> Unit::checkCommand(Command *command) const {
result.first = crFailReqs;
Lang &lang= Lang::getInstance();
result.second = " - " + lang.get("Reqs") + " : " + produced->getUnitAndUpgradeReqDesc(false);
result.second = " - " + lang.get("Reqs") + " : " + produced->getUnitAndUpgradeReqDesc(false,this->showTranslatedTechTree());
return result;
}
@ -3413,7 +3410,7 @@ std::pair<CommandResult,string> Unit::checkCommand(Command *command) const {
//printf("In [%s::%s Line: %d] command = %p\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,command);
result.first = crFailRes;
Lang &lang= Lang::getInstance();
result.second = " - " + lang.get("Reqs") + " : " + produced->getResourceReqDesc(false);
result.second = " - " + lang.get("Reqs") + " : " + produced->getResourceReqDesc(false,this->showTranslatedTechTree());
return result;
}
}
@ -3433,7 +3430,7 @@ std::pair<CommandResult,string> Unit::checkCommand(Command *command) const {
//printf("In [%s::%s Line: %d] command = %p\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,command);
result.first = crFailReqs;
Lang &lang= Lang::getInstance();
result.second = " - " + lang.get("Reqs") + " : " + builtUnit->getUnitAndUpgradeReqDesc(false);
result.second = " - " + lang.get("Reqs") + " : " + builtUnit->getUnitAndUpgradeReqDesc(false,this->showTranslatedTechTree());
return result;
}
if(faction->checkCosts(builtUnit,NULL) == false) {
@ -3441,7 +3438,7 @@ std::pair<CommandResult,string> Unit::checkCommand(Command *command) const {
//printf("In [%s::%s Line: %d] command = %p\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,command);
result.first = crFailRes;
Lang &lang= Lang::getInstance();
result.second = " - " + lang.get("Reqs") + " : " + builtUnit->getResourceReqDesc(false);
result.second = " - " + lang.get("Reqs") + " : " + builtUnit->getResourceReqDesc(false,this->showTranslatedTechTree());
return result;
}
}
@ -3830,7 +3827,7 @@ void Unit::logSynchDataCommon(string file,int line,string source,bool threadedMo
"FrameCount [%d] Unit = %d [%s][%s] pos = %s, lastPos = %s, targetPos = %s, targetVec = %s, meetingPos = %s, progress [" MG_I64_SPECIFIER "], progress2 [%d]\nUnit Path [%s]\n",
getFrameCount(),
id,
getFullName().c_str(),
getFullName(false).c_str(),
faction->getType()->getName(false).c_str(),
//getDesc().c_str(),
pos.getString().c_str(),
@ -4006,7 +4003,7 @@ Vec2i Unit::getPosWithCellMapSet() const {
}
string Unit::getUniquePickName() const {
string result = intToStr(id) + " - " + type->getName() + " : ";
string result = intToStr(id) + " - " + type->getName(false) + " : ";
result += pos.getString();
return result;
}
@ -4034,12 +4031,16 @@ void Unit::clearCaches() {
lastHarvestedResourcePos = Vec2i(0,0);
}
bool Unit::showTranslatedTechTree() const {
return (this->game != NULL ? this->game->showTranslatedTechTree() : true);
}
std::string Unit::toString() const {
std::string result = "";
result += "id = " + intToStr(this->id);
if(this->type != NULL) {
result += " name [" + this->type->getName() + "][" + intToStr(this->type->getId()) + "]";
result += " name [" + this->type->getName(false) + "][" + intToStr(this->type->getId()) + "]";
}
if(this->faction != NULL) {
@ -4145,7 +4146,7 @@ void Unit::saveGame(XmlNode *rootNode) {
// const int id;
unitNode->addAttribute("id",intToStr(id), mapTagReplacements);
// For info purposes only
unitNode->addAttribute("name",type->getName(), mapTagReplacements);
unitNode->addAttribute("name",type->getName(false), mapTagReplacements);
// int hp;
unitNode->addAttribute("hp",intToStr(hp), mapTagReplacements);
@ -4206,9 +4207,9 @@ void Unit::saveGame(XmlNode *rootNode) {
// float rotationX;
unitNode->addAttribute("rotationX",floatToStr(rotationX,16), mapTagReplacements);
// const UnitType *type;
unitNode->addAttribute("type",type->getName(), mapTagReplacements);
unitNode->addAttribute("type",type->getName(false), mapTagReplacements);
unitNode->addAttribute("preMorph_type",(preMorph_type != NULL ? preMorph_type->getName() : ""), mapTagReplacements);
unitNode->addAttribute("preMorph_type",(preMorph_type != NULL ? preMorph_type->getName(false) : ""), mapTagReplacements);
// const ResourceType *loadType;
if(loadType != NULL) {

View File

@ -545,7 +545,7 @@ public:
inline int getEnemyKills() const {return enemyKills;}
inline const Level *getLevel() const {return level;}
const Level *getNextLevel() const;
string getFullName() const;
string getFullName(bool translatedValue) const;
inline const UnitPathInterface *getPath() const {return unitPath;}
inline UnitPathInterface *getPath() {return unitPath;}
inline WaypointPath *getWaypointPath() {return &waypointPath;}
@ -645,8 +645,8 @@ public:
//other
void resetHighlight();
const CommandType *computeCommandType(const Vec2i &pos, const Unit *targetUnit= NULL) const;
string getDesc() const;
string getDescExtension() const;
string getDesc(bool translatedValue) const;
string getDescExtension(bool translatedValue) const;
bool computeEp();
//bool computeHp();
bool repair();
@ -766,6 +766,7 @@ public:
static Unit * loadGame(const XmlNode *rootNode,GameSettings *settings,Faction *faction, World *world);
void clearCaches();
bool showTranslatedTechTree() const;
private:
float computeHeight(const Vec2i &pos) const;

View File

@ -66,7 +66,7 @@ std::string Upgrade::toString() const {
result += " state = " + intToStr(state) + " factionIndex = " + intToStr(factionIndex);
if(type != NULL) {
result += " type = " + type->getReqDesc();
result += " type = " + type->getReqDesc(false);
}
return result;

View File

@ -117,17 +117,17 @@ void StopCommandType::update(UnitUpdater *unitUpdater, Unit *unit, int frameInde
unitUpdater->updateStop(unit, frameIndex);
}
string StopCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{
string StopCommandType::getDesc(const TotalUpgrade *totalUpgrade, bool translatedValue) const{
string str;
Lang &lang= Lang::getInstance();
str= getName(true)+"\n";
str= getName(translatedValue)+"\n";
str+= lang.get("ReactionSpeed")+": "+ intToStr(stopSkillType->getSpeed())+"\n";
if(stopSkillType->getEpCost()!=0)
str+= lang.get("EpCost")+": "+intToStr(stopSkillType->getEpCost())+"\n";
if(stopSkillType->getHpCost()!=0)
str+= lang.get("HpCost")+": "+intToStr(stopSkillType->getHpCost())+"\n";
str+=stopSkillType->getBoostDesc();
str+=stopSkillType->getBoostDesc(translatedValue);
return str;
}
@ -173,11 +173,11 @@ void MoveCommandType::load(int id, const XmlNode *n, const string &dir,
moveSkillType= static_cast<const MoveSkillType*>(ut.getSkillType(skillName, scMove));
}
string MoveCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{
string MoveCommandType::getDesc(const TotalUpgrade *totalUpgrade, bool translatedValue) const{
string str;
Lang &lang= Lang::getInstance();
str=getName(true)+"\n";
str=getName(translatedValue)+"\n";
str+= lang.get("WalkSpeed")+": "+ intToStr(moveSkillType->getSpeed());
if(totalUpgrade->getMoveSpeed(moveSkillType) != 0) {
str+= "+" + intToStr(totalUpgrade->getMoveSpeed(moveSkillType));
@ -189,7 +189,7 @@ string MoveCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{
if(moveSkillType->getHpCost()!=0){
str+= lang.get("HpCost")+": "+intToStr(moveSkillType->getHpCost())+"\n";
}
str+=moveSkillType->getBoostDesc();
str+=moveSkillType->getBoostDesc(translatedValue);
return str;
}
@ -229,11 +229,11 @@ void AttackCommandType::load(int id, const XmlNode *n, const string &dir,
attackSkillType= static_cast<const AttackSkillType*>(ut.getSkillType(skillName, scAttack));
}
string AttackCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{
string AttackCommandType::getDesc(const TotalUpgrade *totalUpgrade, bool translatedValue) const{
string str;
Lang &lang= Lang::getInstance();
str=getName(true)+"\n";
str=getName(translatedValue)+"\n";
if(attackSkillType->getEpCost()!=0){
str+= lang.get("EpCost") + ": " + intToStr(attackSkillType->getEpCost()) + "\n";
}
@ -249,7 +249,7 @@ string AttackCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{
if(totalUpgrade->getAttackStrength(attackSkillType) != 0) {
str+= "+"+intToStr(totalUpgrade->getAttackStrength(attackSkillType));
}
str+= " ("+ attackSkillType->getAttackType()->getName(true) +")";
str+= " ("+ attackSkillType->getAttackType()->getName(translatedValue) +")";
str+= "\n";
//splash radius
@ -283,7 +283,7 @@ string AttackCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{
str+="\n";
str+= lang.get("AttackSpeed")+": "+ intToStr(attackSkillType->getSpeed()) +"\n";
str+=attackSkillType->getBoostDesc();
str+=attackSkillType->getBoostDesc(translatedValue);
return str;
}
@ -323,11 +323,11 @@ void AttackStoppedCommandType::load(int id, const XmlNode *n, const string &dir,
attackSkillType= static_cast<const AttackSkillType*>(ut.getSkillType(skillName, scAttack));
}
string AttackStoppedCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{
string AttackStoppedCommandType::getDesc(const TotalUpgrade *totalUpgrade, bool translatedValue) const{
Lang &lang= Lang::getInstance();
string str;
str=getName(true)+"\n";
str=getName(translatedValue)+"\n";
if(attackSkillType->getEpCost()!=0){
str+= lang.get("EpCost")+": "+intToStr(attackSkillType->getEpCost())+"\n";
}
@ -342,7 +342,7 @@ string AttackStoppedCommandType::getDesc(const TotalUpgrade *totalUpgrade) const
str+= intToStr(attackSkillType->getAttackStrength()+attackSkillType->getAttackVar());
if(totalUpgrade->getAttackStrength(attackSkillType) != 0)
str+= "+"+intToStr(totalUpgrade->getAttackStrength(attackSkillType));
str+= " ("+ attackSkillType->getAttackType()->getName(true) +")";
str+= " ("+ attackSkillType->getAttackType()->getName(translatedValue) +")";
str+="\n";
//splash radius
@ -367,7 +367,7 @@ string AttackStoppedCommandType::getDesc(const TotalUpgrade *totalUpgrade) const
}
}
str+="\n";
str+=attackSkillType->getBoostDesc();
str+=attackSkillType->getBoostDesc(translatedValue);
return str;
}
@ -458,11 +458,11 @@ void BuildCommandType::load(int id, const XmlNode *n, const string &dir,
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
string BuildCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{
string BuildCommandType::getDesc(const TotalUpgrade *totalUpgrade, bool translatedValue) const{
string str;
Lang &lang= Lang::getInstance();
str=getName(true)+"\n";
str=getName(translatedValue)+"\n";
str+= lang.get("BuildSpeed")+": "+ intToStr(buildSkillType->getSpeed())+"\n";
if(buildSkillType->getEpCost()!=0){
str+= lang.get("EpCost")+": "+intToStr(buildSkillType->getEpCost())+"\n";
@ -470,7 +470,7 @@ string BuildCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{
if(buildSkillType->getHpCost()!=0){
str+= lang.get("HpCost")+": "+intToStr(buildSkillType->getHpCost())+"\n";
}
str+=buildSkillType->getBoostDesc();
str+=buildSkillType->getBoostDesc(translatedValue);
return str;
}
@ -531,12 +531,12 @@ void HarvestCommandType::load(int id, const XmlNode *n, const string &dir,
hitsPerUnit= n->getChild("hits-per-unit")->getAttribute("value")->getIntValue();
}
string HarvestCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{
string HarvestCommandType::getDesc(const TotalUpgrade *totalUpgrade, bool translatedValue) const{
Lang &lang= Lang::getInstance();
string str;
str=getName(true)+"\n";
str=getName(translatedValue)+"\n";
str+= lang.get("HarvestSpeed")+": "+ intToStr(harvestSkillType->getSpeed()/hitsPerUnit)+"\n";
str+= lang.get("MaxLoad")+": "+ intToStr(maxLoad)+"\n";
str+= lang.get("LoadedSpeed")+": "+ intToStr(moveLoadedSkillType->getSpeed())+"\n";
@ -548,9 +548,9 @@ string HarvestCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{
}
str+=lang.get("Resources")+":\n";
for(int i=0; i<getHarvestedResourceCount(); ++i){
str+= getHarvestedResource(i)->getName(true)+"\n";
str+= getHarvestedResource(i)->getName(translatedValue)+"\n";
}
str+=harvestSkillType->getBoostDesc();
str+=harvestSkillType->getBoostDesc(translatedValue);
return str;
}
@ -586,12 +586,8 @@ void HarvestEmergencyReturnCommandType::load(int id, const XmlNode *n, const str
// CommandType::load(id, n, dir, tt, ft, ut, loadedFileList, parentLoader);
}
string HarvestEmergencyReturnCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{
//Lang &lang= Lang::getInstance();
string str;
str=getName(true)+"\n";
string HarvestEmergencyReturnCommandType::getDesc(const TotalUpgrade *totalUpgrade, bool translatedValue) const{
string str=getName(translatedValue)+"\n";
return str;
}
@ -645,11 +641,11 @@ void RepairCommandType::load(int id, const XmlNode *n, const string &dir,
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
string RepairCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{
string RepairCommandType::getDesc(const TotalUpgrade *totalUpgrade, bool translatedValue) const{
Lang &lang= Lang::getInstance();
string str;
str=getName(true)+"\n";
str=getName(translatedValue)+"\n";
str+= lang.get("RepairSpeed")+": "+ intToStr(repairSkillType->getSpeed())+"\n";
if(repairSkillType->getEpCost()!=0){
str+= lang.get("EpCost")+": "+intToStr(repairSkillType->getEpCost())+"\n";
@ -659,9 +655,9 @@ string RepairCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{
}
str+="\n"+lang.get("CanRepair")+":\n";
for(int i=0; i<repairableUnits.size(); ++i){
str+= (static_cast<const UnitType*>(repairableUnits[i]))->getName(true)+"\n";
str+= (static_cast<const UnitType*>(repairableUnits[i]))->getName(translatedValue)+"\n";
}
str+=repairSkillType->getBoostDesc();
str+=repairSkillType->getBoostDesc(translatedValue);
return str;
}
@ -713,8 +709,8 @@ void ProduceCommandType::load(int id, const XmlNode *n, const string &dir,
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
string ProduceCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{
string str=getName(true)+"\n";
string ProduceCommandType::getDesc(const TotalUpgrade *totalUpgrade, bool translatedValue) const{
string str=getName(translatedValue)+"\n";
Lang &lang= Lang::getInstance();
//prod speed
@ -731,8 +727,8 @@ string ProduceCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{
if(produceSkillType->getHpCost()!=0){
str+= lang.get("hpCost")+": "+intToStr(produceSkillType->getHpCost())+"\n";
}
str+= "\n" + getProducedUnit()->getReqDesc();
str+=produceSkillType->getBoostDesc();
str+= "\n" + getProducedUnit()->getReqDesc(translatedValue);
str+=produceSkillType->getBoostDesc(translatedValue);
return str;
}
@ -741,8 +737,8 @@ string ProduceCommandType::toString() const{
return lang.get("Produce");
}
string ProduceCommandType::getReqDesc() const{
return RequirableType::getReqDesc()+"\n"+getProducedUnit()->getReqDesc();
string ProduceCommandType::getReqDesc(bool translatedValue) const{
return RequirableType::getReqDesc(translatedValue)+"\n"+getProducedUnit()->getReqDesc(translatedValue);
}
const ProducibleType *ProduceCommandType::getProduced() const{
@ -780,18 +776,18 @@ void UpgradeCommandType::load(int id, const XmlNode *n, const string &dir,
}
string UpgradeCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{
string UpgradeCommandType::getDesc(const TotalUpgrade *totalUpgrade, bool translatedValue) const{
string str;
Lang &lang= Lang::getInstance();
str=getName(true)+"\n";
str=getName(translatedValue)+"\n";
str+= lang.get("UpgradeSpeed")+": "+ intToStr(upgradeSkillType->getSpeed())+"\n";
if(upgradeSkillType->getEpCost()!=0)
str+= lang.get("EpCost")+": "+intToStr(upgradeSkillType->getEpCost())+"\n";
if(upgradeSkillType->getHpCost()!=0)
str+= lang.get("HpCost")+": "+intToStr(upgradeSkillType->getHpCost())+"\n";
str+= "\n"+getProducedUpgrade()->getReqDesc();
str+=upgradeSkillType->getBoostDesc();
str+= "\n"+getProducedUpgrade()->getReqDesc(translatedValue);
str+=upgradeSkillType->getBoostDesc(translatedValue);
return str;
}
@ -800,8 +796,8 @@ string UpgradeCommandType::toString() const{
return lang.get("Upgrade");
}
string UpgradeCommandType::getReqDesc() const{
return RequirableType::getReqDesc()+"\n"+getProducedUpgrade()->getReqDesc();
string UpgradeCommandType::getReqDesc(bool translatedValue) const{
return RequirableType::getReqDesc(translatedValue)+"\n"+getProducedUpgrade()->getReqDesc(translatedValue);
}
const ProducibleType *UpgradeCommandType::getProduced() const{
@ -852,8 +848,8 @@ void MorphCommandType::load(int id, const XmlNode *n, const string &dir,
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
string MorphCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{
string str=getName(true)+"\n";
string MorphCommandType::getDesc(const TotalUpgrade *totalUpgrade, bool translatedValue) const{
string str=getName(translatedValue)+"\n";
Lang &lang= Lang::getInstance();
//prod speed
@ -872,8 +868,8 @@ string MorphCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{
str+= lang.get("Discount")+": "+intToStr(discount)+"%\n";
}
str+= "\n"+getProduced()->getReqDesc(ignoreResourceRequirements);
str+=morphSkillType->getBoostDesc();
str+= "\n"+getProduced()->getReqDesc(ignoreResourceRequirements,translatedValue);
str+=morphSkillType->getBoostDesc(translatedValue);
return str;
}
@ -883,8 +879,8 @@ string MorphCommandType::toString() const{
return lang.get("Morph");
}
string MorphCommandType::getReqDesc() const{
return RequirableType::getReqDesc() + "\n" + getProduced()->getReqDesc();
string MorphCommandType::getReqDesc(bool translatedValue) const{
return RequirableType::getReqDesc(translatedValue) + "\n" + getProduced()->getReqDesc(translatedValue);
}
const ProducibleType *MorphCommandType::getProduced() const{
@ -917,28 +913,8 @@ void SwitchTeamCommandType::load(int id, const XmlNode *n, const string &dir,
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
string SwitchTeamCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{
string str= getName(true)+"\n";
//Lang &lang= Lang::getInstance();
//prod speed
//str+= lang.get("MorphSpeed")+": "+ intToStr(morphSkillType->getSpeed())+"\n";
//mpcost
// if(morphSkillType->getEpCost()!=0){
// str+= lang.get("EpCost")+": "+intToStr(morphSkillType->getEpCost())+"\n";
// }
// if(morphSkillType->getHpCost()!=0){
// str+= lang.get("HpCost")+": "+intToStr(morphSkillType->getHpCost())+"\n";
// }
//
// //discount
// if(discount!=0){
// str+= lang.get("Discount")+": "+intToStr(discount)+"%\n";
// }
//
// str+= "\n"+getProduced()->getReqDesc();
string SwitchTeamCommandType::getDesc(const TotalUpgrade *totalUpgrade, bool translatedValue) const{
string str= getName(translatedValue)+"\n";
return str;
}

View File

@ -96,7 +96,7 @@ public:
virtual void load(int id, const XmlNode *n, const string &dir,
const TechTree *tt, const FactionType *ft, const UnitType &ut,
std::map<string,vector<pair<string, string> > > &loadedFileList, string parentLoader);
virtual string getDesc(const TotalUpgrade *totalUpgrade) const= 0;
virtual string getDesc(const TotalUpgrade *totalUpgrade, bool translatedValue) const= 0;
virtual string toString() const= 0;
virtual const ProducibleType *getProduced() const {return NULL;}
virtual Queueability isQueuable() const {return qOnRequest;}
@ -136,7 +136,7 @@ public:
virtual void load(int id, const XmlNode *n, const string &dir, const TechTree *tt,
const FactionType *ft, const UnitType &ut, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader);
virtual string getDesc(const TotalUpgrade *totalUpgrade) const;
virtual string getDesc(const TotalUpgrade *totalUpgrade, bool translatedValue) const;
virtual string toString() const;
virtual Queueability isQueuable() const {return qNever;}
virtual int getTypePriority() const {return 100000;}
@ -161,7 +161,7 @@ public:
virtual void load(int id, const XmlNode *n, const string &dir,
const TechTree *tt, const FactionType *ft, const UnitType &ut,
std::map<string,vector<pair<string, string> > > &loadedFileList, string parentLoader);
virtual string getDesc(const TotalUpgrade *totalUpgrade) const;
virtual string getDesc(const TotalUpgrade *totalUpgrade, bool translatedValue) const;
virtual string toString() const;
//get
@ -186,7 +186,7 @@ public:
virtual void load(int id, const XmlNode *n, const string &dir,
const TechTree *tt, const FactionType *ft, const UnitType &ut,
std::map<string,vector<pair<string, string> > > &loadedFileList, string parentLoader);
virtual string getDesc(const TotalUpgrade *totalUpgrade) const;
virtual string getDesc(const TotalUpgrade *totalUpgrade, bool translatedValue) const;
virtual string toString() const;
@ -212,7 +212,7 @@ public:
virtual void load(int id, const XmlNode *n, const string &dir,
const TechTree *tt, const FactionType *ft, const UnitType &ut,
std::map<string,vector<pair<string, string> > > &loadedFileList, string parentLoader);
virtual string getDesc(const TotalUpgrade *totalUpgrade) const;
virtual string getDesc(const TotalUpgrade *totalUpgrade, bool translatedValue) const;
virtual string toString() const;
//get
@ -242,7 +242,7 @@ public:
virtual void load(int id, const XmlNode *n, const string &dir,
const TechTree *tt, const FactionType *ft, const UnitType &ut,
std::map<string,vector<pair<string, string> > > &loadedFileList, string parentLoader);
virtual string getDesc(const TotalUpgrade *totalUpgrade) const;
virtual string getDesc(const TotalUpgrade *totalUpgrade, bool translatedValue) const;
virtual string toString() const;
//get
@ -277,7 +277,7 @@ public:
virtual void load(int id, const XmlNode *n, const string &dir,
const TechTree *tt, const FactionType *ft, const UnitType &ut,
std::map<string,vector<pair<string, string> > > &loadedFileList, string parentLoader);
virtual string getDesc(const TotalUpgrade *totalUpgrade) const;
virtual string getDesc(const TotalUpgrade *totalUpgrade, bool translatedValue) const;
virtual string toString() const;
virtual Queueability isQueuable() const {return qOnRequest;}
@ -308,7 +308,7 @@ public:
virtual void load(int id, const XmlNode *n, const string &dir,
const TechTree *tt, const FactionType *ft, const UnitType &ut,
std::map<string,vector<pair<string, string> > > &loadedFileList, string parentLoader);
virtual string getDesc(const TotalUpgrade *totalUpgrade) const;
virtual string getDesc(const TotalUpgrade *totalUpgrade, bool translatedValue) const;
virtual string toString() const;
virtual Queueability isQueuable() const {return qOnRequest;}
@ -334,7 +334,7 @@ public:
virtual void load(int id, const XmlNode *n, const string &dir,
const TechTree *tt, const FactionType *ft, const UnitType &ut,
std::map<string,vector<pair<string, string> > > &loadedFileList, string parentLoader);
virtual string getDesc(const TotalUpgrade *totalUpgrade) const;
virtual string getDesc(const TotalUpgrade *totalUpgrade, bool translatedValue) const;
virtual string toString() const;
//get
@ -364,8 +364,8 @@ public:
virtual void load(int id, const XmlNode *n, const string &dir,
const TechTree *tt, const FactionType *ft, const UnitType &ut,
std::map<string,vector<pair<string, string> > > &loadedFileList, string parentLoader);
virtual string getDesc(const TotalUpgrade *totalUpgrade) const;
virtual string getReqDesc() const;
virtual string getDesc(const TotalUpgrade *totalUpgrade, bool translatedValue) const;
virtual string getReqDesc(bool translatedValue) const;
virtual string toString() const;
virtual const ProducibleType *getProduced() const;
virtual Queueability isQueuable() const {return qAlways;}
@ -394,9 +394,9 @@ public:
virtual void load(int id, const XmlNode *n, const string &dir,
const TechTree *tt, const FactionType *ft, const UnitType &ut,
std::map<string,vector<pair<string, string> > > &loadedFileList, string parentLoader);
virtual string getDesc(const TotalUpgrade *totalUpgrade) const;
virtual string getDesc(const TotalUpgrade *totalUpgrade, bool translatedValue) const;
virtual string toString() const;
virtual string getReqDesc() const;
virtual string getReqDesc(bool translatedValue) const;
virtual const ProducibleType *getProduced() const;
virtual Queueability isQueuable() const {return qAlways;}
virtual int getTypePriority() const {return 15;}
@ -425,9 +425,9 @@ public:
virtual void load(int id, const XmlNode *n, const string &dir,
const TechTree *tt, const FactionType *ft, const UnitType &ut,
std::map<string,vector<pair<string, string> > > &loadedFileList, string parentLoader);
virtual string getDesc(const TotalUpgrade *totalUpgrade) const;
virtual string getDesc(const TotalUpgrade *totalUpgrade, bool translatedValue) const;
virtual string toString() const;
virtual string getReqDesc() const;
virtual string getReqDesc(bool translatedValue) const;
virtual const ProducibleType *getProduced() const;
Queueability isQueuable() const {return qOnlyLast;} //After morph anything can happen
@ -454,7 +454,7 @@ public:
virtual void load(int id, const XmlNode *n, const string &dir,
const TechTree *tt, const FactionType *ft, const UnitType &ut,
std::map<string,vector<pair<string, string> > > &loadedFileList, string parentLoader);
virtual string getDesc(const TotalUpgrade *totalUpgrade) const;
virtual string getDesc(const TotalUpgrade *totalUpgrade, bool translatedValue) const;
virtual string toString() const;
virtual bool usesPathfinder() const { return false; }

View File

@ -53,7 +53,7 @@ string DisplayableType::getName(bool translatedValue) const {
// class RequirableType
// =====================================================
string RequirableType::getReqDesc() const{
string RequirableType::getReqDesc(bool translatedValue) const{
bool anyReqs= false;
string reqString="";
@ -61,7 +61,7 @@ string RequirableType::getReqDesc() const{
if(getUnitReq(i) == NULL) {
throw megaglest_runtime_error("getUnitReq(i) == NULL");
}
reqString+= getUnitReq(i)->getName(true);
reqString+= getUnitReq(i)->getName(translatedValue);
reqString+= "\n";
anyReqs= true;
}
@ -71,12 +71,12 @@ string RequirableType::getReqDesc() const{
throw megaglest_runtime_error("getUpgradeReq(i) == NULL");
}
reqString+= getUpgradeReq(i)->getName(true);
reqString+= getUpgradeReq(i)->getName(translatedValue);
reqString+= "\n";
anyReqs= true;
}
string str= getName(true);
string str= getName(translatedValue);
if(anyReqs){
return str + " " + Lang::getInstance().get("Reqs") + ":\n" + reqString;
}
@ -128,15 +128,15 @@ const Resource *ProducibleType::getCost(const ResourceType *rt) const{
return NULL;
}
string ProducibleType::getReqDesc() const {
return getReqDesc(false);
string ProducibleType::getReqDesc(bool translatedValue) const {
return getReqDesc(false,translatedValue);
}
string ProducibleType::getResourceReqDesc(bool lineBreaks) const {
string ProducibleType::getResourceReqDesc(bool lineBreaks, bool translatedValue) const {
string str= "";
for(int i=0; i<getCostCount(); ++i){
if(getCost(i)->getAmount()!=0){
str+= getCost(i)->getType()->getName(true);
str+= getCost(i)->getType()->getName(translatedValue);
str+= ": "+ intToStr(getCost(i)->getAmount());
if(lineBreaks == true) {
str+= "\n";
@ -150,10 +150,10 @@ string ProducibleType::getResourceReqDesc(bool lineBreaks) const {
return str;
}
string ProducibleType::getUnitAndUpgradeReqDesc(bool lineBreaks) const {
string ProducibleType::getUnitAndUpgradeReqDesc(bool lineBreaks, bool translatedValue) const {
string str= "";
for(int i=0; i<getUnitReqCount(); ++i){
str+= getUnitReq(i)->getName(true);
str+= getUnitReq(i)->getName(translatedValue);
if(lineBreaks == true) {
str+= "\n";
}
@ -163,7 +163,7 @@ string ProducibleType::getUnitAndUpgradeReqDesc(bool lineBreaks) const {
}
for(int i=0; i<getUpgradeReqCount(); ++i){
str+= getUpgradeReq(i)->getName(true);
str+= getUpgradeReq(i)->getName(translatedValue);
if(lineBreaks == true) {
str+= "\n";
}
@ -175,13 +175,13 @@ string ProducibleType::getUnitAndUpgradeReqDesc(bool lineBreaks) const {
return str;
}
string ProducibleType::getReqDesc(bool ignoreResourceRequirements) const {
string str= getName(true) + " " + Lang::getInstance().get("Reqs") + ":\n";
string ProducibleType::getReqDesc(bool ignoreResourceRequirements, bool translatedValue) const {
string str= getName(translatedValue) + " " + Lang::getInstance().get("Reqs") + ":\n";
if(ignoreResourceRequirements == false) {
str+= getResourceReqDesc();
str+= getResourceReqDesc(true,translatedValue);
}
str+= getUnitAndUpgradeReqDesc();
str+= getUnitAndUpgradeReqDesc(true,translatedValue);
return str;
}

View File

@ -83,7 +83,7 @@ public:
const UnitType *getUnitReq(int i) const {return unitReqs[i];}
//other
virtual string getReqDesc() const;
virtual string getReqDesc(bool translatedValue) const;
//virtual void saveGame(XmlNode *rootNode) const;
};
@ -118,10 +118,10 @@ public:
//varios
void checkCostStrings(TechTree *techTree);
virtual string getReqDesc() const;
string getResourceReqDesc(bool lineBreaks=true) const;
string getUnitAndUpgradeReqDesc(bool lineBreaks=true) const;
string getReqDesc(bool ignoreResourceRequirements) const;
virtual string getReqDesc(bool translatedValue) const;
string getResourceReqDesc(bool lineBreaks,bool translatedValue) const;
string getUnitAndUpgradeReqDesc(bool lineBreaks, bool translatedValue) const;
string getReqDesc(bool ignoreResourceRequirements, bool translatedValue) const;
// virtual void saveGame(XmlNode *rootNode) const;
// void loadGame(const XmlNode *rootNode);

View File

@ -779,19 +779,19 @@ std::vector<std::string> FactionType::validateFactionTypeUpgradeTypes() {
const UnitType *FactionType::getUnitType(const string &name) const{
for(int i=0; i<unitTypes.size();i++){
if(unitTypes[i].getName()==name){
if(unitTypes[i].getName(false)==name){
return &unitTypes[i];
}
}
printf("In [%s::%s Line: %d] scanning [%s] size = " MG_SIZE_T_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),unitTypes.size());
for(int i=0; i<unitTypes.size();i++){
printf("In [%s::%s Line: %d] scanning [%s] idx = %d [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),i,unitTypes[i].getName().c_str());
printf("In [%s::%s Line: %d] scanning [%s] idx = %d [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),i,unitTypes[i].getName(false).c_str());
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scanning [%s] size = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),unitTypes.size());
for(int i=0; i<unitTypes.size();i++){
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scanning [%s] idx = %d [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),i,unitTypes[i].getName().c_str());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scanning [%s] idx = %d [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),i,unitTypes[i].getName(false).c_str());
}
throw megaglest_runtime_error("Unit type not found: [" + name + "] in faction type [" + this->name + "]");
@ -806,12 +806,12 @@ const UnitType *FactionType::getUnitTypeById(int id) const{
printf("In [%s::%s Line: %d] scanning [%d] size = " MG_SIZE_T_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,id,unitTypes.size());
for(int i=0; i<unitTypes.size();i++){
printf("In [%s::%s Line: %d] scanning [%s] idx = %d [%s][%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),i,unitTypes[i].getName().c_str(),unitTypes[i].getId());
printf("In [%s::%s Line: %d] scanning [%s] idx = %d [%s][%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),i,unitTypes[i].getName(false).c_str(),unitTypes[i].getId());
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scanning [%s] size = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),unitTypes.size());
for(int i=0; i<unitTypes.size();i++){
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scanning [%s] idx = %d [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),i,unitTypes[i].getName().c_str());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scanning [%s] idx = %d [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),i,unitTypes[i].getName(false).c_str());
}
throw megaglest_runtime_error("Unit type not found: [" + intToStr(id) + "] in faction type [" + this->name + "]");
@ -902,7 +902,7 @@ std::string FactionType::toString() const {
result += "Upgrade Type List count = " + intToStr(this->getUpgradeTypeCount()) + "\n";
for(int i=0; i<upgradeTypes.size();i++) {
result += "index: " + intToStr(i) + " " + upgradeTypes[i].getReqDesc() + "\n";
result += "index: " + intToStr(i) + " " + upgradeTypes[i].getReqDesc(false) + "\n";
}
return result;
@ -924,18 +924,18 @@ void FactionType::saveGame(XmlNode *rootNode) {
// UnitTypes unitTypes;
for(unsigned int i = 0; i < unitTypes.size(); ++i) {
XmlNode *unitTypesNode = factionTypeNode->addChild("unitTypes");
unitTypesNode->addAttribute("name",unitTypes[i].getName(), mapTagReplacements);
unitTypesNode->addAttribute("name",unitTypes[i].getName(false), mapTagReplacements);
}
// UpgradeTypes upgradeTypes;
for(unsigned int i = 0; i < upgradeTypes.size(); ++i) {
XmlNode *upgradeTypesNode = factionTypeNode->addChild("upgradeTypes");
upgradeTypesNode->addAttribute("name",upgradeTypes[i].getName(), mapTagReplacements);
upgradeTypesNode->addAttribute("name",upgradeTypes[i].getName(false), mapTagReplacements);
}
// StartingUnits startingUnits;
for(unsigned int i = 0; i < startingUnits.size(); ++i) {
XmlNode *startingUnitsNode = factionTypeNode->addChild("startingUnits");
startingUnitsNode->addAttribute("name",startingUnits[i].first->getName(), mapTagReplacements);
startingUnitsNode->addAttribute("name",startingUnits[i].first->getName(false), mapTagReplacements);
startingUnitsNode->addAttribute("count",intToStr(startingUnits[i].second), mapTagReplacements);
}
@ -957,7 +957,7 @@ void FactionType::saveGame(XmlNode *rootNode) {
XmlNode *mapAIBehaviorUnitCategoriesNode = factionTypeNode->addChild("mapAIBehaviorUnitCategories");
mapAIBehaviorUnitCategoriesNode->addAttribute("key",intToStr(iterMap->first), mapTagReplacements);
mapAIBehaviorUnitCategoriesNode->addAttribute("unitType",item.first->getName(), mapTagReplacements);
mapAIBehaviorUnitCategoriesNode->addAttribute("unitType",item.first->getName(false), mapTagReplacements);
mapAIBehaviorUnitCategoriesNode->addAttribute("count",intToStr(item.second), mapTagReplacements);
}
}

View File

@ -150,7 +150,7 @@ bool AttackBoost::isAffected(const Unit *source, const Unit *dest) const {
return result;
}
string AttackBoost::getDesc() const{
string AttackBoost::getDesc(bool translatedValue) const{
Lang &lang= Lang::getInstance();
string str= "";
string indent=" ";
@ -166,7 +166,7 @@ string AttackBoost::getDesc() const{
allowIt=lang.get("False");
str += indent+lang.get("allowMultiBoost") + ": " + allowIt +"\n";
}
str+=boostUpgrade.getDesc();
str+=boostUpgrade.getDesc(translatedValue);
if(targetType==abtAlly)
{
@ -191,7 +191,7 @@ string AttackBoost::getDesc() const{
if(boostUnitList.empty() == false) {
for(int i=0; i<boostUnitList.size(); ++i){
str+= " "+boostUnitList[i]->getName(true)+"\n";
str+= " "+boostUnitList[i]->getName(translatedValue)+"\n";
}
}
else
@ -221,7 +221,7 @@ void AttackBoost::saveGame(XmlNode *rootNode) const {
for(unsigned int i = 0; i < boostUnitList.size(); ++i) {
const UnitType *ut = boostUnitList[i];
XmlNode *unitTypeNode = attackBoostNode->addChild("UnitType");
unitTypeNode->addAttribute("name",ut->getName(), mapTagReplacements);
unitTypeNode->addAttribute("name",ut->getName(false), mapTagReplacements);
}
// UpgradeTypeBase boostUpgrade;
boostUpgrade.saveGame(attackBoostNode);
@ -877,7 +877,7 @@ void AttackSkillType::saveGame(XmlNode *rootNode) {
attackSkillTypeNode->addAttribute("attackRange",intToStr(attackRange), mapTagReplacements);
// const AttackType *attackType;
if(attackType != NULL) {
attackSkillTypeNode->addAttribute("attackType",attackType->getName(), mapTagReplacements);
attackSkillTypeNode->addAttribute("attackType",attackType->getName(false), mapTagReplacements);
}
// bool attackFields[fieldCount];
for(unsigned int i = 0; i < fieldCount; ++i) {

View File

@ -106,7 +106,7 @@ public:
string name;
bool isAffected(const Unit *source, const Unit *dest) const;
virtual string getDesc() const;
virtual string getDesc(bool translatedValue) const;
virtual void saveGame(XmlNode *rootNode) const;
};
@ -188,7 +188,7 @@ public:
virtual int getTotalSpeed(const TotalUpgrade *) const {return speed;}
static string skillClassToStr(SkillClass skillClass);
static string fieldToStr(Field field);
virtual string getBoostDesc() const {return attackBoost.getDesc();}
virtual string getBoostDesc(bool translatedValue) const {return attackBoost.getDesc(translatedValue);}
virtual void saveGame(XmlNode *rootNode);
};

View File

@ -44,6 +44,7 @@ TechTree::TechTree(const vector<string> pathList) {
armorTypes.clear();
attackTypes.clear();
translatedTechNames.clear();
translatedTechFactionNames.clear();
}
string TechTree::getName(bool translatedValue) const {
@ -53,14 +54,14 @@ string TechTree::getName(bool translatedValue) const {
return lang.getTechTreeString("TechTreeName",name.c_str());
}
string TechTree::getTranslatedName(string techName, bool forceLoad) {
string TechTree::getTranslatedName(string techName, bool forceLoad, bool forceTechtreeActiveFile) {
string result = techName;
if(translatedTechNames.find(techName) != translatedTechNames.end()) {
if(forceTechtreeActiveFile == false &&
translatedTechNames.find(techName) != translatedTechNames.end()) {
result = translatedTechNames[techName];
}
else {
//TechTree techTree(pathList);
name = "";
string path = findPath(techName);
if(path != "") {
@ -81,6 +82,24 @@ string TechTree::getTranslatedName(string techName, bool forceLoad) {
return result;
}
string TechTree::getTranslatedFactionName(string techName, string factionName) {
std::map<string,std::map<string,string> >::iterator iterMap = translatedTechFactionNames.find(techName);
if(iterMap != translatedTechFactionNames.end()) {
if(iterMap->second.find(factionName) != iterMap->second.end()) {
return iterMap->second.find(factionName)->second;
}
}
getTranslatedName(techName,false,true);
Lang &lang = Lang::getInstance();
string result = lang.getTechTreeString("FactionName_" + factionName,factionName.c_str());
translatedTechFactionNames[techName][factionName] = result;
//printf("Translated faction for Tech [%s] faction [%s] result [%s]\n",techName.c_str(),factionName.c_str(),result.c_str());
return result;
}
Checksum TechTree::loadTech(const string &techName,
set<string> &factions, Checksum* checksum, std::map<string,vector<pair<string, string> > > &loadedFileList) {
name = "";
@ -248,7 +267,7 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
Lang::getInstance().get("Faction").c_str(),
i+1,
(int)factions.size(),
factionName.c_str());
this->getTranslatedFactionName(name,factionName).c_str());
Logger &logger= Logger::getInstance();
logger.setState(szBuf);
logger.setProgress((int)((((double)i) / (double)factions.size()) * 100.0));
@ -409,7 +428,7 @@ const ResourceType *TechTree::getResourceType(const string &name) const{
const ArmorType *TechTree::getArmorType(const string &name) const{
for(int i=0; i<armorTypes.size(); ++i){
if(armorTypes[i].getName()==name){
if(armorTypes[i].getName(false)==name){
return &armorTypes[i];
}
}
@ -419,7 +438,7 @@ const ArmorType *TechTree::getArmorType(const string &name) const{
const AttackType *TechTree::getAttackType(const string &name) const{
for(int i=0; i<attackTypes.size(); ++i){
if(attackTypes[i].getName()==name){
if(attackTypes[i].getName(false)==name){
return &attackTypes[i];
}
}

View File

@ -54,6 +54,7 @@ private:
Checksum checksumValue;
std::map<string,string> translatedTechNames;
std::map<string,std::map<string,string> > translatedTechFactionNames;
public:
Checksum loadTech(const string &techName,
@ -73,7 +74,9 @@ public:
const FactionType *getType(int i) const {return &factionTypes[i];}
const ResourceType *getResourceType(int i) const {return &resourceTypes[i];}
string getName(bool translatedValue=false) const;
string getTranslatedName(string techName, bool forceLoad=false);
string getTranslatedName(string techName, bool forceLoad=false, bool forceTechtreeActiveFile=false);
string getTranslatedFactionName(string techName, string factionName);
vector<string> getPathList() const {return pathList;}
//const string &getDesc() const {return desc;}

View File

@ -417,7 +417,7 @@ void UnitType::loaddd(int id,const string &dir, const TechTree *techTree, const
sortedItems[name] = 0;
}
if(hasDup) {
printf("WARNING, unit type [%s] has one or more duplicate unit requirements\n",this->getName().c_str());
printf("WARNING, unit type [%s] has one or more duplicate unit requirements\n",this->getName(false).c_str());
}
for(std::map<string,int>::iterator iterMap = sortedItems.begin();
@ -441,7 +441,7 @@ void UnitType::loaddd(int id,const string &dir, const TechTree *techTree, const
}
if(hasDup) {
printf("WARNING, unit type [%s] has one or more duplicate upgrade requirements\n",this->getName().c_str());
printf("WARNING, unit type [%s] has one or more duplicate upgrade requirements\n",this->getName(false).c_str());
}
for(std::map<string,int>::iterator iterMap = sortedItems.begin();
@ -467,7 +467,7 @@ void UnitType::loaddd(int id,const string &dir, const TechTree *techTree, const
//if(hasDup || sortedItems.size() != costs.size()) printf("Found duplicate resource requirement, costs.size() = %d sortedItems.size() = %d\n",costs.size(),sortedItems.size());
if(hasDup) {
printf("WARNING, unit type [%s] has one or more duplicate resource requirements\n",this->getName().c_str());
printf("WARNING, unit type [%s] has one or more duplicate resource requirements\n",this->getName(false).c_str());
}
if(sortedItems.size() < costs.size()) {
@ -498,7 +498,7 @@ void UnitType::loaddd(int id,const string &dir, const TechTree *techTree, const
}
if(hasDup) {
printf("WARNING, unit type [%s] has one or more duplicate stored resources\n",this->getName().c_str());
printf("WARNING, unit type [%s] has one or more duplicate stored resources\n",this->getName(false).c_str());
}
if(sortedItems.size() < storedResources.size()) {
@ -1030,9 +1030,9 @@ string UnitType::getCommandTypeListDesc() const {
}
string UnitType::getReqDesc() const{
string UnitType::getReqDesc(bool translatedValue) const{
Lang &lang= Lang::getInstance();
string desc = "Limits: ";
//string desc = "Limits: ";
string resultTxt="";
checkItemInVault(&(this->maxUnitCount),this->maxUnitCount);
@ -1040,9 +1040,9 @@ string UnitType::getReqDesc() const{
resultTxt += "\n" + lang.get("MaxUnitCount") + " " + intToStr(getMaxUnitCount());
}
if(resultTxt == "")
return ProducibleType::getReqDesc();
return ProducibleType::getReqDesc(translatedValue);
else
return ProducibleType::getReqDesc()+"\nLimits: "+resultTxt;
return ProducibleType::getReqDesc(translatedValue)+"\n" + lang.get("Limits") + " " + resultTxt;
}
string UnitType::getName(bool translatedValue) const {
@ -1071,7 +1071,7 @@ std::string UnitType::toString() const {
result += " armor = " + intToStr(armor);
if(armorType != NULL) {
result += " armorType Name: [" + armorType->getName() + " id = " + intToStr(armorType->getId());
result += " armorType Name: [" + armorType->getName(false) + " id = " + intToStr(armorType->getId());
}
result += " light = " + intToStr(light);
@ -1104,7 +1104,7 @@ std::string UnitType::toString() const {
result += " storedResources: [" + intToStr(storedResources.size()) + "]";
for(int i = 0; i < storedResources.size(); ++i) {
result += " i = " + intToStr(i) + " " + storedResources[i].getDescription();
result += " i = " + intToStr(i) + " " + storedResources[i].getDescription(false);
}
result += " levels: [" + intToStr(levels.size()) + "]";

View File

@ -253,7 +253,7 @@ public:
inline void setRotatedBuildPos(float value) { rotatedBuildPos = value; }
//other
virtual string getReqDesc() const;
virtual string getReqDesc(bool translatedValue) const;
std::string toString() const;

View File

@ -237,7 +237,7 @@ int UpgradeTypeBase::getProdSpeed(const SkillType *st) const {
}
}
string UpgradeTypeBase::getDesc() const{
string UpgradeTypeBase::getDesc(bool translatedValue) const{
string str="";
string indent="->";
@ -558,18 +558,18 @@ string UpgradeType::getName(bool translatedValue) const {
return lang.getTechTreeString("UpgradeTypeName_" + name,name.c_str());
}
string UpgradeType::getReqDesc() const{
string UpgradeType::getReqDesc(bool translatedValue) const{
Lang &lang= Lang::getInstance();
string str= ProducibleType::getReqDesc();
string str= ProducibleType::getReqDesc(translatedValue);
string indent=" ";
if(getEffectCount()>0){
str+= "\n"+ lang.get("Upgrades")+"\n";
}
str+=UpgradeTypeBase::getDesc();
str+=UpgradeTypeBase::getDesc(translatedValue);
if(getEffectCount()>0){
str+= lang.get("AffectedUnits")+"\n";
for(int i=0; i<getEffectCount(); ++i){
str+= indent+getEffect(i)->getName(true)+"\n";
str+= indent+getEffect(i)->getName(translatedValue)+"\n";
}
}
return str;

View File

@ -110,7 +110,8 @@ public:
void load(const XmlNode *upgradeNode, string upgradename);
virtual string getDesc() const;
virtual string getDesc(bool translatedValue) const;
std::string toString() const {
std::string result = "";
@ -168,7 +169,7 @@ public:
bool isAffected(const UnitType *unitType) const;
//other methods
virtual string getReqDesc() const;
virtual string getReqDesc(bool translatedValue) const;
//virtual void saveGame(XmlNode *rootNode) const;
//virtual void loadGame(const XmlNode *rootNode);

View File

@ -1346,7 +1346,7 @@ void Map::putUnitCellsPrivate(Unit *unit, const Vec2i &pos, const UnitType *ut,
}
else {
char szBuf[8096]="";
snprintf(szBuf,8096,"Trying to move unit [%d - %s] into occupied cell [%s] and field = %d, unit already in cell [%d - %s] ",unit->getId(),unit->getType()->getName().c_str(),pos.getString().c_str(),field,getCell(currPos)->getUnit(field)->getId(),getCell(currPos)->getUnit(field)->getType()->getName().c_str());
snprintf(szBuf,8096,"Trying to move unit [%d - %s] into occupied cell [%s] and field = %d, unit already in cell [%d - %s] ",unit->getId(),unit->getType()->getName(false).c_str(),pos.getString().c_str(),field,getCell(currPos)->getUnit(field)->getId(),getCell(currPos)->getUnit(field)->getType()->getName(false).c_str());
throw megaglest_runtime_error(szBuf);
}
}

View File

@ -167,7 +167,7 @@ bool UnitUpdater::updateUnit(Unit *unit) {
if(unit->getCurrCommand() != NULL &&
unit->getCurrCommand()->getCommandType()->getClass() == ccAttackStopped) {
reQueueHoldPosition = true;
holdPositionName = unit->getCurrCommand()->getCommandType()->getName();
holdPositionName = unit->getCurrCommand()->getCommandType()->getName(false);
}
unit->setCurrSkill(scStop);
@ -180,7 +180,7 @@ bool UnitUpdater::updateUnit(Unit *unit) {
const CommandType* ct= ut->getCommandType(i);
if(ct != NULL && ct->getClass() == ccAttackStopped) {
const AttackStoppedCommandType *act= static_cast<const AttackStoppedCommandType*>(ct);
if(act != NULL && act->getName() == holdPositionName) {
if(act != NULL && act->getName(false) == holdPositionName) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
//printf("Re-Queing hold pos = %d, ep = %d skillep = %d skillname [%s]\n ",unit->getFaction()->reqsOk(act),unit->getEp(),act->getAttackSkillType()->getEpCost(),act->getName().c_str());
@ -300,7 +300,7 @@ void UnitUpdater::updateUnitCommand(Unit *unit, int frameIndex) {
//if unit has command process it
bool hasCommand = (unit->anyCommand());
if((minorDebugPerformance && frameIndex > 0) && chrono.getMillis() >= 1) printf("UnitUpdate [%d - %s] #1-unit threaded updates on frame: %d took [%lld] msecs\n",unit->getId(),unit->getType()->getName().c_str(),frameIndex,(long long int)chrono.getMillis());
if((minorDebugPerformance && frameIndex > 0) && chrono.getMillis() >= 1) printf("UnitUpdate [%d - %s] #1-unit threaded updates on frame: %d took [%lld] msecs\n",unit->getId(),unit->getType()->getName(false).c_str(),frameIndex,(long long int)chrono.getMillis());
int64 elapsed1 = 0;
if(minorDebugPerformance && frameIndex > 0) elapsed1 = chrono.getMillis();
@ -327,7 +327,7 @@ void UnitUpdater::updateUnitCommand(Unit *unit, int frameIndex) {
if((minorDebugPerformance && frameIndex > 0) && (chrono.getMillis() - elapsed1) >= 1) {
//CommandClass cc = unit->getCurrCommand()->getCommandType()->commandTypeClass;
printf("UnitUpdate [%d - %s] #2-unit threaded updates on frame: %d commandUsesPathFinder = %d took [%lld] msecs\nCommand: %s\n",unit->getId(),unit->getType()->getName().c_str(),frameIndex,commandUsesPathFinder,(long long int)chrono.getMillis() - elapsed1,unit->getCurrCommand()->toString().c_str());
printf("UnitUpdate [%d - %s] #2-unit threaded updates on frame: %d commandUsesPathFinder = %d took [%lld] msecs\nCommand: %s\n",unit->getId(),unit->getType()->getName(false).c_str(),frameIndex,commandUsesPathFinder,(long long int)chrono.getMillis() - elapsed1,unit->getCurrCommand()->toString().c_str());
}
}
@ -348,7 +348,7 @@ void UnitUpdater::updateUnitCommand(Unit *unit, int frameIndex) {
}
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld --------------------------- [END OF METHOD] ---------------------------\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
if((minorDebugPerformance && frameIndex > 0) && chrono.getMillis() >= 1) printf("UnitUpdate [%d - %s] #3-unit threaded updates on frame: %d took [%lld] msecs\n",unit->getId(),unit->getType()->getName().c_str(),frameIndex,(long long int)chrono.getMillis());
if((minorDebugPerformance && frameIndex > 0) && chrono.getMillis() >= 1) printf("UnitUpdate [%d - %s] #3-unit threaded updates on frame: %d took [%lld] msecs\n",unit->getId(),unit->getType()->getName(false).c_str(),frameIndex,(long long int)chrono.getMillis());
}
// ==================== updateStop ====================
@ -438,7 +438,7 @@ void UnitUpdater::updateMove(Unit *unit, int frameIndex) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0) {
char szBuf[8096]="";
snprintf(szBuf,8096,"[updateMove] pos [%s] unit [%d - %s] cmd [%s]",pos.getString().c_str(),unit->getId(),unit->getFullName().c_str(),command->toString().c_str());
snprintf(szBuf,8096,"[updateMove] pos [%s] unit [%d - %s] cmd [%s]",pos.getString().c_str(),unit->getId(),unit->getFullName(false).c_str(),command->toString().c_str());
unit->logSynchData(__FILE__,__LINE__,szBuf);
}
// else if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex >= 0) {
@ -958,7 +958,7 @@ void UnitUpdater::updateBuild(Unit *unit, int frameIndex) {
builtUnit->create();
if(builtUnitType->hasSkillClass(scBeBuilt) == false) {
throw megaglest_runtime_error("Unit [" + builtUnitType->getName() + "] has no be_built skill, producer was [" + intToStr(unit->getId()) + " - " + unit->getType()->getName() + "].");
throw megaglest_runtime_error("Unit [" + builtUnitType->getName(false) + "] has no be_built skill, producer was [" + intToStr(unit->getId()) + " - " + unit->getType()->getName(false) + "].");
}
builtUnit->setCurrSkill(scBeBuilt);
@ -1762,7 +1762,7 @@ void UnitUpdater::updateRepair(Unit *unit, int frameIndex) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] unit = %p\n",__FILE__,__FUNCTION__,__LINE__,unit);
//if(unit != NULL) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] unit doing the repair [%s] - %d\n",__FILE__,__FUNCTION__,__LINE__,unit->getFullName().c_str(),unit->getId());
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] unit doing the repair [%s] - %d\n",__FILE__,__FUNCTION__,__LINE__,unit->getFullName(false).c_str(),unit->getId());
//}
Command *command= unit->getCurrCommand();
@ -1777,7 +1777,7 @@ void UnitUpdater::updateRepair(Unit *unit, int frameIndex) {
}
if(repaired != NULL) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] unit to repair [%s] - %d\n",__FILE__,__FUNCTION__,__LINE__,repaired->getFullName().c_str(),repaired->getId());
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] unit to repair [%s] - %d\n",__FILE__,__FUNCTION__,__LINE__,repaired->getFullName(false).c_str(),repaired->getId());
}
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
@ -1786,7 +1786,7 @@ void UnitUpdater::updateRepair(Unit *unit, int frameIndex) {
Unit *peerUnitBuilder = findPeerUnitBuilder(unit);
if(peerUnitBuilder != NULL) {
SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] unit peer [%s] - %d\n",__FILE__,__FUNCTION__,__LINE__,peerUnitBuilder->getFullName().c_str(),peerUnitBuilder->getId());
SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] unit peer [%s] - %d\n",__FILE__,__FUNCTION__,__LINE__,peerUnitBuilder->getFullName(false).c_str(),peerUnitBuilder->getId());
}
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());
@ -1881,7 +1881,7 @@ void UnitUpdater::updateRepair(Unit *unit, int frameIndex) {
}
}
else {
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] unit to repair[%s]\n",__FILE__,__FUNCTION__,__LINE__,repaired->getFullName().c_str());
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] unit to repair[%s]\n",__FILE__,__FUNCTION__,__LINE__,repaired->getFullName(false).c_str());
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] repaired = %p, nextToRepaired = %d, unit->getCurrSkill()->getClass() = %d\n",__FILE__,__FUNCTION__,__LINE__,repaired,nextToRepaired,unit->getCurrSkill()->getClass());

View File

@ -1234,13 +1234,13 @@ void World::morphToUnit(int unitId,const string &morphName,bool ignoreRequiremen
for(int i = 0; i < unit->getType()->getCommandTypeCount(); ++i) {
const CommandType *ct = unit->getType()->getCommandType(i);
const MorphCommandType *mct = dynamic_cast<const MorphCommandType *>(ct);
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(mct != NULL && mct->getName(false) == 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(false).c_str());
std::pair<CommandResult,string> cr(crFailUndefined,"");
try {
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(false).c_str(),mct->getUpgradeReqCount());
unit->setIgnoreCheckCommand(true);
}
@ -1261,7 +1261,7 @@ void World::morphToUnit(int unitId,const string &morphName,bool ignoreRequiremen
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.first);
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(false).c_str(),cr.first);
break;
}
@ -1412,9 +1412,9 @@ void World::givePositionCommand(int unitId, const string &commandName, const Vec
}
if(unit->getType()->getFirstCtOfClass(cc) == NULL) {
throw megaglest_runtime_error("Invalid commmand: [" + commandName + "] for unit: [" + unit->getType()->getName() + "] id [" + intToStr(unit->getId()) + "]");
throw megaglest_runtime_error("Invalid commmand: [" + commandName + "] for unit: [" + unit->getType()->getName(false) + "] id [" + intToStr(unit->getId()) + "]");
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] cc = %d Unit [%s]\n",__FILE__,__FUNCTION__,__LINE__,cc,unit->getFullName().c_str());
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] cc = %d Unit [%s]\n",__FILE__,__FUNCTION__,__LINE__,cc,unit->getFullName(false).c_str());
unit->giveCommand(new Command( unit->getType()->getFirstCtOfClass(cc), pos ));
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
@ -1428,7 +1428,7 @@ void World::giveStopCommand(int unitId) {
if(unit != NULL) {
const CommandType *ct = unit->getType()->getFirstCtOfClass(ccStop);
if(ct != NULL) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] Unit [%s] will stop\n",__FILE__,__FUNCTION__,__LINE__,unit->getFullName().c_str());
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] Unit [%s] will stop\n",__FILE__,__FUNCTION__,__LINE__,unit->getFullName(false).c_str());
unit->giveCommand(new Command(ct));
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@ -1488,7 +1488,7 @@ void World::giveAttackCommand(int unitId, int unitToAttackId) {
if(targetUnit != NULL) {
const CommandType *ct = unit->getType()->getFirstAttackCommand(targetUnit->getCurrField());
if(ct != NULL) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] Unit [%s] is attacking [%s]\n",__FILE__,__FUNCTION__,__LINE__,unit->getFullName().c_str(),targetUnit->getFullName().c_str());
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] Unit [%s] is attacking [%s]\n",__FILE__,__FUNCTION__,__LINE__,unit->getFullName(false).c_str(),targetUnit->getFullName(false).c_str());
unit->giveCommand(new Command(ct,targetUnit));
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
@ -1523,7 +1523,7 @@ void World::giveProductionCommand(int unitId, const string &producedName) {
if(ct != NULL && ct->getClass() == ccProduce) {
const ProduceCommandType *pct= dynamic_cast<const ProduceCommandType*>(ct);
if(pct != NULL && pct->getProducedUnit() != NULL &&
pct->getProducedUnit()->getName() == producedName) {
pct->getProducedUnit()->getName(false) == producedName) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
//printf("File: %s line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__);
@ -1552,7 +1552,7 @@ void World::giveAttackStoppedCommand(int unitId, const string &itemName, bool ig
const CommandType* ct= ut->getCommandType(i);
if(ct != NULL && ct->getClass() == ccAttackStopped) {
const AttackStoppedCommandType *act= static_cast<const AttackStoppedCommandType*>(ct);
if(act != NULL && act->getName() == itemName) {
if(act != NULL && act->getName(false) == itemName) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
try {
@ -1643,10 +1643,10 @@ void World::moveToUnit(int unitId, int destUnitId) {
Unit* unit= findUnitById(unitId);
if(unit != NULL) {
CommandClass cc= ccMove;
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] cc = %d Unit [%s]\n",__FILE__,__FUNCTION__,__LINE__,cc,unit->getFullName().c_str());
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] cc = %d Unit [%s]\n",__FILE__,__FUNCTION__,__LINE__,cc,unit->getFullName(false).c_str());
Unit* destUnit = findUnitById(destUnitId);
if(destUnit != NULL) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] cc = %d Unit [%s] destUnit [%s]\n",__FILE__,__FUNCTION__,__LINE__,cc,unit->getFullName().c_str(),destUnit->getFullName().c_str());
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] cc = %d Unit [%s] destUnit [%s]\n",__FILE__,__FUNCTION__,__LINE__,cc,unit->getFullName(false).c_str(),destUnit->getFullName(false).c_str());
unit->giveCommand(new Command( unit->getType()->getFirstCtOfClass(cc), destUnit));
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
@ -1845,7 +1845,7 @@ const string World::getUnitName(int unitId) {
if(unit == NULL) {
throw megaglest_runtime_error("Can not find Faction unit to get position unitId = " + intToStr(unitId));
}
return unit->getFullName();
return unit->getFullName(game->showTranslatedTechTree());
}
int World::getUnitCount(int factionIndex) {
@ -1873,7 +1873,7 @@ int World::getUnitCountOfType(int factionIndex, const string &typeName) {
for(int i= 0; i< faction->getUnitCount(); ++i) {
const Unit* unit= faction->getUnit(i);
if(unit != NULL && unit->isAlive() && unit->getType()->getName() == typeName) {
if(unit != NULL && unit->isAlive() && unit->getType()->getName(false) == typeName) {
++count;
}
}
@ -2118,7 +2118,7 @@ void World::initUnitsForScenario() {
//unit->born();
}
else {
string unitName = unit->getType()->getName();
string unitName = unit->getType()->getName(false);
delete unit;
unit = NULL;
throw megaglest_runtime_error("Unit: " + unitName + " can't be placed, this error is caused because there\nis not enough room to put all units near their start location.\nmake a better/larger map. Faction: #" + intToStr(i) + " name: " + ft->getName(false));
@ -2144,7 +2144,7 @@ void World::placeUnitAtLocation(const Vec2i &location, int radius, Unit *unit, b
unit->born(NULL);
}
else {
string unitName = unit->getType()->getName();
string unitName = unit->getType()->getName(false);
string unitFactionName = unit->getFaction()->getType()->getName(false);
int unitFactionIndex = unit->getFactionIndex();
@ -2818,7 +2818,7 @@ std::string World::DumpWorldToLog(bool consoleBasicInfoOnly) const {
for(int j= unitCount - 1; j >= 0; j--){
Unit *unit= getFaction(i)->getUnit(j);
if(unit->getToBeUndertaken()) {
logFile << "Undertake unit index = " << j << unit->getFullName() << std::endl;
logFile << "Undertake unit index = " << j << unit->getFullName(false) << std::endl;
}
}
}