|
From: <imp...@us...> - 2007-03-14 05:15:33
|
Revision: 42
http://civ4ccp.svn.sourceforge.net/civ4ccp/?rev=42&view=rev
Author: impalerwrg
Date: 2007-03-13 22:15:29 -0700 (Tue, 13 Mar 2007)
Log Message:
-----------
More TR merging
Modified Paths:
--------------
CvGameCoreDLL/CvCity.cpp
CvGameCoreDLL/CvGameCoreDLL.depend
CvGameCoreDLL/CvGameTextMgr.cpp
CvGameCoreDLL/CvPlayer.cpp
CvGameCoreDLL/CvPlot.cpp
CvGameCoreDLL/CvUnit.cpp
Added Paths:
-----------
CvGameCoreDLL/CvPlotRegion.h
Modified: CvGameCoreDLL/CvCity.cpp
===================================================================
--- CvGameCoreDLL/CvCity.cpp 2007-03-13 05:07:20 UTC (rev 41)
+++ CvGameCoreDLL/CvCity.cpp 2007-03-14 05:15:29 UTC (rev 42)
@@ -7463,6 +7463,7 @@
FAssertMsg(eIndex < NUM_YIELD_TYPES, "eIndex expected to be < NUM_YIELD_TYPES");
FAssertMsg(eSpecialist >= 0, "eSpecialist expected to be >= 0");
FAssertMsg(eSpecialist < GC.getNumSpecialistInfos(), "GC.getNumSpecialistInfos expected to be >= 0");
+
// < Local Specialist Yield Change By Impaler[WrG] Start >
// ORIGINAL CODE return ((getSpecialistCount(eSpecialist) + getFreeSpecialistCount(eSpecialist)) * GET_PLAYER(getOwnerINLINE()).getSpecialistExtraYield(eSpecialist, eIndex));
return (getSpecialistCount(eSpecialist) * (GET_PLAYER(getOwnerINLINE()).getSpecialistExtraYield(eSpecialist, eIndex) + getLocalSpecialistYieldChange(eSpecialist, eIndex)));
@@ -7486,10 +7487,11 @@
return m_ppaaiLocalSpecialistExtraCommerce[eSpecialist][eIndex];
}
-void CvCity::changeLocalSpecialistCommerceChange(SpecialistTypes eSpecialist, CommerceTypes eCommerce, int iChange) // < Local Specialist Yield Change By Impaler[WrG] >
+void CvCity::changeLocalSpecialistCommerceChange(SpecialistTypes eSpecialist, CommerceTypes eCommerce, int iChange)
{
m_ppaaiLocalSpecialistExtraCommerce[eSpecialist][eCommerce] += iChange;
}
+// < Local Specialist Yield Change End >
void CvCity::updateExtraSpecialistYield(YieldTypes eYield)
{
@@ -12100,4 +12102,9 @@
{
return m_iPandemicTurns;
}
-// Pandemic system end
\ No newline at end of file
+// Pandemic system end
+
+int CvCity::getArea() const
+{
+ return plot()->getArea();
+}
\ No newline at end of file
Modified: CvGameCoreDLL/CvGameCoreDLL.depend
===================================================================
--- CvGameCoreDLL/CvGameCoreDLL.depend 2007-03-13 05:07:20 UTC (rev 41)
+++ CvGameCoreDLL/CvGameCoreDLL.depend 2007-03-14 05:15:29 UTC (rev 42)
@@ -31134,7 +31134,7 @@
"CvInfos.h"
"CvGlobals.h"
-1173737945 c:\sdk\cccp dll\cvcity.cpp
+1173847594 c:\sdk\cccp dll\cvcity.cpp
"CvGameCoreDLL.h"
"CvGlobals.h"
"CvCity.h"
@@ -31362,7 +31362,7 @@
1173731815 c:\sdk\cccp dll\fastarnode.h
-1173740374 c:\sdk\cccp dll\cvgametextmgr.cpp
+1173762348 c:\sdk\cccp dll\cvgametextmgr.cpp
"CvGameCoreDLL.h"
"CvGameTextMgr.h"
"CvGameCoreUtils.h"
@@ -31493,7 +31493,7 @@
"CvDLLPythonIFaceBase.h"
"FProfiler.h"
-1173738026 c:\sdk\cccp dll\cvplayer.cpp
+1173809204 c:\sdk\cccp dll\cvplayer.cpp
"CvGameCoreDLL.h"
"CvGlobals.h"
"CvArea.h"
@@ -31545,7 +31545,7 @@
"CvPopupInfo.h"
"FProfiler.h"
-1173731815 c:\sdk\cccp dll\cvplot.cpp
+1173810089 c:\sdk\cccp dll\cvplot.cpp
"CvGameCoreDLL.h"
"CvPlot.h"
"CvCity.h"
Modified: CvGameCoreDLL/CvGameTextMgr.cpp
===================================================================
--- CvGameCoreDLL/CvGameTextMgr.cpp 2007-03-13 05:07:20 UTC (rev 41)
+++ CvGameCoreDLL/CvGameTextMgr.cpp 2007-03-14 05:15:29 UTC (rev 42)
@@ -2276,19 +2276,14 @@
}
else
{
- // Start Change UniqueUnitsForLeaders v1.0 by Impaler[WrG] 6/10/06
- // ORIGINAL CODE eLoopUnit = ((UnitTypes)(GC.getCivilizationInfo(eCivilization).getCivilizationUnits(iI)));
-
+ // Start Change UniqueUnitsForLeaders v1.0 by Impaler[WrG] 6/10/06
+ // ORIGINAL CODE eLoopUnit = ((UnitTypes)(GC.getCivilizationInfo(eCivilization).getCivilizationUnits(iI)));
if ( GC.getGameINLINE().getActivePlayer() != NO_PLAYER && GET_PLAYER( GC.getGameINLINE().getActivePlayer()).getLeaderType() != NO_LEADER )
- {
eLoopUnit = (UnitTypes)(GC.getLeaderHeadInfo(GET_PLAYER(GC.getGameINLINE().getActivePlayer()).getLeaderType()).getUnitTypeByClass(eCivilization, iI));
- }
else
- {
- eLoopUnit = ((UnitTypes)(GC.getCivilizationInfo(eCivilization).getCivilizationUnits(iI)));
+ eLoopUnit = ((UnitTypes)(GC.getCivilizationInfo(eCivilization).getCivilizationUnits(iI)));
+ // End Change by Impaler[WrG] 6/10/06
}
- // End Change by Impaler[WrG] 6/10/06
- }
if (eLoopUnit != NO_UNIT)
{
@@ -2454,7 +2449,7 @@
// return szHelpString;
}
-// < Scriptable Leader Traits Start >
+// < Scriptable Leader Traits by Lopez & Impaler[WrG] Start >
void CvGameTextMgr::parseLeaderTraits(CvWString &szHelpString, PlayerTypes ePlayer)
{
// CvWString szHelpString; // Final String Storage
@@ -2485,12 +2480,9 @@
}
else
{
- // Random leader
swprintf(szTempBuffer, SETCOLR L"%s" ENDCOLR , TEXT_COLOR("COLOR_HIGHLIGHT_TEXT"), gDLL->getText("TXT_KEY_TRAIT_PLAYER_UNKNOWN").c_str());
szHelpString+=szTempBuffer;
}
-
-// return szHelpString;
}
// < Scriptable Leader Traits End >
@@ -4865,8 +4857,8 @@
szBuffer += NEWLINE + gDLL->getText("TXT_KEY_UNIQUE_UNIT", GC.getCivilizationInfo((CivilizationTypes)iI).getTextKeyWide());
}
}
- //Start Addition UniqueUnitsForLeaders v1.0 by Impaler[WrG] 6/9/06
-
+
+ // < UniqueUnits For Leaders by Impaler[WrG] Start >
if (NO_UNIT != eDefaultUnit && eDefaultUnit != eUnit && eUnitClass != -1)
{
for (iI = 0; iI < GC.getNumLeaderHeadInfos(); iI++)
@@ -4881,10 +4873,10 @@
if (NO_UNIT != eDefaultUnit && eDefaultUnit != eUnit)
{
- //End Addition UniqueUnitsForLeaders v1.0 by Impaler[WrG] 6/9/06
+ // < UniqueUnits For Leaders by Impaler[WrG] Start >
szBuffer += NEWLINE + gDLL->getText("TXT_KEY_REPLACES_UNIT", GC.getUnitInfo(eDefaultUnit).getTextKeyWide());
}
- }
+ }// < UniqueUnits For Leaders by Impaler[WrG] Start >
if (isWorldUnitClass(eUnitClass))
{
@@ -5258,6 +5250,14 @@
szBuffer += NEWLINE + gDLL->getText("TXT_KEY_REPLACES_UNIT", GC.getBuildingInfo(eDefaultBuilding).getTextKeyWide());
}
+ // < Building Timer by Mexico Start >
+ int iTimer = GC.getBuildingInfo(eBuilding).getTimer();
+ if ( iTimer > 0)
+ {
+ szBuffer += NEWLINE + gDLL->getText("TXT_KEY_BUILDING_TIMER", iTimer);
+ }
+ // < Building Timer End >
+
if (bCivilopediaText)
{
setYieldChangeHelp(szBuffer, L"", L"", L"", GC.getBuildingInfo(eBuilding).getYieldModifierArray(), true, bCivilopediaText);
@@ -5329,34 +5329,26 @@
// Update by Mexico 10.1.2007
// re-added stuff from building resource component (included in 2.00.06 version)
// < Building Resource Converter Start >
- if(GC.getBuildingInfo(eBuilding).getRequiredInputBonusCount() > 0 && GC.getBuildingInfo(eBuilding).getBuildingOutputBonusCount() > 0 )
+ if (GC.getBuildingInfo(eBuilding).getRequiredInputBonusCount() > 0 && GC.getBuildingInfo(eBuilding).getBuildingOutputBonusCount() > 0 )
{
bool bFirst = true;
szBuffer += NEWLINE;
- //swprintf(szTempBuffer, L"%cConverts ", gDLL->getSymbolID(BULLET_CHAR));
szTempBuffer.Format(L"%cConverts ", gDLL->getSymbolID(BULLET_CHAR));
szBuffer += szTempBuffer;
for (iI = 0; iI < GC.getNumBonusInfos(); iI++)
{
-
- if(GC.getBuildingInfo(eBuilding).getRequiredInputBonusValue((BonusTypes)iI) > 0)
+ if (GC.getBuildingInfo(eBuilding).getRequiredInputBonusValue((BonusTypes)iI) > 0)
{
if(!bFirst)
- {
- //swprintf(szTempBuffer, L", ");
szBuffer += L", ";
- }
-
//swprintf(szTempBuffer, L"%d <link=literal>%s</link> (%c)", GC.getBuildingInfo(eBuilding).getRequiredInputBonusValue((BonusTypes)iI), GC.getBonusInfo((BonusTypes)iI).getDescription(), GC.getBonusInfo((BonusTypes)iI).getChar());
szTempBuffer.Format(L"%d <link=literal>%s</link> (%c)", GC.getBuildingInfo(eBuilding).getRequiredInputBonusValue((BonusTypes)iI), GC.getBonusInfo((BonusTypes)iI).getDescription(), GC.getBonusInfo((BonusTypes)iI).getChar());
szBuffer += szTempBuffer;
bFirst = false;
}
}
-
- //swprintf(szTempBuffer, L" into ");
szBuffer += L" into ";
bFirst = true;
@@ -5364,14 +5356,10 @@
for (iI = 0; iI < GC.getNumBonusInfos(); iI++)
{
- if(GC.getBuildingInfo(eBuilding).getBuildingOutputBonusValues((BonusTypes)iI) > 0)
+ if (GC.getBuildingInfo(eBuilding).getBuildingOutputBonusValues((BonusTypes)iI) > 0)
{
if(!bFirst)
- {
- //swprintf(szTempBuffer, L", ");
szBuffer += L", ";
- }
-
//swprintf(szTempBuffer, L"%d <link=literal>%s</link> (%c)", GC.getBuildingInfo(eBuilding).getBuildingOutputBonusValues((BonusTypes)iI), GC.getBonusInfo((BonusTypes)iI).getDescription(), GC.getBonusInfo((BonusTypes)iI).getChar());
szTempBuffer.Format(L"%d <link=literal>%s</link> (%c)", GC.getBuildingInfo(eBuilding).getBuildingOutputBonusValues((BonusTypes)iI), GC.getBonusInfo((BonusTypes)iI).getDescription(), GC.getBonusInfo((BonusTypes)iI).getChar());
szBuffer += szTempBuffer;
@@ -6872,14 +6860,12 @@
// XXX decomp these???
- //Addition TraitHappiness by Impaler[WrG]
+ // < Trait Happiness by Impaler[WrG]
int iHappy = 0;
for (int T = 0; T < GC.getNumTraitInfos(); T++)
{
if (GET_PLAYER(city.getOwnerINLINE()).hasTrait((TraitTypes)T))
- {
iHappy += GC.getTraitInfo((TraitTypes)T).getHappiness();
- }
}
if (iHappy < 0) //Negative Happiness needs to be converted to anger
Modified: CvGameCoreDLL/CvPlayer.cpp
===================================================================
--- CvGameCoreDLL/CvPlayer.cpp 2007-03-13 05:07:20 UTC (rev 41)
+++ CvGameCoreDLL/CvPlayer.cpp 2007-03-14 05:15:29 UTC (rev 42)
@@ -239,6 +239,8 @@
// End Scriptable Leader Traits
}
+ updateMaxAnarchyTurns();
+
for (iI = 0; iI < GC.getNumCivicOptionInfos(); iI++)
{
setCivics(((CivicOptionTypes)iI), ((CivicTypes)(GC.getCivilizationInfo(getCivilizationType()).getCivilizationInitialCivics(iI))));
@@ -1085,7 +1087,7 @@
CvPlot* pStartingPlot;
- iRange -= iPass;
+ iRange -= (1 + iPass * 2);
if (pPlot->getMinOriginalStartDist() == -1)
{
@@ -1308,9 +1310,9 @@
void CvPlayer::acquireCity(CvCity* pOldCity, bool bConquest, bool bTrade)
{
- // ---------------- REVOLUTION_MOD start ---------------------
- std::string scriptData;
- // ---------------- REVOLUTION_MOD end -----------------------
+
+ std::string scriptData; // < Revolution Mod by jdog5000 >
+
CLLNode<IDInfo>* pUnitNode;
CvCity* pNewCity;
CvUnit* pLoopUnit;
@@ -1550,10 +1552,9 @@
iOccupationTimer = pOldCity->getOccupationTimer();
szName = pOldCity->getNameKey();
iDamage = pOldCity->getDefenseDamage();
- // ---------------- REVOLUTION_MOD start ---------------------
- scriptData = pOldCity->getScriptData();
- // ---------------- REVOLUTION_MOD end -----------------------
+ scriptData = pOldCity->getScriptData(); // < Revolution Mod by jdog5000 >
+
for (iI = 0; iI < MAX_PLAYERS; iI++)
{
abEverOwned[iI] = pOldCity->isEverOwned((PlayerTypes)iI);
@@ -1607,10 +1608,9 @@
pNewCity->setName(szName);
pNewCity->setNeverLost(false);
pNewCity->changeDefenseDamage(iDamage);
- // ---------------- REVOLUTION_MOD start ---------------------
- pNewCity->setScriptData(scriptData);
- // ---------------- REVOLUTION_MOD end -----------------------
+ pNewCity->setScriptData(scriptData); // < Revolution Mod by jdog5000 >
+
for (iI = 0; iI < MAX_PLAYERS; iI++)
{
pNewCity->setEverOwned(((PlayerTypes)iI), abEverOwned[iI]);
@@ -1965,6 +1965,12 @@
iValue *= 8;
break;
+ // < Inquisition by Lopez Start >
+ case UNITAI_INQUISITOR:
+ iValue *= 12;
+ break;
+ // < Inquisition End >
+
case UNITAI_PROPHET:
case UNITAI_ARTIST:
case UNITAI_SCIENTIST:
@@ -1997,6 +2003,9 @@
case UNITAI_ASSAULT_SEA:
case UNITAI_SETTLER_SEA:
case UNITAI_MISSIONARY_SEA:
+
+ case UNITAI_INQUISITOR_SEA: // < Inquisition by Lopez >
+
case UNITAI_SPY_SEA:
case UNITAI_CARRIER_SEA:
iValue *= 5;
@@ -2177,7 +2186,7 @@
{
FAssertMsg((getLeaderType() >= 0), "getLeaderType() is less than zero");
FAssertMsg((eTrait >= 0), "eTrait is less than zero");
- // < Scriptable Leader Traits Start >
+ // < Scriptable Leader Traits by Lopez & Impaler[WrG] Start >
// ORIGINAL CDOE return GC.getLeaderHeadInfo(getLeaderType()).hasTrait(eTrait);
return m_pbTraits[(int)eTrait];
// < Scriptable Leader Traits End >
@@ -2191,10 +2200,10 @@
return false;
}
-// ---------------- AI_AUTO_PLAY_MOD start (2006-07-04)-------------------
+ // Revolution Mod by jdog5000 Start >
if( m_bDisableHuman )
return false;
-// ---------------- AI_AUTO_PLAY_MOD end ---------------------------------
+ // Revolution Mod End >
return GC.getInitCore().getHuman(getID());
}
@@ -2850,6 +2859,9 @@
{
if (pLoopSelectionGroup->isBusy())
{
+ if (pLoopSelectionGroup->getNumUnits() == 0)
+ pLoopSelectionGroup->kill();
+ else
return true;
}
}
@@ -2993,11 +3005,12 @@
iCount = 0;
+ int iAreaID = pArea->getID();
for (pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))
{
if (pLoopCity->isCoastal(GC.getDefineINT("MIN_WATER_SIZE_FOR_OCEAN")))
{
- if ((pLoopCity->area() == pArea) || pLoopCity->plot()->isAdjacentToArea(pArea))
+ if ((pLoopCity->getArea() == iAreaID) || pLoopCity->plot()->isAdjacentToArea(iAreaID))
{
iCount++;
}
@@ -4971,6 +4984,17 @@
}
}
+ // < Building Civic Prereqs by Mexico Start >
+ for(iI = 0; iI < GC.getNumCivicInfos(); iI++)
+ {
+ if (GC.getBuildingInfo(eBuilding).isPrereqCivic(iI))
+ {
+ if (!isCivic((CivicTypes)iI))
+ return false;
+ }
+ }
+ // < Building Civic Prereqs End >
+
if (GC.getGameINLINE().countCivTeamsEverAlive() < GC.getBuildingInfo(eBuilding).getNumTeamsPrereq())
{
return false;
@@ -5451,24 +5475,22 @@
{
changeCommerceRateModifier(((CommerceTypes)iI), (GC.getBuildingInfo(eBuilding).getGlobalCommerceModifier(iI) * iChange));
- // Start Change SpecialistTechCommerceChange by Impaler[WrG]
+ // < Specialist Tech Commerce Change by Impaler[WrG] Start >
// ORIGINAL CODE changeSpecialistExtraCommerce(((CommerceTypes)iI), (GC.getBuildingInfo(eBuilding).getSpecialistExtraCommerce(iI) * iChange));
for (int iS = 0; iS < GC.getNumSpecialistInfos(); iS++)
{
changeSpecialistTypeExtraCommerce((SpecialistTypes) iS, (CommerceTypes)iI, (GC.getBuildingInfo(eBuilding).getSpecialistExtraCommerce(iI) * iChange));
}
- // End Change By Impaler[WrG]
+ // < Specialist Tech Commerce Change End >
changeStateReligionBuildingCommerce(((CommerceTypes)iI), (GC.getBuildingInfo(eBuilding).getStateReligionCommerce(iI) * iChange));
changeCommerceFlexibleCount(((CommerceTypes)iI), (GC.getBuildingInfo(eBuilding).isCommerceFlexible(iI)) ? iChange : 0);
}
- // Start BuildingClass Fix by Impaler[WrG]
for (iI = 0; iI < GC.getNumBuildingInfos(); iI++)
{
changeExtraBuildingHappiness((BuildingTypes) iI, (GC.getBuildingInfo(eBuilding).getBuildingClassHappinessChanges(GC.getBuildingInfo((BuildingTypes)iI).getBuildingClassType()) * iChange));
}
- // End BuildingClass Fix by Impaler[WrG]
for (iI = 0; iI < GC.getNumSpecialistInfos(); iI++)
{
@@ -5478,11 +5500,11 @@
}
}
- changeDistanceMaintenanceModifier(GC.getBuildingInfo(eBuilding).getDistanceMaintenanceModifier() * iChange); // Addition WonderMaintanceModifier by Impaler[WrG]
- changeNumCitiesMaintenanceModifier(GC.getBuildingInfo(eBuilding).getNumCitiesMaintenanceModifier() * iChange); // Addition WonderMaintanceModifier by Impaler[WrG]
- changeUpgradeCostModifier(GC.getBuildingInfo(eBuilding).getUpgradeCostModifier() * iChange); // Addition UpgradeCostModifier by Impaler[WrG] 7/11/07
+ changeDistanceMaintenanceModifier(GC.getBuildingInfo(eBuilding).getDistanceMaintenanceModifier() * iChange); // < Global Distance Maintance Modifier by Impaler[WrG] >
+ changeNumCitiesMaintenanceModifier(GC.getBuildingInfo(eBuilding).getNumCitiesMaintenanceModifier() * iChange); // < Global NumCities Maintance Modifier by Impaler[WrG] >
+ changeUpgradeCostModifier(GC.getBuildingInfo(eBuilding).getUpgradeCostModifier() * iChange); // < UpgradeCost Modifier by Impaler[WrG]>
- // Start Addition SpecialBuildingCommerceChange by Impaler[WrG]
+ // < SpecialBuilding Commerce Change by Impaler[WrG] Start >
for (iI = 0; iI < GC.getNumSpecialBuildingInfos(); iI++)
{
for(iJ = 0; iJ < NUM_COMMERCE_TYPES; iJ++)
@@ -5490,9 +5512,9 @@
changeSpecialBuildingCommerceChangeArray(iI, iJ, GC.getBuildingInfo(eBuilding).getSpecialBuildingCommerceChange(iI,iJ) * iChange);
}
}
- // Start Addition SpecialBuildingCommerceChange by Impaler[WrG]
+ // < SpecialBuilding Commerce Change End >
- // Start Addition FreePromotionWonder by Impaler[WrG]
+ // < Free Promotions by Impaler[WrG] Start >
if (GC.getBuildingInfo(eBuilding).getFreePromotions() > 0 && iChange > 0)
{
CvUnit* pLoopUnit;
@@ -5507,14 +5529,14 @@
}
}
}
- // End Addition FreePromotionWonder by Impaler[WrG]
+ // < Free Promotions End >
- changeDiplomacyModifier(GC.getBuildingInfo(eBuilding).getDiplomacyModifier()* iChange); // Addition BuildingDiplomacyModifier by Impaler[WrG]
+ changeDiplomacyModifier(GC.getBuildingInfo(eBuilding).getDiplomacyModifier()* iChange); // < Building Diplomacy Modifier by Impaler[WrG] >
- changeImprovementUpgradeRateModifier(GC.getBuildingInfo(eBuilding).getImprovmentUpgradeRateModifier()* iChange); // Wonder Improvment Upgrades by Impaler[WrG]
- changeHappyPerMilitaryUnit(GC.getBuildingInfo(eBuilding).getGlobalHappinessPerMilitaryUnit()* iChange); // Wonder Military Happyness by Impaler[WrG]
- //changeBuildingProductionModifier(GC.getBuildingInfo(eBuilding).getBuildingProductionModifier()* iChange); // Wonder Building Production Modifier by Impaler[WrG]
- changeVoteModifier(GC.getBuildingInfo(eBuilding).getVoteModifier()* iChange); // Wonder Vote Modifier by Impaler[WrG]
+ changeImprovementUpgradeRateModifier(GC.getBuildingInfo(eBuilding).getImprovmentUpgradeRateModifier()* iChange); // < Global Improvment Upgrades by Impaler[WrG] >
+ changeHappyPerMilitaryUnit(GC.getBuildingInfo(eBuilding).getGlobalHappinessPerMilitaryUnit()* iChange); // < Wonder Military Happyness by Impaler[WrG] >
+ changeBuildingProductionModifier(GC.getBuildingInfo(eBuilding).getBuildingProductionModifier()* iChange); // < Wonder Building Production Modifier by Impaler[WrG] >
+ changeVoteModifier(GC.getBuildingInfo(eBuilding).getVoteModifier()* iChange); // < Wonder Vote Modifier by Impaler[WrG] >
}
@@ -6135,13 +6157,11 @@
}
}
- // Start Addition Wonder Secret Tech by moctezuma
+ // < Wonder Secret Tech by moctezuma Start >
if (bTrade)
{
if (!canEverTrade(eTech))
- {
return false;
- }
}
else // Original Behavior
{
@@ -6150,7 +6170,7 @@
return false;
}
}
- // End Addition by moctezuma
+ // < Wonder Secret Tech End >
return true;
}
@@ -6864,10 +6884,10 @@
int CvPlayer::specialistCommerce(SpecialistTypes eSpecialist, CommerceTypes eCommerce)
{
- //Start Change SpecialistTechCommerceChange by Impaler[WrG]
+ // < Specialist Tech Commerce Change by Impaler[WrG] Start >
//ORIGINAL CODE return (GC.getSpecialistInfo(eSpecialist).getCommerceChange(eCommerce) + getSpecialistExtraCommerce(eCommerce));
return (GC.getSpecialistInfo(eSpecialist).getCommerceChange(eCommerce) + getSpecialistTypeExtraCommerce(eSpecialist, eCommerce));
- //End Change by Impaler[WrG]
+ // < Specialist Tech Commerce Change End >
}
@@ -8609,28 +8629,21 @@
ORIGINAL CODE END */
if (iExperience == getCombatExperience())
- {
return;
- }
if (isBarbarian() && !GC.getDefineBOOL("GREAT_GENERAL_FOR_BARBARIANS"))
- {
return;
- }
m_iCombatExperience = iExperience;
int iExperienceThreshold = greatPeopleThreshold(true);
if (m_iCombatExperience < iExperienceThreshold)
- {
return;
- }
if(iExperienceThreshold <= 0)
- {
return;
- }
+
// < Great Generals From Barbarian Combat End >
// create great person
@@ -8662,11 +8675,11 @@
UnitTypes eLoopUnit = (UnitTypes)((iI + iRandOffset) % GC.getNumUnitInfos());
if (GC.getUnitInfo(eLoopUnit).getLeaderExperience() > 0 || GC.getUnitInfo(eLoopUnit).getLeaderPromotion() != NO_PROMOTION)
{
- // Start Unique GreatPeople by Mexico
+ // < Unique GreatPeople by Mexico Start >
UnitClassTypes eUnitClass = (UnitClassTypes)GC.getUnitInfo(eLoopUnit).getUnitClassType();
UnitTypes iUniqueUnit = (UnitTypes)GC.getCivilizationInfo((CivilizationTypes)getCivilizationType()).getCivilizationUnits((int)eUnitClass);
eLoopUnit = (UnitTypes)((iUniqueUnit != NO_UNIT) ? iUniqueUnit : eLoopUnit);
- // End by Mexico
+ // < Unique GreatPeople End >
pBestCity->createGreatPeople(eLoopUnit, false, true);
setCombatExperience(getCombatExperience() - iExperienceThreshold);
@@ -9363,6 +9376,20 @@
updateReligionHappiness();
updateReligionCommerce();
+ // < Prereq Religion Building Obsoleted by Mexico Start >
+ if (GC.getDefineBOOL("BUILDINGS_OBSOLETE_WITHOUT_PREREQ_RELIGION"))
+ {
+ if (getLastStateReligion() != NO_RELIGION)
+ {
+ for (iI = 0; iI < GC.getNumBuildingInfos(); iI++)
+ {
+ if (GC.getBuildingInfo((BuildingTypes)iI).isPrereqReligion())
+ GET_TEAM(getTeam()).changeObsoleteBuildingCount((BuildingTypes)iI, 1);
+ }
+ }
+ }
+ // < PrereqReligion Building Obsoleted End >
+
GC.getGameINLINE().AI_makeAssignWorkDirty();
gDLL->getInterfaceIFace()->setDirty(Score_DIRTY_BIT, true);
@@ -11342,7 +11369,11 @@
void CvPlayer::deleteSelectionGroup(int iID)
{
- m_selectionGroups.removeAt(iID);
+ // < SelectionGroup Delete chck by ??? Start >
+ bool bRemoved = m_selectionGroups.removeAt(iID);
+
+ FAssertMsg(bRemoved, "could not find group, delete failed");
+ // < SelectionGroup Delete chck by ??? Start >
}
@@ -11817,7 +11848,7 @@
changeCapitalYieldRateModifier(((YieldTypes)iI), (GC.getCivicInfo(eCivic).getCapitalYieldModifier(iI) * iChange));
changeTradeYieldModifier(((YieldTypes)iI), (GC.getCivicInfo(eCivic).getTradeYieldModifier(iI) * iChange));
- // Start CivicBalancer by Aussie Lurker
+ // < Civic Balancer by Aussie Lurker Start >
changeStateReligionYieldRateModifier(((YieldTypes)iI), (GC.getCivicInfo(eCivic).getStateReligionYieldModifier(iI) * iChange));
changeNonStateReligionYieldRateModifier(((YieldTypes)iI), (GC.getCivicInfo(eCivic).getNonStateReligionYieldModifier(iI) * iChange));
@@ -11825,7 +11856,7 @@
{
changeSpecialistExtraYield((SpecialistTypes) iJ, (YieldTypes)iI, (GC.getCivicInfo(eCivic).getSpecialistExtraYield(iI) * iChange));
}
- // End CivicBalancer
+ // < Civic Balancer End >
}
for (iI = 0; iI < NUM_COMMERCE_TYPES; iI++)
@@ -11833,25 +11864,25 @@
changeCommerceRateModifier(((CommerceTypes)iI), (GC.getCivicInfo(eCivic).getCommerceModifier(iI) * iChange));
changeCapitalCommerceRateModifier(((CommerceTypes)iI), (GC.getCivicInfo(eCivic).getCapitalCommerceModifier(iI) * iChange));
- // Start Change SpecialistTechCommerceChange by Impaler[WrG]
+ // < Specialist Tech Commerce by Impaler[WrG] Start >
// ORIGINAL CODE changeSpecialistExtraCommerce(((CommerceTypes)iI), (GC.getCivicInfo(eCivic).getSpecialistExtraCommerce(iI) * iChange));
for (iJ = 0; iJ < GC.getNumSpecialistInfos(); iJ++)
{
changeSpecialistTypeExtraCommerce((SpecialistTypes) iJ, (CommerceTypes)iI, (GC.getCivicInfo(eCivic).getSpecialistExtraCommerce(iI) * iChange));
}
- // End Change by Impaler[WrG]
+ // < Specialist Tech Commerce End >
- // Start CivicBalancer by Aussie Lurker
+ // < Civic Balancer by Aussie Lurker Start >
changeStateReligionCommerceRateModifier(((CommerceTypes)iI), (GC.getCivicInfo(eCivic).getStateReligionCommerceModifier(iI) * iChange));
changeNonStateReligionCommerceRateModifier(((CommerceTypes)iI), (GC.getCivicInfo(eCivic).getNonStateReligionCommerceModifier(iI) * iChange));
- // End CivicBalancer
+ // < Civic Balancer End >
}
for (iI = 0; iI < GC.getNumBuildingInfos(); iI++)
{
changeExtraBuildingHappiness(((BuildingTypes)iI), (GC.getCivicInfo(eCivic).getBuildingHappinessChanges(iI) * iChange));
- // Start CivicBalancer by Aussie Lurker
+ // < Civic Balancer by Aussie Lurker Start >
BuildingClassTypes eBuildingClass = (BuildingClassTypes) GC.getBuildingInfo((BuildingTypes)iI).getBuildingClassType();
for (iJ; iJ < NUM_YIELD_TYPES; iJ++)
@@ -11862,7 +11893,7 @@
{
changeBuildingCommerceChange(((BuildingTypes)iI), (CommerceTypes) iJ, (GC.getCivicInfo(eCivic).getBuildingClassCommerceChanges(eBuildingClass, (CommerceTypes) iJ)) * iChange);
}
- // End CivicBalancer
+ // < Civic Balancer End >
}
for (iI = 0; iI < GC.getNumFeatureInfos(); iI++)
@@ -11893,7 +11924,7 @@
}
}
- // Start CivicBalancer by Aussie Lurker
+ // < Civic Balancer by Aussie Lurker Start >
for (iI = 0; iI < GC.getNumBuildingInfos(); iI++)
{
for (iJ = 0; iJ < NUM_YIELD_TYPES; iJ++)
@@ -11919,7 +11950,7 @@
changeStateReligionExtraHealth(GC.getCivicInfo(eCivic).getStateReligionExtraHealth() * iChange);
changeNonStateReligionExtraHealth(GC.getCivicInfo(eCivic).getNonStateReligionExtraHealth() * iChange);
updateBuildingCommerce();
- // End CivicBalancer
+ // < Civic Balancer End >
}
void CvPlayer::showMissedMessages()
@@ -13575,5 +13606,107 @@
{
m_iGlobalPandemicModifier = iNewValue;
}
+// Pandemic system by Mexico - End
-// Pandemic system by Mexico - End
+int CvPlayer::startingPlotDistanceFactor(CvPlot* pPlot, PlayerTypes ePlayer, int iRange)
+{
+ PROFILE_FUNC();
+
+ FAssert(ePlayer != getID());
+ CvPlot* pStartingPlot;
+ int iValue = 100;
+ pStartingPlot = getStartingPlot();
+
+ if (pStartingPlot != NULL)
+ {
+ if (GC.getGameINLINE().isTeamGame())
+ {
+ if (GET_PLAYER(ePlayer).getTeam() == getTeam())
+ {
+ iRange *= GC.getDefineINT("OWN_TEAM_STARTING_MODIFIER");
+ iRange /= 100;
+ }
+ else
+ {
+ iRange *= GC.getDefineINT("RIVAL_TEAM_STARTING_MODIFIER");
+ iRange /= 100;
+ }
+ }
+
+ int iDistance = plotDistance(pPlot->getX_INLINE(), pPlot->getY_INLINE(), pStartingPlot->getX_INLINE(), pStartingPlot->getY_INLINE());
+ if (pStartingPlot->getArea() != pPlot->getArea())
+ {
+ iDistance *= 4;
+ iDistance /= 3;
+ }
+ iValue *= iDistance;
+ iValue /= iRange ;
+ }
+ return max(1, iValue);
+}
+
+int CvPlayer::getResearchTurnsLeftTimes100(TechTypes eTech, bool bOverflow)
+{
+ int iResearchRate;
+ int iOverflow;
+ int iResearchLeft;
+ int iTurnsLeft;
+ int iI;
+
+ iResearchRate = 0;
+ iOverflow = 0;
+
+ for (iI = 0; iI < MAX_PLAYERS; iI++)
+ {
+ if (GET_PLAYER((PlayerTypes)iI).isAlive())
+ {
+ if (GET_PLAYER((PlayerTypes)iI).getTeam() == getTeam())
+ {
+ if ((iI == getID()) || (GET_PLAYER((PlayerTypes)iI).getCurrentResearch() == eTech))
+ {
+ iResearchRate += GET_PLAYER((PlayerTypes)iI).calculateResearchRate(eTech);
+ iOverflow += (GET_PLAYER((PlayerTypes)iI).getOverflowResearch() * calculateResearchModifier(eTech)) / 100;
+ }
+ }
+ }
+ }
+
+ if (iResearchRate == 0)
+ return MAX_INT;
+
+ iResearchLeft = GET_TEAM(getTeam()).getResearchLeft(eTech);
+
+ if (bOverflow)
+ iResearchLeft -= iOverflow;
+
+ iResearchLeft *= 100;
+ iTurnsLeft = (iResearchLeft / iResearchRate);
+
+ return max(1, iTurnsLeft);
+}
+
+// < Inquisition by Lopez Start >
+int CvPlayer::countRemoveNonStateReligionUnits(CvArea* pArea, ReligionTypes eReligion)
+{
+ PROFILE_FUNC();
+
+ CvUnit* pLoopUnit;
+ int iCount = 0;
+ int iLoop;
+
+ for (pLoopUnit = firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = nextUnit(&iLoop))
+ {
+ if (pLoopUnit->area() == pArea)
+ {
+ if (getStateReligion() == GC.getUnitInfo(pLoopUnit->getUnitType()).getPrereqReligion() && GC.getUnitInfo(pLoopUnit->getUnitType()).isRemoveNonStateReligion())
+ iCount++;
+ }
+ }
+ return iCount;
+}
+// < Inquisition End >
+
+bool CvPlayer::canPopRush()
+{
+ return (m_iPopRushHurryCount > 0);
+}
Modified: CvGameCoreDLL/CvPlot.cpp
===================================================================
--- CvGameCoreDLL/CvPlot.cpp 2007-03-13 05:07:20 UTC (rev 41)
+++ CvGameCoreDLL/CvPlot.cpp 2007-03-14 05:15:29 UTC (rev 42)
@@ -120,7 +120,8 @@
SAFE_DELETE_ARRAY(m_paiBuildProgress);
gDLL->getFeatureIFace()->destroy(m_pFeatureSymbol);
- if(m_pPlotBuilder) {
+ if(m_pPlotBuilder)
+ {
gDLL->getPlotBuilderIFace()->destroy(m_pPlotBuilder);
}
gDLL->getRouteIFace()->destroy(m_pRouteSymbol);
@@ -952,6 +953,7 @@
bool CvPlot::isConnectedTo(const CvCity* pCity) const
{
+ FAssert(isOwned());
return ((getPlotGroup(getOwnerINLINE()) == pCity->plotGroup(getOwnerINLINE())) || (getPlotGroup(pCity->getOwnerINLINE()) == pCity->plotGroup(pCity->getOwnerINLINE())));
}
@@ -1087,7 +1089,7 @@
}
-bool CvPlot::isAdjacentToArea(const CvArea* pArea) const
+bool CvPlot::isAdjacentToArea(int iAreaID) const
{
PROFILE_FUNC();
@@ -1100,7 +1102,7 @@
if (pAdjacentPlot != NULL)
{
- if (pAdjacentPlot->area() == pArea)
+ if (pAdjacentPlot->getArea() == iAreaID)
{
return true;
}
@@ -1110,17 +1112,22 @@
return false;
}
+bool CvPlot::isAdjacentToArea(const CvArea* pArea) const
+{
+ return isAdjacentToArea(pArea->getID());
+}
+
bool CvPlot::shareAdjacentArea(const CvPlot* pPlot) const
{
PROFILE_FUNC();
- CvArea* pCurrArea;
- CvArea* pLastArea;
+ int iCurrArea;
+ int iLastArea;
CvPlot* pAdjacentPlot;
int iI;
- pLastArea = NULL;
+ iLastArea = FFreeList::INVALID_INDEX;
for (iI = 0; iI < NUM_DIRECTION_TYPES; iI++)
{
@@ -1128,16 +1135,16 @@
if (pAdjacentPlot != NULL)
{
- pCurrArea = pAdjacentPlot->area();
+ iCurrArea = pAdjacentPlot->getArea();
- if (pCurrArea != pLastArea)
+ if (iCurrArea != iLastArea)
{
- if (pPlot->isAdjacentToArea(pCurrArea))
+ if (pPlot->isAdjacentToArea(iCurrArea))
{
return true;
}
- pLastArea = pCurrArea;
+ iLastArea = iCurrArea;
}
}
}
@@ -1779,7 +1786,33 @@
}
}
+/*
+// adds all plots visible from this at iRange to visiblePlots if they do not already exist in it,
+void CvPlot::addVisiblePlots(CvPlotRegion& visiblePlots, int iRange, TeamTypes eTeam) const
+{
+ ::addVisiblePlots(visiblePlots, getX_INLINE(), getY_INLINE(), iRange, eTeam);
+}
+// adds all plots visible from this at iRange to visiblePlots if they do not already exist in it,
+// and adds the (*iObserverCount*visibility) value to the int value for each plot
+void CvPlot::addVisiblePlots(CvPlotDataRegion& visiblePlots, int iRange, int iObserverCount, TeamTypes eTeam) const
+{
+ ::addVisiblePlots(visiblePlots, getX_INLINE(), getY_INLINE(), iRange, iObserverCount, eTeam);
+}
+
+// builds a region of plots visible to all the units in this plot
+void CvPlot::buildVisibilityRegion(CvPlotRegion& visiblePlots, TeamTypes eTeam) const
+{
+ ::buildVisibilityRegion(visiblePlots, getX_INLINE(), getY_INLINE(), m_units, eTeam);
+}
+
+// builds a region of plots visible to all the units in this plot, the data value is set to the visibility count
+void CvPlot::buildVisibilityRegion(CvPlotDataRegion& visiblePlots, TeamTypes eTeam) const
+{
+ ::buildVisibilityRegion(visiblePlots, getX_INLINE(), getY_INLINE(), m_units, eTeam);
+}
+*/
+
bool CvPlot::canHaveBonus(BonusTypes eBonus, bool bIgnoreLatitude) const
{
FAssertMsg(getTerrainType() != NO_TERRAIN, "TerrainType is not assigned a valid value");
@@ -1951,12 +1984,12 @@
bValid = true;
}
- // Start Addition ImprovmentUpgrading by Impaler[WrG]
+ // < Improvment Upgrading by Impaler[WrG] Start >
if ((getImprovementType() != NO_IMPROVEMENT) && GC.getImprovementInfo(eImprovement).getImprovementMakesValid(getImprovementType()))
{
bValid = true;
}
- // End Addition by Impaler[WrG]
+ // < Improvment Upgrading End >
if (!bValid)
{
@@ -2062,16 +2095,16 @@
{
if (GET_PLAYER(ePlayer).getTeam() != getTeam())
{
- // Start Change Improvements Outside Borders by Lopez / PlayerBuildoutsideBorders by Impaler[WrG] Start
+ // < Improvements Outside Borders by Lopez & PlayerBuildoutsideBorders by Impaler[WrG] Start >
// ORIGINAL CODE return false;
if (getTeam() == NO_TEAM)
{
if(!GC.getImprovementInfo(eImprovement).canBuildOutsideBorder() && !GET_PLAYER(ePlayer).canBuildOutsideBorders())
- {return false;}
+ return false;
}
else
- {return false;}
- // End Change Improvements Outside Borders by Lopez End
+ return false;
+ // < Improvements Outside Borders & PlayerBuildoutsideBorders End >
}
}
@@ -2268,10 +2301,10 @@
{
if (!bTestCanMove || (pLoopUnit->canMove() && !(pLoopUnit->isCargo())))
{
- // < Air Forces Start >
+ // < Air Forces by Lopez Start >
// ORIGINAL CODE if ((pAttacker == NULL) || (pAttacker->getDomainType() != DOMAIN_AIR) || (pLoopUnit->getDamage() < pAttacker->airCombatLimit()))
if ((pAttacker == NULL) || (pAttacker->getDomainType() != DOMAIN_AIR)) //< pAttacker->airCombatLimit()))
- // < Air Forces End >
+ // < Air Forces End >
{
if (pLoopUnit->isBetterDefenderThan(pBestUnit, pAttacker))
{
@@ -2288,7 +2321,48 @@
return pBestUnit;
}
+// returns a sum of the strength (adjusted by firepower) of all the units on a plot
+int CvPlot::AI_sumStrength(PlayerTypes eOwner, PlayerTypes eAttackingPlayer, DomainTypes eDomainType, bool bDefensiveBonuses, bool bTestAtWar, bool bTestPotentialEnemy) const
+{
+ CLLNode<IDInfo>* pUnitNode;
+ CvUnit* pLoopUnit;
+ int strSum = 0;
+ pUnitNode = headUnitNode();
+
+ while (pUnitNode != NULL)
+ {
+ pLoopUnit = ::getUnit(pUnitNode->m_data);
+ pUnitNode = nextUnitNode(pUnitNode);
+
+ if ((eOwner == NO_PLAYER) || (pLoopUnit->getOwnerINLINE() == eOwner))
+ {
+ if ((eAttackingPlayer == NO_PLAYER) || !(pLoopUnit->isInvisible(GET_PLAYER(eAttackingPlayer).getTeam(), false)))
+ {
+ if (!bTestAtWar || (eAttackingPlayer == NO_PLAYER) || atWar(GET_PLAYER(eAttackingPlayer).getTeam(), pLoopUnit->getTeam()))
+ {
+ if (!bTestPotentialEnemy || (eAttackingPlayer == NO_PLAYER) || isPotentialEnemy(GET_PLAYER(eAttackingPlayer).getTeam(), pLoopUnit->getTeam()))
+ {
+ // we may want to be more sophisticated about domains
+ // somewhere we need to check to see if this is a city, if so, only land units can defend here, etc
+ if (eDomainType == NO_DOMAIN || (pLoopUnit->getDomainType() == eDomainType))
+ {
+ const CvPlot* pPlot = NULL;
+
+ if (bDefensiveBonuses)
+ pPlot = this;
+
+ strSum += pLoopUnit->currEffectiveStr(pPlot, NULL);
+ }
+ }
+ }
+ }
+ }
+ }
+ return strSum;
+}
+
+
CvUnit* CvPlot::getSelectedUnit() const
{
CLLNode<IDInfo>* pUnitNode;
@@ -2405,35 +2479,18 @@
}
}
- // Start Change RogerBacon FlyingMod
+ // < FlyingMod by RogerBacon Start >
// Original if (!(pFromPlot->isValidDomainForLocation(pUnit->getDomainType())))
- if (!(pFromPlot->isValidDomainForLocation(pUnit,pUnit->getDomainType()))) //RogerBacon FlyingMod
- // End Change RogerBacon
+ if (!(pFromPlot->isValidDomainForLocation(pUnit,pUnit->getDomainType())))
+ // < FlyingMod End >
{
return pUnit->maxMoves();
}
- /*
- if (isOwned() && getOwnerINLINE() != pFromPlot->getOwnerINLINE())
- {
- if (DOMAIN_LAND == pUnit->getDomainType())
- {
- TeamTypes ePlotTeam = GET_PLAYER(getOwnerINLINE()).getTeam();
- if (area()->isBorderObstacle(ePlotTeam))
- {
- if (GET_TEAM(ePlotTeam).isAtWar(pUnit->getTeam()))
- {
- return pUnit->maxMoves();
- }
- }
- }
- }
- */
-
- // Start Change by RogerBacon FlyingMod
+ // < FlyingMod by RogerBacon Start >
// Original if (!isValidDomainForAction(pUnit->getDomainType()))
- if (!isValidDomainForAction(pUnit, pUnit->getDomainType()))//RogerBacon FlyingMod
- // End Change by RogerBacon
+ if (!isValidDomainForAction(pUnit, pUnit->getDomainType()))
+ // < FlyingMod End >
{
return GC.getMOVE_DENOMINATOR();
}
@@ -5759,7 +5816,9 @@
CvPlot* pAdjacentPlot;
int iI;
- if (getFoundValue(eIndex) == 0)
+ int iPlotValue = GET_PLAYER(eIndex).AI_foundValue(getX_INLINE(), getY_INLINE());
+
+ if (iPlotValue == 0)
{
return false;
}
@@ -5768,9 +5827,9 @@
{
pAdjacentPlot = plotDirection(getX_INLINE(), getY_INLINE(), ((DirectionTypes)iI));
- if (pAdjacentPlot != NULL)
+ if ((pAdjacentPlot != NULL) && pAdjacentPlot->isRevealed(GET_PLAYER(eIndex).getTeam(), false))
{
- if (pAdjacentPlot->getFoundValue(eIndex) >= getFoundValue(eIndex))
+ if (GET_PLAYER(eIndex).AI_foundValue(pAdjacentPlot->getX_INLINE(), pAdjacentPlot->getY_INLINE()) > iPlotValue)
{
return false;
}
@@ -6159,7 +6218,47 @@
}
}
+void CvPlot::clearAllVisibility()
+{
+ PROFILE_FUNC();
+ for (int iI = 0; iI < MAX_TEAMS; iI++)
+ {
+ TeamTypes eTeam = (TeamTypes) iI;
+ bool bOldVisible = isVisible(eTeam, false);
+
+ m_aiVisibilityCount[eTeam] = 0;
+ m_aiStolenVisibilityCount[eTeam] = 0;
+
+ for (int iJ = 0; iJ < GC.getNumInvisibleInfos(); iJ++)
+ {
+ if (m_apaiInvisibleVisibilityCount[eTeam] != NULL)
+ {
+ m_apaiInvisibleVisibilityCount[eTeam][iJ] = 0;
+ }
+ }
+
+ if (bOldVisible)
+ {
+ CvCity* pCity = getPlotCity();
+ if (pCity != NULL)
+ {
+ pCity->setInfoDirty(true);
+ }
+
+ if (eTeam == GC.getGameINLINE().getActiveTeam())
+ {
+ PROFILE("CvPlot::clearAllVisibility 1");
+
+ updateFog();
+ updateMinimapColor();
+ updateCenterUnit();
+ }
+ }
+ }
+}
+
+
PlayerTypes CvPlot::getRevealedOwner(TeamTypes eTeam, bool bDebug) const
{
if (bDebug && GC.getGameINLINE().isDebugMode())
@@ -7998,19 +8097,16 @@
return iMaxYield;
}
-//-------------------NEW---------------------------
+//-----------------------CCCP NEW-------------------------------
bool CvPlot::isValidDomainForLocation(const CvUnit* pUnit, DomainTypes eDomain) const // Addition RogerBacon FlyingMod
{
if (isValidDomainForAction(pUnit, eDomain))
- {
return true;
- }
return isCity();
}
-//Polymorphic version of the Original function
bool CvPlot::isValidDomainForAction(const CvUnit* pUnit, DomainTypes eDomain) const // Addition RogerBacon FlyingMod
{
switch (eDomain)
@@ -8023,11 +8119,6 @@
return false;
break;
-/* case DOMAIN_LAND: //RogerBacon flyingMod
- case DOMAIN_IMMOBILE:
- return !(isWater());
- break;
-*/
case DOMAIN_LAND: //RogerBacon flyingMod
return (pUnit->isFlying()) || !(isWater());
break;
Added: CvGameCoreDLL/CvPlotRegion.h
===================================================================
--- CvGameCoreDLL/CvPlotRegion.h (rev 0)
+++ CvGameCoreDLL/CvPlotRegion.h 2007-03-14 05:15:29 UTC (rev 42)
@@ -0,0 +1,224 @@
+#ifndef CIV4_PLOT_REGION_H
+#define CIV4_PLOT_REGION_H
+
+#include <map>
+#include <set>
+
+#define GET_COORDS(it) (it->first)
+#define GET_VISIBILITY(it) (it->second)
+
+inline XYCoords getXYCoords(const std::set<XYCoords>::const_iterator itPlotRegion)
+{
+ return XYCoords(*itPlotRegion);
+}
+
+inline XYCoords getXYCoords(const std::map<XYCoords,int>::const_iterator itPlotRegion)
+{
+ return XYCoords((itPlotRegion->first));
+}
+
+inline XYCoords makeXYCoords(const std::set<XYCoords>::const_iterator itPlotRegion, XYCoords xy)
+{
+ return xy;
+}
+
+inline std::pair<XYCoords,int> makeXYCoords(const std::map<XYCoords,int>::const_iterator itPlotRegion, XYCoords xy)
+{
+ return std::pair<XYCoords,int>(xy, 0);
+}
+
+template <class _RegionIter>
+inline int getRegionValue(const _RegionIter itRegion)
+{
+ return itRegion->second;
+}
+
+template <class _RegionIter>
+inline void setRegionValue(const _RegionIter itRegion, int iValue)
+{
+ itRegion->second = iValue;
+}
+
+// increases the size of regionToAddTo by adding all plots in regionToAdd
+template <class _RegionClass>
+void regionUnion(_RegionClass& regionToAddTo, const _RegionClass& regionToAdd)
+{
+#ifndef check_our_work
+ _RegionClass addToCopy = regionToAddTo;
+#endif
+
+ // loop both until finished adding (both are in sorted order)
+ _RegionClass::iterator itAddTo = regionToAddTo.begin();
+ _RegionClass::const_iterator itAdd = regionToAdd.begin();
+ while (itAdd != regionToAdd.end())
+ {
+ bool bAtAddToEnd = (itAddTo == regionToAddTo.end());
+
+ XYCoords addXY = getXYCoords(itAdd);
+ XYCoords addToXY;
+ if (!bAtAddToEnd)
+ {
+ addToXY = getXYCoords(itAddTo);
+ }
+
+ // if not at addTo end and addTo less, increment addTo and loop again
+ if (!bAtAddToEnd && addToXY < addXY)
+ {
+ itAddTo++;
+ }
+ // if at addTo end or addTo more, insert here, increment add and loop again
+ else if (bAtAddToEnd || addXY < addToXY)
+ {
+ regionToAddTo.insert(itAddTo, (*itAdd));
+ itAdd++;
+ }
+ // otherwise they must be equal, it is in both, increment both
+ else
+ {
+ FAssert(!bAtAddToEnd);
+ FAssert(addToXY == addXY);
+ itAddTo++;
+ itAdd++;
+ }
+ }
+
+#ifndef check_our_work
+ for (_RegionClass::const_iterator it = regionToAdd.begin(); it != regionToAdd.end(); it++)
+ {
+ addToCopy.insert((*it));
+ }
+
+ FAssert(addToCopy.size() == regionToAddTo.size());
+
+ _RegionClass::const_iterator itCopy = addToCopy.begin();
+ for (_RegionClass::const_iterator it = regionToAddTo.begin(); it != regionToAddTo.end(); it++)
+ {
+ FAssert(*itCopy == *it);
+ FAssert(itCopy != addToCopy.end());
+
+ itCopy++;
+ }
+#endif
+}
+
+// subtract removes all plots in regionToSubtract from regionToSubtractFrom (non-symetrical difference)
+template <class _RegionClass>
+void regionDifference(_RegionClass& regionToSubtractFrom, const _RegionClass& regionToSubtract)
+{
+ for (_RegionClass::const_iterator it = regionToSubtract.begin(); it != regionToSubtract.end(); it++)
+ {
+ // if we have this plot in the set, remove it
+ _RegionClass::iterator itToSubtract = regionToSubtractFrom.find(getXYCoords(it));
+ if (itToSubtract != regionToSubtractFrom.end())
+ {
+ regionToSubtractFrom.erase(itToSubtract);
+ }
+ }
+}
+
+// removes intersection from both regions
+template <class _RegionClass>
+void removeIntersection (_RegionClass& regionA, _RegionClass& regionB)
+{
+ bool bAIsSmaller = regionA < regionB;
+ _RegionClass& smallerRegion = (bAIsSmaller) ? regionA : regionB;
+ _RegionClass& largerRegion = (bAIsSmaller) ? regionB : regionA;
+
+ // loop over the plots, removing as necessary
+ _RegionClass::iterator it = smallerRegion.begin();
+ while (it != smallerRegion.end())
+ {
+ // increment before we work with it, so we can remove it if necessary
+ _RegionClass::iterator itSmaller = it;
+ it++;
+
+ _RegionClass::iterator itLarger = largerRegion.find(getXYCoords(itSmaller));
+ if (itLarger != largerRegion.end())
+ {
+ largerRegion.erase(itLarger);
+ smallerRegion.erase(itSmaller);
+ }
+ }
+}
+
+class CvPlotRegion : public std::set<XYCoords>
+{
+public:
+ // adding builds a union of the two regions
+ void operator+= (const CvPlotRegion& regionToAdd)
+ {
+ regionUnion<CvPlotRegion>(*this, regionToAdd);
+ }
+
+ // subtract removes all plots in regionToSubtract (non-symetrical difference)
+ void operator-= (const CvPlotRegion& regionToSubtract)
+ {
+ regionDifference<CvPlotRegion>(*this, regionToSubtract);
+ }
+
+ // copy the left hand operand into new region, then += that with the right hand operand and return the result
+ CvPlotRegion operator+ (const CvPlotRegion& regionToAdd) const
+ {
+ CvPlotRegion resultRegion(*this);
+ resultRegion += regionToAdd;
+ return resultRegion;
+ }
+};
+
+typedef CvPlotRegion::iterator CvPlotRegionIterator;
+typedef CvPlotRegion::const_iterator CvPlotRegionConstIterator;
+
+class CvPlotDataRegion : public std::map<XYCoords,int>
+{
+public:
+ // adding adds the int values at each plot, building a union of the two regions with a sum of the values
+ void operator+= (const CvPlotDataRegion& regionToAdd)
+ {
+ for (CvPlotDataRegion::const_iterator it = regionToAdd.begin(); it != regionToAdd.end(); it++)
+ {
+ (*this)[(*it).first] += (*it).second;
+ }
+ }
+
+ // subtract finds the _positive_ intersection of the regions,
+ // if a point from regionToSubtract is in this region, then subtract the value from the other set
+ // if the result value is not positive, then remove this point from this set
+ // note, this is the only place where negative or zero visibility values cause a removal
+ // if -= is never called, then it is entirely legal to have zero or negative values
+ void operator-= (const CvPlotDataRegion& regionToSubtract)
+ {
+ for (CvPlotDataRegion::const_iterator it = regionToSubtract.begin(); it != regionToSubtract.end(); it++)
+ {
+ const XYCoords& xy = (*it).first;
+ // make sure we have this plot in the set
+ CvPlotDataRegion::iterator itFind = this->find(xy);
+ if (itFind != this->end())
+ {
+ // subtract
+ int iNewValue = (*itFind).second - (*it).second;
+ if (iNewValue > 0)
+ {
+ (*itFind).second = iNewValue;
+ }
+ else
+ {
+ this->erase(itFind);
+ }
+ }
+ }
+ }
+
+ // copy the left hand operand into new region, then += that with the right hand operand and return the result
+ CvPlotDataRegion operator+ (const CvPlotDataRegion& regionToAdd) const
+ {
+ CvPlotDataRegion resultRegion(*this);
+ resultRegion += regionToAdd;
+ return resultRegion;
+ }
+};
+
+typedef CvPlotDataRegion::iterator CvPlotDataRegionIterator;
+typedef CvPlotDataRegion::const_iterator CvPlotDataRegionConstIterator;
+typedef std::pair<XYCoords,int> CvVisibilityRegionPair;
+
+#endif
\ No newline at end of file
Modified: CvGameCoreDLL/CvUnit.cpp
===================================================================
--- CvGameCoreDLL/CvUnit.cpp 2007-03-13 05:07:20 UTC (rev 41)
+++ CvGameCoreDLL/CvUnit.cpp 2007-03-14 05:15:29 UTC (rev 42)
@@ -10821,3 +10821,20 @@
return size + sizeof(CvUnit);
}
// Private Functions...
+
+int CvUnit::getArea() const
+{
+ return plot()->getArea();
+}
+
+// < Better AI by Blake Start >
+int CvUnit::currEffectiveStr(const CvPlot* pPlot, const CvUnit* pAttacker, CombatDetails* pCombatDetails) const
+{
+ int currStr = currCombatStr(pPlot, pAttacker, pCombatDetails);
+
+ currStr *= (maxHitPoints() + currHitPoints());
+ currStr /= (2 * maxHitPoints());
+
+ return currStr;
+}
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|