void CvTreasury::LogExpenditure(CvString strExpenditure, int iAmount, int iColumn) { if(!(GC.getLogging() && GC.getAILogging())) { return; } // don't log minor civs for now if(m_pPlayer->isMinorCiv()) { return; } static bool bFirstRun = true; bool bBuildHeader = false; CvString strHeader; if(bFirstRun) { bFirstRun = false; bBuildHeader = true; } CvString strLog; // Find the name of this civ and city CvString strPlayerName; strPlayerName = m_pPlayer->getCivilizationShortDescription(); CvString strLogName; // Open the log file if(GC.getPlayerAndCityAILogSplit()) { strLogName = "ExpenditureLog_" + strPlayerName + ".csv"; } else { strLogName = "ExpenditureLog.csv"; } FILogFile* pLog; pLog = LOGFILEMGR.GetLog(strLogName, FILogFile::kDontTimeStamp); CvString str; // civ name TreasuryHelpers::AppendToLog(strHeader, strLog, "Civ Name", strPlayerName); // turn TreasuryHelpers::AppendToLog(strHeader, strLog, "Turn", GC.getGame().getGameTurn()); // treasury at turn start TreasuryHelpers::AppendToLog(strHeader, strLog, "Treasury Before Purchase", m_pPlayer->GetTreasury()->GetGold()); // Cost of Plot if (iColumn == 1){ TreasuryHelpers::AppendToLog(strHeader, strLog, "Cost of Plot:", iAmount); } else{ TreasuryHelpers::AppendToLog(strHeader, strLog, "Cost of Plot:", 0); } // City Expenditure and Amount if (iColumn == 2){ TreasuryHelpers::AppendToLog(strHeader, strLog, "City Bought:", strExpenditure); TreasuryHelpers::AppendToLog(strHeader, strLog, "City Spent:", iAmount); } else{ TreasuryHelpers::AppendToLog(strHeader, strLog, "City Bought:", ""); TreasuryHelpers::AppendToLog(strHeader, strLog, "City Spent:", 0); } // Unit Upgrade and cost if (iColumn == 3){ TreasuryHelpers::AppendToLog(strHeader, strLog, "Unit Upgraded:", strExpenditure); TreasuryHelpers::AppendToLog(strHeader, strLog, "Spent on Upgrade:", iAmount); } else{ TreasuryHelpers::AppendToLog(strHeader, strLog, "Unit Upgrade:", ""); TreasuryHelpers::AppendToLog(strHeader, strLog, "Spent on Upgrade:", 0); } // City State Gifted and Amount if (iColumn == 4){ TreasuryHelpers::AppendToLog(strHeader, strLog, "City State Gold Gifted:", strExpenditure); TreasuryHelpers::AppendToLog(strHeader, strLog, "Gold Gift Amount:", iAmount); } else{ TreasuryHelpers::AppendToLog(strHeader, strLog, "City State Gold Gifted:", ""); TreasuryHelpers::AppendToLog(strHeader, strLog, "Gold Gift Amount:", 0); } // City State Improved and Amount if (iColumn == 5){ TreasuryHelpers::AppendToLog(strHeader, strLog, "City State Improved:", strExpenditure); TreasuryHelpers::AppendToLog(strHeader, strLog, "Gold for Improvement Amount:", iAmount); } else{ TreasuryHelpers::AppendToLog(strHeader, strLog, "City State Improved:", ""); TreasuryHelpers::AppendToLog(strHeader, strLog, "Gold for Improvement Amount:", 0); } // City State Bought and Amount if (iColumn == 6){ TreasuryHelpers::AppendToLog(strHeader, strLog, "City State Bought:", strExpenditure); TreasuryHelpers::AppendToLog(strHeader, strLog, "Bought for:", iAmount); } else{ TreasuryHelpers::AppendToLog(strHeader, strLog, "City State Bought:", ""); TreasuryHelpers::AppendToLog(strHeader, strLog, "Bought for:", 0); } // Emergency City Expenditure Unit and Amount if (iColumn == 7){ TreasuryHelpers::AppendToLog(strHeader, strLog, "Emergency Unit:", strExpenditure); TreasuryHelpers::AppendToLog(strHeader, strLog, "Emergency Unit Cost:", iAmount); } else{ TreasuryHelpers::AppendToLog(strHeader, strLog, "Emergency Unit:", ""); TreasuryHelpers::AppendToLog(strHeader, strLog, "Emergency Unit Cost:", 0); } // Emergency City Expenditure Unit and Amount if (iColumn == 8){ TreasuryHelpers::AppendToLog(strHeader, strLog, "Emergency Building:", strExpenditure); TreasuryHelpers::AppendToLog(strHeader, strLog, "Emergency Building Cost:", iAmount); } else{ TreasuryHelpers::AppendToLog(strHeader, strLog, "Emergency Building:", ""); TreasuryHelpers::AppendToLog(strHeader, strLog, "Emergency Building Cost:", 0); } // Research Agreement and Amount if (iColumn == 9){ TreasuryHelpers::AppendToLog(strHeader, strLog, "Research Agreement with:", strExpenditure); TreasuryHelpers::AppendToLog(strHeader, strLog, "Research Agreement Cost:", iAmount); } else{ TreasuryHelpers::AppendToLog(strHeader, strLog, "Research Agreement with:", ""); TreasuryHelpers::AppendToLog(strHeader, strLog, "Research Agreement Cost:", 0); } if(bBuildHeader) { pLog->Msg(strHeader); } pLog->Msg(strLog); }
void CvTypes::AcquireTypes(Database::Connection& db) { //MissionTypes { typedef std::tr1::unordered_map<std::string, MissionTypes*> LookupTable; LookupTable kMissionTypesLookupTable; kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_MOVE_TO"), &s_eMISSION_MOVE_TO)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_ROUTE_TO"), &s_eMISSION_ROUTE_TO)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_MOVE_TO_UNIT"), &s_eMISSION_MOVE_TO_UNIT)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_SWAP_UNITS"), &s_eMISSION_SWAP_UNITS)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_SKIP"), &s_eMISSION_SKIP)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_SLEEP"), &s_eMISSION_SLEEP)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_ALERT"), &s_eMISSION_ALERT)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_FORTIFY"), &s_eMISSION_FORTIFY)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_GARRISON"), &s_eMISSION_GARRISON)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_SET_UP_FOR_RANGED_ATTACK"), &s_eMISSION_SET_UP_FOR_RANGED_ATTACK)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_EMBARK"), &s_eMISSION_EMBARK)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_DISEMBARK"), &s_eMISSION_DISEMBARK)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_AIRPATROL"), &s_eMISSION_AIRPATROL)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_HEAL"), &s_eMISSION_HEAL)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_AIRLIFT"), &s_eMISSION_AIRLIFT)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_NUKE"), &s_eMISSION_NUKE)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_PARADROP"), &s_eMISSION_PARADROP)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_AIR_SWEEP"), &s_eMISSION_AIR_SWEEP)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_REBASE"), &s_eMISSION_REBASE)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_RANGE_ATTACK"), &s_eMISSION_RANGE_ATTACK)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_PILLAGE"), &s_eMISSION_PILLAGE)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_FOUND"), &s_eMISSION_FOUND)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_JOIN"), &s_eMISSION_JOIN)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_CONSTRUCT"), &s_eMISSION_CONSTRUCT)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_DISCOVER"), &s_eMISSION_DISCOVER)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_HURRY"), &s_eMISSION_HURRY)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_TRADE"), &s_eMISSION_TRADE)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_REPAIR_FLEET"), &s_eMISSION_REPAIR_FLEET)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_SPACESHIP"), &s_eMISSION_SPACESHIP)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_CULTURE_BOMB"), &s_eMISSION_CULTURE_BOMB)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_FOUND_RELIGION"), &s_eMISSION_FOUND_RELIGION)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_GOLDEN_AGE"), &s_eMISSION_GOLDEN_AGE)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_BUILD"), &s_eMISSION_BUILD)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_LEAD"), &s_eMISSION_LEAD)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_DIE_ANIMATION"), &s_eMISSION_DIE_ANIMATION)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_BEGIN_COMBAT"), &s_eMISSION_BEGIN_COMBAT)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_END_COMBAT"), &s_eMISSION_END_COMBAT)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_AIRSTRIKE"), &s_eMISSION_AIRSTRIKE)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_SURRENDER"), &s_eMISSION_SURRENDER)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_CAPTURED"), &s_eMISSION_CAPTURED)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_IDLE"), &s_eMISSION_IDLE)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_DIE"), &s_eMISSION_DIE)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_DAMAGE"), &s_eMISSION_DAMAGE)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_MULTI_SELECT"), &s_eMISSION_MULTI_SELECT)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_MULTI_DESELECT"), &s_eMISSION_MULTI_DESELECT)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_WAIT_FOR"), &s_eMISSION_WAIT_FOR)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_SPREAD_RELIGION"), &s_eMISSION_SPREAD_RELIGION)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_ENHANCE_RELIGION"), &s_eMISSION_ENHANCE_RELIGION)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_REMOVE_HERESY"), &s_eMISSION_REMOVE_HERESY)); Database::Results kResults; if(db.Execute(kResults, "SELECT Type, ID from Missions")) { while(kResults.Step()) { std::string strMissionType = kResults.GetText(0); LookupTable::iterator it = kMissionTypesLookupTable.find(strMissionType); if(it != kMissionTypesLookupTable.end()) { (*it->second) = static_cast<MissionTypes>(kResults.GetInt(1)); } } } int iNumTypes = db.Count("Missions", false); if(iNumTypes >= 0) { s_uiNUM_MISSION_TYPES = static_cast<unsigned int>(iNumTypes); } for(LookupTable::iterator it = kMissionTypesLookupTable.begin(); it != kMissionTypesLookupTable.end(); ++it) { if((*it->second) == NO_MISSION) { char msg[256] = {0}; sprintf_s(msg, "MissionType - %s is used in the DLL but does not exist in the database.", it->first.c_str()); FILogFile* pLog = LOGFILEMGR.GetLog("Gamecore.log", FILogFile::kDontTimeStamp); pLog->WarningMsg(msg); CvAssertMsg(false, msg); } } } }
void CvTypes::AcquireTypes(Database::Connection& db) { //ArtifactType { typedef std::tr1::unordered_map<std::string, GreatWorkArtifactClass*> LookupTable; LookupTable kArtifactTypeLookupTable; kArtifactTypeLookupTable.insert(make_pair(std::string("ARTIFACT_ANCIENT_RUIN"), &s_eARTIFACT_ANCIENT_RUIN)); kArtifactTypeLookupTable.insert(make_pair(std::string("ARTIFACT_BARBARIAN_CAMP"), &s_eARTIFACT_BARBARIAN_CAMP)); kArtifactTypeLookupTable.insert(make_pair(std::string("ARTIFACT_BATTLE_RANGED"), &s_eARTIFACT_BATTLE_RANGED)); kArtifactTypeLookupTable.insert(make_pair(std::string("ARTIFACT_BATTLE_MELEE"), &s_eARTIFACT_BATTLE_MELEE)); kArtifactTypeLookupTable.insert(make_pair(std::string("ARTIFACT_RAZED_CITY"), &s_eARTIFACT_RAZED_CITY)); kArtifactTypeLookupTable.insert(make_pair(std::string("ARTIFACT_WRITING"), &s_eARTIFACT_WRITING)); Database::Results kResults; if(db.Execute(kResults, "SELECT Type, ID from GreatWorkArtifactClasses")) { while(kResults.Step()) { std::string strArtifactType = kResults.GetText(0); LookupTable::iterator it = kArtifactTypeLookupTable.find(strArtifactType); if(it != kArtifactTypeLookupTable.end()) { (*it->second) = static_cast<GreatWorkArtifactClass>(kResults.GetInt(1)); } } } for(LookupTable::iterator it = kArtifactTypeLookupTable.begin(); it != kArtifactTypeLookupTable.end(); ++it) { if((*it->second) == NO_GREAT_WORK_ARTIFACT_CLASS) { char msg[256] = {0}; sprintf_s(msg, "ArtifactType - %s is used in the DLL but does not exist in the database.", it->first.c_str()); FILogFile* pLog = LOGFILEMGR.GetLog("Gamecore.log", FILogFile::kDontTimeStamp); pLog->WarningMsg(msg); CvAssertMsg(false, msg); } } } //GreatWorkSlots { typedef std::tr1::unordered_map<std::string, GreatWorkSlotType*> LookupTable; LookupTable kTypeLookupTable; kTypeLookupTable.insert(make_pair(std::string("GREAT_WORK_SLOT_ART_ARTIFACT"), &s_eGREAT_WORK_SLOT_ART_ARTIFACT)); kTypeLookupTable.insert(make_pair(std::string("GREAT_WORK_SLOT_LITERATURE"), &s_eGREAT_WORK_SLOT_LITERATURE)); kTypeLookupTable.insert(make_pair(std::string("GREAT_WORK_SLOT_MUSIC"), &s_eGREAT_WORK_SLOT_MUSIC)); Database::Results kResults; if(db.Execute(kResults, "SELECT Type, ID from GreatWorkSlots")) { while(kResults.Step()) { std::string strType = kResults.GetText(0); LookupTable::iterator it = kTypeLookupTable.find(strType); if(it != kTypeLookupTable.end()) { (*it->second) = static_cast<GreatWorkSlotType>(kResults.GetInt(1)); } } } for(LookupTable::iterator it = kTypeLookupTable.begin(); it != kTypeLookupTable.end(); ++it) { if((*it->second) == NO_GREAT_WORK_SLOT) { char msg[256] = {0}; sprintf_s(msg, "GreatWorkSlotType - %s is used in the DLL but does not exist in the database.", it->first.c_str()); FILogFile* pLog = LOGFILEMGR.GetLog("Gamecore.log", FILogFile::kDontTimeStamp); pLog->WarningMsg(msg); CvAssertMsg(false, msg); } } } //MissionTypes { typedef std::tr1::unordered_map<std::string, MissionTypes*> LookupTable; LookupTable kMissionTypesLookupTable; kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_MOVE_TO"), &s_eMISSION_MOVE_TO)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_ROUTE_TO"), &s_eMISSION_ROUTE_TO)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_MOVE_TO_UNIT"), &s_eMISSION_MOVE_TO_UNIT)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_SWAP_UNITS"), &s_eMISSION_SWAP_UNITS)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_SKIP"), &s_eMISSION_SKIP)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_SLEEP"), &s_eMISSION_SLEEP)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_ALERT"), &s_eMISSION_ALERT)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_FORTIFY"), &s_eMISSION_FORTIFY)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_GARRISON"), &s_eMISSION_GARRISON)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_SET_UP_FOR_RANGED_ATTACK"), &s_eMISSION_SET_UP_FOR_RANGED_ATTACK)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_EMBARK"), &s_eMISSION_EMBARK)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_DISEMBARK"), &s_eMISSION_DISEMBARK)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_AIRPATROL"), &s_eMISSION_AIRPATROL)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_HEAL"), &s_eMISSION_HEAL)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_AIRLIFT"), &s_eMISSION_AIRLIFT)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_NUKE"), &s_eMISSION_NUKE)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_PARADROP"), &s_eMISSION_PARADROP)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_AIR_SWEEP"), &s_eMISSION_AIR_SWEEP)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_REBASE"), &s_eMISSION_REBASE)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_RANGE_ATTACK"), &s_eMISSION_RANGE_ATTACK)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_PILLAGE"), &s_eMISSION_PILLAGE)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_FOUND"), &s_eMISSION_FOUND)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_JOIN"), &s_eMISSION_JOIN)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_CONSTRUCT"), &s_eMISSION_CONSTRUCT)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_DISCOVER"), &s_eMISSION_DISCOVER)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_HURRY"), &s_eMISSION_HURRY)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_TRADE"), &s_eMISSION_TRADE)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_BUY_CITY_STATE"), &s_eMISSION_BUY_CITY_STATE)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_REPAIR_FLEET"), &s_eMISSION_REPAIR_FLEET)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_SPACESHIP"), &s_eMISSION_SPACESHIP)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_CULTURE_BOMB"), &s_eMISSION_CULTURE_BOMB)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_FOUND_RELIGION"), &s_eMISSION_FOUND_RELIGION)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_GOLDEN_AGE"), &s_eMISSION_GOLDEN_AGE)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_BUILD"), &s_eMISSION_BUILD)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_LEAD"), &s_eMISSION_LEAD)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_DIE_ANIMATION"), &s_eMISSION_DIE_ANIMATION)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_BEGIN_COMBAT"), &s_eMISSION_BEGIN_COMBAT)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_END_COMBAT"), &s_eMISSION_END_COMBAT)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_AIRSTRIKE"), &s_eMISSION_AIRSTRIKE)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_SURRENDER"), &s_eMISSION_SURRENDER)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_CAPTURED"), &s_eMISSION_CAPTURED)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_IDLE"), &s_eMISSION_IDLE)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_DIE"), &s_eMISSION_DIE)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_DAMAGE"), &s_eMISSION_DAMAGE)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_MULTI_SELECT"), &s_eMISSION_MULTI_SELECT)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_MULTI_DESELECT"), &s_eMISSION_MULTI_DESELECT)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_WAIT_FOR"), &s_eMISSION_WAIT_FOR)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_SPREAD_RELIGION"), &s_eMISSION_SPREAD_RELIGION)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_ENHANCE_RELIGION"), &s_eMISSION_ENHANCE_RELIGION)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_REMOVE_HERESY"), &s_eMISSION_REMOVE_HERESY)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_ESTABLISH_TRADE_ROUTE"), &s_eMISSION_ESTABLISH_TRADE_ROUTE)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_PLUNDER_TRADE_ROUTE"), &s_eMISSION_PLUNDER_TRADE_ROUTE)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_CREATE_GREAT_WORK"), &s_eMISSION_GREAT_WORK)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_CHANGE_TRADE_UNIT_HOME_CITY"), &s_eMISSION_CHANGE_TRADE_UNIT_HOME_CITY)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_SELL_EXOTIC_GOODS"), &s_eMISSION_SELL_EXOTIC_GOODS)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_GIVE_POLICIES"), &s_eMISSION_GIVE_POLICIES)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_ONE_SHOT_TOURISM"), &s_eMISSION_ONE_SHOT_TOURISM)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_CHANGE_ADMIRAL_PORT"), &s_eMISSION_CHANGE_ADMIRAL_PORT)); #ifdef Imperial_Combat_BomberMission_FireBombing kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_FIREBOMB_IMPROVEMENT"), &s_eMISSION_FIREBOMB_IMPROVEMENT)); kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_FIREBOMB_BUILDING"), &s_eMISSION_FIREBOMB_BUILDING)); #endif Database::Results kResults; if(db.Execute(kResults, "SELECT Type, ID from Missions")) { while(kResults.Step()) { std::string strMissionType = kResults.GetText(0); LookupTable::iterator it = kMissionTypesLookupTable.find(strMissionType); if(it != kMissionTypesLookupTable.end()) { (*it->second) = static_cast<MissionTypes>(kResults.GetInt(1)); } } } int iNumTypes = db.Count("Missions", false); if(iNumTypes >= 0) { s_uiNUM_MISSION_TYPES = static_cast<unsigned int>(iNumTypes); } for(LookupTable::iterator it = kMissionTypesLookupTable.begin(); it != kMissionTypesLookupTable.end(); ++it) { if((*it->second) == NO_MISSION) { char msg[256] = {0}; sprintf_s(msg, "MissionType - %s is used in the DLL but does not exist in the database.", it->first.c_str()); FILogFile* pLog = LOGFILEMGR.GetLog("Gamecore.log", FILogFile::kDontTimeStamp); pLog->WarningMsg(msg); CvAssertMsg(false, msg); } } } }
void CvCityAI::AI_chooseProduction(bool bInterruptWonders) { VALIDATE_OBJECT CvPlayerAI& kOwner = GET_PLAYER(getOwner()); CvCitySpecializationAI* pSpecializationAI = kOwner.GetCitySpecializationAI(); bool bBuildWonder = false; // See if this is the one AI city that is supposed to be building wonders if(pSpecializationAI->GetWonderBuildCity() == this) { // Is it still working on that wonder and we don't want to interrupt it? if(!bInterruptWonders) { const BuildingTypes eBuilding = getProductionBuilding(); CvBuildingEntry* pkBuilding = (eBuilding != NO_BUILDING)? GC.getBuildingInfo(eBuilding) : NULL; if(pkBuilding && kOwner.GetWonderProductionAI()->IsWonder(*pkBuilding)) { return; // Stay the course } } // So we're the wonder building city but it is not underway yet... // Has the designated wonder been poached by another civ? BuildingTypes eNextWonder = pSpecializationAI->GetNextWonderDesired(); if(!canConstruct(eNextWonder)) { // Reset city specialization kOwner.GetCitySpecializationAI()->SetSpecializationsDirty(SPECIALIZATION_UPDATE_WONDER_BUILT_BY_RIVAL); } else { // to prevent us from continuously locking into building wonders in one city when there are other high priority items to build int iFlavorWonder = kOwner.GetGrandStrategyAI()->GetPersonalityAndGrandStrategy((FlavorTypes)GC.getInfoTypeForString("FLAVOR_WONDER")); int iFlavorGP = kOwner.GetGrandStrategyAI()->GetPersonalityAndGrandStrategy((FlavorTypes)GC.getInfoTypeForString("FLAVOR_GREAT_PEOPLE")); int iFlavor = (iFlavorWonder > iFlavorGP ) ? iFlavorWonder : iFlavorGP; if (GC.getGame().getJonRandNum(11, "Random roll for whether to continue building wonders") <= iFlavor) bBuildWonder = true; } } if(bBuildWonder) { CvCityBuildable buildable; buildable.m_eBuildableType = CITY_BUILDABLE_BUILDING; buildable.m_iIndex = pSpecializationAI->GetNextWonderDesired(); buildable.m_iTurnsToConstruct = getProductionTurnsLeft((BuildingTypes)buildable.m_eBuildableType, 0); pushOrder(ORDER_CONSTRUCT, buildable.m_iIndex, -1, false, false, false, false); if(GC.getLogging() && GC.getAILogging()) { CvString playerName; FILogFile* pLog; CvString strBaseString; CvString strOutBuf; m_pCityStrategyAI->LogCityProduction(buildable, false); playerName = kOwner.getCivilizationShortDescription(); pLog = LOGFILEMGR.GetLog(kOwner.GetCitySpecializationAI()->GetLogFileName(playerName), FILogFile::kDontTimeStamp); strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns()); strBaseString += playerName + ", "; strOutBuf.Format("%s, WONDER - Started %s, Turns: %d", getName().GetCString(), GC.getBuildingInfo((BuildingTypes)buildable.m_iIndex)->GetDescription(), buildable.m_iTurnsToConstruct); strBaseString += strOutBuf; pLog->Msg(strBaseString); } } else { m_pCityStrategyAI->ChooseProduction(false); AI_setChooseProductionDirty(false); } return; }
/// Log our guess as to other Players' Active Grand Strategy void CvGrandStrategyAI::LogGuessOtherPlayerGrandStrategy(const FStaticVector< int, 5, true, c_eCiv5GameplayDLL >& vGrandStrategyPriorities, PlayerTypes ePlayer) { if(GC.getLogging() && GC.getAILogging()) { CvString strOutBuf; CvString strBaseString; CvString strTemp; CvString playerName; CvString otherPlayerName; CvString strDesc; CvString strLogName; // Find the name of this civ and city playerName = GetPlayer()->getCivilizationShortDescription(); // Open the log file if(GC.getPlayerAndCityAILogSplit()) { strLogName = "GrandStrategyAI_Guess_Log_" + playerName + ".csv"; } else { strLogName = "GrandStrategyAI_Guess_Log.csv"; } FILogFile* pLog; pLog = LOGFILEMGR.GetLog(strLogName, FILogFile::kDontTimeStamp); AIGrandStrategyTypes eGrandStrategy; int iPriority; // Loop through Grand Strategies for(int iGrandStrategyLoop = 0; iGrandStrategyLoop < GC.getNumAIGrandStrategyInfos(); iGrandStrategyLoop++) { // Get the leading info for this line strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns()); strBaseString += playerName + ", "; eGrandStrategy = (AIGrandStrategyTypes) iGrandStrategyLoop; iPriority = vGrandStrategyPriorities[iGrandStrategyLoop]; CvAIGrandStrategyXMLEntry* pEntry = GC.getAIGrandStrategyInfo(eGrandStrategy); const char* szGrandStrategyType = (pEntry != NULL)? pEntry->GetType() : "Unknown Strategy"; // GrandStrategy Info if(GetActiveGrandStrategy() == eGrandStrategy) { strTemp.Format("*** %s, %d", szGrandStrategyType, iPriority); } else { strTemp.Format("%s, %d", szGrandStrategyType, iPriority); } otherPlayerName = GET_PLAYER(ePlayer).getCivilizationShortDescription(); strOutBuf = strBaseString + otherPlayerName + ", " + strTemp; if(GetGuessOtherPlayerActiveGrandStrategy(ePlayer) == eGrandStrategy) { // Confidence in our guess switch(GetGuessOtherPlayerActiveGrandStrategyConfidence(ePlayer)) { case GUESS_CONFIDENCE_POSITIVE: strTemp.Format("Positive"); break; case GUESS_CONFIDENCE_LIKELY: strTemp.Format("Likely"); break; case GUESS_CONFIDENCE_UNSURE: strTemp.Format("Unsure"); break; default: strTemp.Format("XXX"); break; } strOutBuf += ", " + strTemp; } pLog->Msg(strOutBuf); } // One more entry for NO GRAND STRATEGY // Get the leading info for this line strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns()); strBaseString += playerName + ", "; iPriority = vGrandStrategyPriorities[GC.getNumAIGrandStrategyInfos()]; // GrandStrategy Info strTemp.Format("NO_GRAND_STRATEGY, %d", iPriority); otherPlayerName = GET_PLAYER(ePlayer).getCivilizationShortDescription(); strOutBuf = strBaseString + otherPlayerName + ", " + strTemp; pLog->Msg(strOutBuf); } }