Doto [AdvCiv ModMod]

Finally I had the time and mood for looking into the code. I tried compiling it but:

Spoiler error :

1>------ Build started: Project: CvGameCoreDLL, Configuration: Release-fast Win32 ------
1> Building source list
1> Running fastdep
1> CvArea.cpp
1> CvBuildingFilters.cpp
1> CvBuildingList.cpp
1> CvBuildingSort.cpp
1> CvBuildingInfo.cpp
1> CvCity.cpp
1> CvCityAI.cpp
1> CvContractBroker.cpp
1> CvDeal.cpp
1> CvDLLButtonPopup.cpp
1> CvDllTranslator.cpp
1> CvDLLWidgetData.cpp
1> CvEventReporter.cpp
1> CvGame.cpp
1> CvGameAI.cpp
1> CvGameCoreUtils.cpp
1> CvGameInterface.cpp
1> CvGameObject.cpp
1> CvGameTextMgr.cpp
1> CvGlobals.cpp
1> CvInfos.cpp
1> CvInitCore.cpp
1> CvMap.cpp
1> CvMapExternal.cpp
1> CvMessageControl.cpp
1> CvMessageData.cpp
1> CvOutcome.cpp
1> CvOutcomemission.cpp
1> CvPathGenerator.cpp
1> CvPlayer.cpp
1>..\CvPlayer.cpp(8859): error C2228: left of '.getBuilding' must have class/struct/union type
1> type is ''unknown-type''
1>..\CvPlayer.cpp(8859): error C3861: 'getCivilization': identifier not found, even with argument-dependent lookup
1>..\CvPlayer.cpp(8868): error C2228: left of '.getBuilding' must have class/struct/union type
1> type is ''unknown-type''
1>..\CvPlayer.cpp(8868): error C3861: 'getCivilization': identifier not found, even with argument-dependent lookup
1> jom: F:\Games\Civilization 4\Beyond the Sword\Mods\Chronicles of Mankind\CvGameCoreDLL\project\Makefile [temp_files\Release\.\CvPlayer.obj] Error 2
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command "set TARGET=Release
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: nmake source_list /NOLOGO
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: nmake fastdep /NOLOGO
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: nmake precompile /NOLOGO
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: bin\jom build /NOLOGO" exited with code 2.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


I atttached CvPlayer.cpp. Could you look into it, please? THX :)
 

Attachments

@<Nexus> hi

looks like an advCiv syntax.

replace this line
BuildingTypes const eCapitalBuilding2 = getCivilization().getBuilding((BuildingClassTypes)GC.getInfoTypeForString(
GC.getDefineSTRING("CAPITAL_BUILDINGCLASS_2")));
with:
BuildingTypes const eCapitalBuilding2 = GC.getCivilizationInfo(getCivilizationType()).getCivilizationBuildings((BuildingClassTypes)GC.getInfoTypeForString(
GC.getDefineSTRING("CAPITAL_BUILDINGCLASS_2")));
 
@<Nexus> hi

looks like an advCiv syntax.

replace this line
BuildingTypes const eCapitalBuilding2 = getCivilization().getBuilding((BuildingClassTypes)GC.getInfoTypeForString(
GC.getDefineSTRING("CAPITAL_BUILDINGCLASS_2")));
with:
BuildingTypes const eCapitalBuilding2 = GC.getCivilizationInfo(getCivilizationType()).getCivilizationBuildings((BuildingClassTypes)GC.getInfoTypeForString(
GC.getDefineSTRING("CAPITAL_BUILDINGCLASS_2")));
I guess I had to do the same for eCapitalBuilding3.

However there's an other error:
Spoiler :

1>------ Build started: Project: CvGameCoreDLL, Configuration: Release-fast Win32 ------
1> Building source list
1> Running fastdep
1> CvPlayer.cpp
1>..\CvPlayer.cpp(8860): error C2440: 'initializing' : cannot convert from 'int' to 'const BuildingTypes'
1> Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or function-style cast)
1>..\CvPlayer.cpp(8869): error C2440: 'initializing' : cannot convert from 'int' to 'const BuildingTypes'
1> Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or function-style cast)
1> jom: F:\Games\Civilization 4\Beyond the Sword\Mods\Chronicles of Mankind\CvGameCoreDLL\project\Makefile [temp_files\Release\.\CvPlayer.obj] Error 2
1> CvPlayerAI.cpp
1> CvPlot.cpp
1> CvPlotGroup.cpp
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command "set TARGET=Release
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: nmake source_list /NOLOGO
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: nmake fastdep /NOLOGO
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: nmake precompile /NOLOGO
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: bin\jom build /NOLOGO" exited with code 2.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


