Hooks
static bool BeforeCvActiveResolution_DoEffects(CvActiveResolution* self, PlayerTypes ePlayer);static void AfterCvActiveResolution_DoEffects(CvActiveResolution* self, PlayerTypes ePlayer);static void ReplaceCvActiveResolution_DoEffects(void (*original)(CvActiveResolution*, PlayerTypes), CvActiveResolution* self, PlayerTypes ePlayer);CivRegisterBefore<CivHooks::CvActiveResolution_DoEffects>(host, &BeforeCvActiveResolution_DoEffects);CivRegisterAfter<CivHooks::CvActiveResolution_DoEffects>(host, &AfterCvActiveResolution_DoEffects);CivRegisterReplace<CivHooks::CvActiveResolution_DoEffects>(host, &ReplaceCvActiveResolution_DoEffects);
Code
1237void CvActiveResolution::DoEffects(PlayerTypes ePlayer)1238{1239 CvPlayer* pPlayer = &GET_PLAYER(ePlayer);1240 CvAssertMsg(pPlayer != NULL, "Player is null when doing effects of an active resolution. Please send Anton your save file and version.");1241 if (pPlayer == NULL) return;12421243 CvLeague* pLeague = GC.getGame().GetGameLeagues()->GetLeague(GetLeague());1244 CvAssertMsg(pLeague != NULL, "League is null when doing effects of an active resolution. Please send Anton your save file and version.");1245 if (pLeague == NULL) return;12461247 // == Proposer Choices ==1248 ResolutionDecisionTypes eProposerDecision = GetProposerDecision()->GetType();1249 PlayerTypes eTargetPlayer = NO_PLAYER;1250 if (eProposerDecision == RESOLUTION_DECISION_ANY_MEMBER ||1251 eProposerDecision == RESOLUTION_DECISION_MAJOR_CIV_MEMBER ||1252 eProposerDecision == RESOLUTION_DECISION_OTHER_MAJOR_CIV_MEMBER)1253 {1254 eTargetPlayer = (PlayerTypes) GetProposerDecision()->GetDecision();1255 }1256 ResourceTypes eTargetLuxury = NO_RESOURCE;1257 if (eProposerDecision == RESOLUTION_DECISION_ANY_LUXURY_RESOURCE)1258 {1259 CvResourceInfo* pInfo = GC.getResourceInfo((ResourceTypes) GetProposerDecision()->GetDecision());1260 if (pInfo && pInfo->getResourceUsage() == RESOURCEUSAGE_LUXURY)1261 {1262 eTargetLuxury = (ResourceTypes) GetProposerDecision()->GetDecision();1263 }1264 }1265 ReligionTypes eTargetReligion = NO_RELIGION;1266 if (eProposerDecision == RESOLUTION_DECISION_RELIGION)1267 {1268 eTargetReligion = (ReligionTypes) GetProposerDecision()->GetDecision();1269 }1270 PolicyBranchTypes eTargetIdeology = NO_POLICY_BRANCH_TYPE;1271 if (eProposerDecision == RESOLUTION_DECISION_IDEOLOGY)1272 {1273 eTargetIdeology = (PolicyBranchTypes) GetProposerDecision()->GetDecision();1274 }12751276 // == Voter Choices ==1277 ResolutionDecisionTypes eVoterDecision = GetVoterDecision()->GetType();1278 PlayerTypes eVotedPlayer = NO_PLAYER;1279 if (eVoterDecision == RESOLUTION_DECISION_ANY_MEMBER ||1280 eVoterDecision == RESOLUTION_DECISION_MAJOR_CIV_MEMBER ||1281 eVoterDecision == RESOLUTION_DECISION_OTHER_MAJOR_CIV_MEMBER)1282 {1283 eVotedPlayer = (PlayerTypes) GetVoterDecision()->GetDecision();1284 }12851286 // == One Time Effects ==1287 if (GetEffects()->bDiplomaticVictory)1288 {1289 CvAssertMsg(eTargetPlayer != NO_PLAYER || eVotedPlayer != NO_PLAYER, "Diplomatic Victory voted for NO_PLAYER. Please send Anton your save file and version.");1290 CvAssertMsg(eTargetPlayer == NO_PLAYER || eVotedPlayer == NO_PLAYER, "Ambiguous target when setting Diplomatic Victory. Please send Anton your save file and version");1291 if (ePlayer == eVotedPlayer || ePlayer == eTargetPlayer)1292 {1293 GC.getGame().GetGameLeagues()->SetDiplomaticVictor(ePlayer);1294 }1295 }1296 if (GetEffects()->bChangeLeagueHost)1297 {1298 CvAssertMsg(eTargetPlayer != NO_PLAYER || eVotedPlayer != NO_PLAYER, "Changing host to NO_PLAYER. Please send Anton your save file and version.");1299 CvAssertMsg(eTargetPlayer == NO_PLAYER || eVotedPlayer == NO_PLAYER, "Ambiguous target when changing host. Please send Anton your save file and version");1300 if (ePlayer == eVotedPlayer || ePlayer == eTargetPlayer)1301 {1302 pLeague->SetHostMember(ePlayer);1303 }1304 }1305 if (GetEffects()->iOneTimeGold != 0)1306 {1307 pPlayer->GetTreasury()->ChangeGold(GetEffects()->iOneTimeGold);1308 }1309 if (GetEffects()->iOneTimeGoldPercent != 0)1310 {1311 int iGold = pPlayer->GetTreasury()->GetGold();1312 int iChange = (iGold * GetEffects()->iOneTimeGoldPercent) / 100;1313 pPlayer->GetTreasury()->ChangeGold(iChange);1314 }1315 if (GetEffects()->bRaiseCityStateInfluenceToNeutral)1316 {1317 if (!GET_PLAYER(ePlayer).isMinorCiv())1318 {1319 int iNeutral = GC.getMINOR_FRIENDSHIP_ANCHOR_DEFAULT();1320 for (int iMinor = MAX_MAJOR_CIVS; iMinor < MAX_CIV_PLAYERS; iMinor++)1321 {1322 PlayerTypes eMinor = (PlayerTypes) iMinor;1323 if (GET_PLAYER(eMinor).isAlive() && GET_PLAYER(eMinor).GetMinorCivAI()->GetBaseFriendshipWithMajor(ePlayer) < iNeutral)1324 {1325 if (pLeague->IsMember(eMinor))1326 {1327 GET_PLAYER(eMinor).GetMinorCivAI()->SetFriendshipWithMajor(ePlayer, iNeutral);1328 }1329 }1330 }1331 }1332 }13331334 // == Ongoing Effects ==1335 if (GetEffects()->iGoldPerTurn != 0)1336 {1337 pPlayer->GetTreasury()->ChangeGoldPerTurnFromDiplomacy(GetEffects()->iGoldPerTurn);1338 }1339 if (GetEffects()->iResourceQuantity != 0)1340 {1341 CvAssertMsg(eTargetLuxury != NO_RESOURCE, "Adding NO_RESOURCE for a player. Please send Anton your save file and version.");1342 pPlayer->changeNumResourceTotal(eTargetLuxury, GetEffects()->iResourceQuantity);1343 }1344 if (GetEffects()->bEmbargoCityStates)1345 { 1346 // Refresh trade routes1347 GC.getGame().GetGameTrade()->ClearAllCityStateTradeRoutes();1348 }1349 if (GetEffects()->bEmbargoPlayer)1350 {1351 CvAssertMsg(eTargetPlayer != NO_PLAYER, "Making an embargo on NO_PLAYER. Please send Anton your save file and version.");1352 // Refresh trade routes1353 GC.getGame().GetGameTrade()->ClearAllCivTradeRoutes(eTargetPlayer);1354 }1355 if (GetEffects()->bNoResourceHappiness)1356 {1357 CvAssertMsg(eTargetLuxury != NO_RESOURCE, "Banning Happiness for NO_RESOURCE. Please send Anton your save file and version.");1358 // Refresh happiness1359 }1360 if (GetEffects()->iUnitMaintenanceGoldPercent != 0)1361 {1362 pPlayer->ChangeUnitGoldMaintenanceMod(GetEffects()->iUnitMaintenanceGoldPercent);1363 }1364 if (GetEffects()->iMemberDiscoveredTechMod != 0)1365 {1366 // Refresh research1367 }1368 if (GetEffects()->iCulturePerWonder != 0)1369 {1370 // Refresh yields1371 }1372 if (GetEffects()->iCulturePerNaturalWonder != 0)1373 {1374 // Refresh yields1375 }1376 if (GetEffects()->bNoTrainingNuclearWeapons)1377 {1378 }1379 if (GetEffects()->iVotesForFollowingReligion != 0)1380 {1381 CvAssertMsg(eTargetReligion != NO_RELIGION, "No target religion when one was expected. Please send Anton your save file and version.");1382 }1383 if (GetEffects()->iHolyCityTourism != 0)1384 {1385 CvAssertMsg(eTargetReligion != NO_RELIGION, "No target religion when one was expected. Please send Anton your save file and version.");1386 /*1387 if (eTargetReligion != NO_RELIGION)1388 {1389 const CvReligion* pTargetReligion = GC.getGame().GetGameReligions()->GetReligion(eTargetReligion, ePlayer);1390 if (pTargetReligion != NULL)1391 {1392 CvPlot* pHolyCityPlot = GC.getMap().plot(pTargetReligion->m_iHolyCityX, pTargetReligion->m_iHolyCityY);1393 if (pHolyCityPlot != NULL && pHolyCityPlot->isCity())1394 {1395 CvCity* pHolyCity = pHolyCityPlot->getPlotCity();1396 if (pHolyCity != NULL && pHolyCity->getOwner() == ePlayer)1397 {1398 //antonjs: temp:1399 GET_PLAYER(ePlayer).GetTreasury()->ChangeGoldPerTurnFromDiplomacy(GetEffects()->iHolyCityTourism);1400 }1401 }1402 }1403 }1404 //antonjs: todo: OnHolyCityCaptured()1405 */1406 }1407 if (GetEffects()->iReligionSpreadStrengthMod != 0)1408 {1409 CvAssertMsg(eTargetReligion != NO_RELIGION, "No target religion when one was expected. Please send Anton your save file and version.");1410 // Updated on CvGameReligions::DoTurn1411 }1412 if (GetEffects()->iVotesForFollowingIdeology != 0)1413 {1414 CvAssertMsg(eTargetIdeology != NO_POLICY_BRANCH_TYPE, "No target ideology when one was expected. Please send Anton your save file and version.");1415 }1416 if (GetEffects()->iOtherIdeologyRebellionMod != 0)1417 {1418 CvAssertMsg(eTargetIdeology != NO_POLICY_BRANCH_TYPE, "No target ideology when one was expected. Please send Anton your save file and version.");1419 /*1420 if (eTargetIdeology != NO_POLICY_BRANCH_TYPE)1421 {1422 if (GET_PLAYER(ePlayer).GetPlayerPolicies()->GetLateGamePolicyTree() == eTargetIdeology)1423 {1424 //antonjs: temp:1425 GET_PLAYER(ePlayer).GetTreasury()->ChangeGoldPerTurnFromDiplomacy(GetEffects()->iOtherIdeologyRebellionMod);1426 }1427 }1428 //antonjs: todo: OnIdeologyChanged()1429 */1430 }1431 if (GetEffects()->iArtsyGreatPersonRateMod != 0)1432 {1433 }1434 if (GetEffects()->iScienceyGreatPersonRateMod != 0)1435 {1436 }1437 if (GetEffects()->iGreatPersonTileImprovementCulture != 0)1438 {1439 // Loop through all Great Person tile improvements1440 for (int i = 0; i < GC.getNumImprovementInfos(); i++)1441 {1442 CvImprovementEntry* pInfo = GC.getImprovementInfo((ImprovementTypes)i);1443 if (pInfo != NULL && pInfo->IsCreatedByGreatPerson())1444 {1445 GET_PLAYER(ePlayer).changeImprovementYieldChange((ImprovementTypes)pInfo->GetID(), YIELD_CULTURE, GetEffects()->iGreatPersonTileImprovementCulture);1446 }1447 }1448 // Refresh yield1449 }1450 if (GetEffects()->iLandmarkCulture != 0)1451 {1452 CvImprovementEntry* pLandmarkInfo = GC.getImprovementInfo((ImprovementTypes)GC.getInfoTypeForString("IMPROVEMENT_LANDMARK"));1453 if (pLandmarkInfo != NULL)1454 {1455 GET_PLAYER(ePlayer).changeImprovementYieldChange((ImprovementTypes)pLandmarkInfo->GetID(), YIELD_CULTURE, GetEffects()->iLandmarkCulture);1456 }1457 // Refresh yield1458 }1459 1460 m_iTurnEnacted = GC.getGame().getGameTurn();1461}