I tried this:
Code:
//doto113 keldath find the best capital enhanced start
        //BuildingClassTypes eCapitalBuilding2 = (BuildingClassTypes)GC.getInfoTypeForString(GC.getDefineSTRING("CAPITAL_BUILDINGCLASS_2"));
        BuildingTypes const eCapitalBuilding2 = GC.getCivilizationInfo(getCivilizationType()).getCivilizationBuildings((BuildingClassTypes)GC.getInfoTypeForString(
        GC.getDefineSTRING("CAPITAL_BUILDINGCLASS_2")));
        if (eCapitalBuilding2 != NO_BUILDING)
        {
            const eCapitalBuilding2Amnt = pLoopCity->getNumBuilding(eCapitalBuilding2);
            if (eCapitalBuilding2Amnt > 0)
                iValue += pLoopCity->getPopulation() * 2;
        }
        //BuildingClassTypes eCapitalBuilding3 = (BuildingClassTypes)GC.getInfoTypeForString(GC.getDefineSTRING("CAPITAL_BUILDINGCLASS_3"));
        BuildingTypes const eCapitalBuilding3 = GC.getCivilizationInfo(getCivilizationType()).getCivilizationBuildings((BuildingClassTypes)GC.getInfoTypeForString(
        GC.getDefineSTRING("CAPITAL_BUILDINGCLASS_3")));
        if (eCapitalBuilding3 != NO_BUILDING)
        {
            const eCapitalBuilding3Amnt = pLoopCity->getNumBuilding(eCapitalBuilding3);
            if (eCapitalBuilding3Amnt > 0)
                iValue += pLoopCity->getPopulation() * 2;
        }
        iValue += pLoopCity->getNumNationalWonders();
        iValue += pLoopCity->getNumWorldWonders();
//doto113 keldath find the best capital enhanced start
but the result was this:
Spoiler :

1>------ Build started: Project: CvGameCoreDLL, Configuration: Release-fast Win32 ------
1> Building source list
1> Running fastdep
1> CvPlayer.cpp
1>..\CvPlayer.cpp(8860): error C2440: 'initializing' : cannot convert from 'int' to 'const BuildingTypes'
1> Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or function-style cast)
1>..\CvPlayer.cpp(8869): error C2440: 'initializing' : cannot convert from 'int' to 'const BuildingTypes'
1> Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or function-style cast)
1> CvProperties.cpp
1> jom: F:\Games\Civilization 4\Beyond the Sword\Mods\Chronicles of Mankind\CvGameCoreDLL\project\Makefile [temp_files\Release\.\CvPlayer.obj] Error 2
1> CvReplayInfo.cpp
1> CvSelectionGroup.cpp
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command "set TARGET=Release
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: nmake source_list /NOLOGO
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: nmake fastdep /NOLOGO
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: nmake precompile /NOLOGO
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: bin\jom build /NOLOGO" exited with code 2.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



And a few questions:
What does the above code exactly do? Will it CHOOSE or will it NOT CHOOSE the city with Summer Palace or Versailles?
And since my mod has more buildings with bGovernmentCenter tag can I just make copies of the above lines to have eCapitalBuilding4, eCapitalBuilding5 and eCapitalBuilding6? And of course have to add respective values to globaldefines as well.
 
@<Nexus>
hey,
ok easy fix,
add this :(BuildingClassTypes)

BuildingTypes const eCapitalBuilding2 = (BuildingClassTypes)GC.getCivilizationInfo(getCivilizationType()).getCivilizationBuildings((BuildingClassTypes)GC.getInfoTypeForString(
GC.getDefineSTRING("CAPITAL_BUILDINGCLASS_2")));

The function returns a variable that is integer, the number index of the building in the xml by its position.
but, advCiv changed the return type to , BuildingTypes, which is a custom type.
so by adding the (BuildingClassTypes) you convert the int to (BuildingClassTypes).


for youquestions:


1. let me explain how it works, first.
in civ's code, everything works by scoring, thats how choices are made.
the more population a city have its value, aka score will be higher. lots pf values are considered.
so the higher the score , the choice will take the highest.
so if a city has building eCapitalBuilding2,....10 the value of that choice city will be higher, making it more likely to be the next Capital.
the score is based on the amount of population, so possibly a cirty with 30 pop' vs a city with 5 pop and Summer Palace, will probably loose to the 30 pop city.

2. absolutely, do the same for any added, both dlll and xml.

3. if you wanna raise the score value for these buildings, change the :
iValue += pLoopCity->getPopulation() * 2;
to what ever you want ->
iValue += pLoopCity->getPopulation() * 3
or
iValue += 500.....
or you can base it on some other parameter , for example, number of food yields * number of hammer yields :)
 
Ah! Thanks for the fix and the explanation. I'll try it ASAP.
I had a shallow guess that the code isn't a Yes/No thing (seeing the population*2) but great thanks for the explanation 🙂
 
Okaay, I did this:
Code:
//doto113 keldath find the best capital enhanced start
        //BuildingClassTypes eCapitalBuilding2 = (BuildingClassTypes)GC.getInfoTypeForString(GC.getDefineSTRING("CAPITAL_BUILDINGCLASS_2"));
        BuildingTypes const eCapitalBuilding2 = (BuildingClassTypes)GC.getCivilizationInfo(getCivilizationType()).getCivilizationBuildings((BuildingClassTypes)GC.getInfoTypeForString(
        GC.getDefineSTRING("CAPITAL_BUILDINGCLASS_2")));
        if (eCapitalBuilding2 != NO_BUILDING)
        {
            int eCapitalBuilding2Amnt = pLoopCity->getNumBuilding(eCapitalBuilding2);
            if (eCapitalBuilding2Amnt > 0)
                iValue += pLoopCity->getPopulation() * 2;
        }
        //BuildingClassTypes eCapitalBuilding3 = (BuildingClassTypes)GC.getInfoTypeForString(GC.getDefineSTRING("CAPITAL_BUILDINGCLASS_3"));
        BuildingTypes const eCapitalBuilding3 = (BuildingClassTypes)GC.getCivilizationInfo(getCivilizationType()).getCivilizationBuildings((BuildingClassTypes)GC.getInfoTypeForString(
        GC.getDefineSTRING("CAPITAL_BUILDINGCLASS_3")));
        if (eCapitalBuilding3 != NO_BUILDING)
        {
            int eCapitalBuilding3Amnt = pLoopCity->getNumBuilding(eCapitalBuilding3);
            if (eCapitalBuilding3Amnt > 0)
                iValue += pLoopCity->getPopulation() * 2;
        }
        iValue += pLoopCity->getNumNationalWonders();
        iValue += pLoopCity->getNumWorldWonders();
...and got this 😅
Spoiler :

1>------ Build started: Project: CvGameCoreDLL, Configuration: Release-fast Win32 ------
1> Building source list
1> Running fastdep
1> CvPlayer.cpp
1>..\CvPlayer.cpp(8860): error C2440: 'initializing' : cannot convert from 'BuildingClassTypes' to 'const BuildingTypes'
1> Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or function-style cast)
1>..\CvPlayer.cpp(8869): error C2440: 'initializing' : cannot convert from 'BuildingClassTypes' to 'const BuildingTypes'
1> Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or function-style cast)
1> CvSelectionGroupAI.cpp
1> CvStatistics.cpp
1> CvTeam.cpp
1> jom: F:\Games\Civilization 4\Beyond the Sword\Mods\Chronicles of Mankind\CvGameCoreDLL\project\Makefile [temp_files\Release\.\CvPlayer.obj] Error 2
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command "set TARGET=Release
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: nmake source_list /NOLOGO
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: nmake fastdep /NOLOGO
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: nmake precompile /NOLOGO
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: bin\jom build /NOLOGO" exited with code 2.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

 
@<Nexus>

Aha i maybe i got the wrong type try any of the followong:
BuildingTypes const eCapitalBuilding2 =
(BuildingTypes )GC.getCivilizationInfo(getCivilizationType()).getCivilizationBuildings((BuildingClassTypes)GC.getInfoTypeForString(
GC.getDefineSTRING("CAPITAL_BUILDINGCLASS_2")));


BuildingClassTypes eCapitalBuilding2 =
(BuildingClassTypes)GC.getCivilizationInfo(getCivilizationType()).getCivilizationBuildings((BuildingClassTypes)GC.getInfoTypeForString(
GC.getDefineSTRING("CAPITAL_BUILDINGCLASS_2")));

BuildingClassTypes eCapitalBuilding2 = (BuildingClassTypes)GC.getInfoTypeForString(GC.getDefineSTRING("CAPITAL_BUILDINGCLASS_2"));

BuildingTypes eCapitalBuilding2 = (BuildingTypes)GC.getInfoTypeForString(GC.getDefineSTRING("CAPITAL_BUILDINGCLASS_2"));


BuildingTypeseCapitalBuilding2 =
(BuildingTypes)GC.getCivilizationInfo(getCivilizationType()).getCivilizationBuildings((BuildingTypes)GC.getInfoTypeForString(
GC.getDefineSTRING("CAPITAL_BUILDINGCLASS_2")));
 
Aha i maybe i got the wrong type try any of the followong:
BuildingTypes const eCapitalBuilding2 =
(BuildingTypes )GC.getCivilizationInfo(getCivilizationType()).getCivilizationBuildings((BuildingClassTypes)GC.getInfoTypeForString(
GC.getDefineSTRING("CAPITAL_BUILDINGCLASS_2")));
Okay, this first one seems to have work. :goodjob:
At least the compilation was successful. Now I'll test it...


EDIT:
Tested aaaand... Capturing a capital makes the game CTD 😭
 
Last edited:
BuildingClassTypes eCapitalBuilding2 =
(BuildingClassTypes)GC.getCivilizationInfo(getCivilizationType()).getCivilizationBuildings((BuildingClassTypes)GC.getInfoTypeForString(
GC.getDefineSTRING("CAPITAL_BUILDINGCLASS_2")));
This one fails to compile.

BuildingClassTypes eCapitalBuilding2 = (BuildingClassTypes)GC.getInfoTypeForString(GC.getDefineSTRING("CAPITAL_BUILDINGCLASS_2"));
This one too.

BuildingTypes eCapitalBuilding2 = (BuildingTypes)GC.getInfoTypeForString(GC.getDefineSTRING("CAPITAL_BUILDINGCLASS_2"));
Failed.

BuildingTypeseCapitalBuilding2 =
(BuildingTypes)GC.getCivilizationInfo(getCivilizationType()).getCivilizationBuildings((BuildingTypes)GC.getInfoTypeForString(
GC.getDefineSTRING("CAPITAL_BUILDINGCLASS_2")));
Okay, this one compiled (despite a SPACE was missing ;) ) let's test it...

EDIT: No, CTD with this one too :(
 
Are you sure the global xml has that and other entries of the capital_building?

Wait,
Why did i marked this one off?
Try it:
//BuildingClassTypes eCapitalBuilding2 = (BuildingClassTypes)GC.getInfoTypeForString(GC.getDefineSTRING("CAPITAL_BUILDINGCLASS_2"));

I cant remember. I think im doing it wrong on the code that crashes to you. It gets the civ. We need the building.

We will win eventually, despair not.
 
No, sorry, it was totally on me. I forgot to copy GlobalDefines from my work folder to my gaming folder 😅

It's working fine :woohoo:

Spoiler :

Proof of success:
1717674313639.png


Guangzhu(4) has Summer Palace:
1717674455327.png


Guangzhu(4) has Summer Palace and Nanjing(5) has Versailles
1717674760914.png



Everything seems to work as intended.


THANK YOU VERY MUCH!
🤗🤗🤗
 
Last edited:
Looking at your SS, your in AE. What civics are you running? Demo/Fed civics make it really hard for any anarchy to happen unless your switching to a different civic. Also, if you have Cristo wonder, you won't have any anarchy. Just a possible answer to your question :D
 
Hey Drak! I'm talking about modding stuff for CoM 🙂
Keldath helped me out with some dll code that should do this: When loosing a capital there's a little anarchy and the new capital is chosen from the largest cities and preferably one with a Summer Palace or Versailles (or some other with a government centre).
 
Ah! ok, mis-read your post then.. My bad.
 
Ah! ok, mis-read your post then.. My bad.
I admit that it's quite misleading to talk about modding of a different mod in a thread. :blush:

@keldath
I think we should move over to my CoM thread.
 
Back
Top Bottom