FfH2: Source Code

MrUnderhill said:
Software Development Kit.

Basically, it's the C++ code that makes up Civ4 (and FfH, by association).

It's not all of the code, its not the code for the .exe file, which includes the game engine etc.

This source code is for the game rules, you could say.
 
The Source code has been updated to the 0.16f code. If you have already begun modifying your code based on the 0.16c just look in the SDKChangelog.cpp file that is included and manually add the post 0.16c changes to your code to catch up (there are three of them).
 
I'll be uploading the patch "g" version of the source tomorrow.
 
Okay a new version is uploaded with all of the changes from patch "g". It is linked in the first post.
 
Hey folks,
I have been perusing the code, looking for where Mercenaries get the Weapons promotion, I found the Py code that actually applies the promotion, but I can't seem to find where it dictates that only the Mercs get that promotion. I looked over the Unit, Promotions and looked through the SDK changelog, but no luck... I may just not know what I am looking for... I see in the Py where it disallows certain unitclasses from gaining the promotion, but its seemingly limited list...
Anyway, can anyone point me in the proper direction?

Cheers!
 
Hey folks,
I have been perusing the code, looking for where Mercenaries get the Weapons promotion, I found the Py code that actually applies the promotion, but I can't seem to find where it dictates that only the Mercs get that promotion. I looked over the Unit, Promotions and looked through the SDK changelog, but no luck... I may just not know what I am looking for... I see in the Py where it disallows certain unitclasses from gaining the promotion, but its seemingly limited list...
Anyway, can anyone point me in the proper direction?

Cheers!

This is from the onBeginPlayerTurn in CvEventManager.py:

Code:
			if pPlot.isCity():
				if pUnit.getUnitClassType() == iMercenary:
					bUpgrade = True
				if (pUnit.getUnitCombatType() == iMelee and pPlayer.getCivilizationType() == iDoviello):
					bUpgrade = True
				if bUpgrade == True:
					pCity = pPlot.getPlotCity()
					if pCity.getOwner() == pUnit.getOwner():
						cf.FFHSetWeapons(pUnit, pCity)
 
I really don't know how I missed that! Thanks Kael!

Cheers!
 
I was following the instructions on how to get your source to compile using Code::blocks and the MSVC Toolkit.

It was refusing to link at the final step, giving an error something like "Missing symbol CyMessageControl2::sendDoCommand()". Anyway I noticed that in the final build the file 'CyMessageControl2.cpp' was missing from the project files list. So I added it to the project and the build completed fine (menu "Project -> Add Files").

Not sure I have the latest copy of the source (most recent modified date was Nov.19), but in case someone else has the same problem I thought I'd mention it.

I'll try re-downloading the source when I get on my home.
 
Hi,

following Kael's method to compile the SDK, I get the following errors in codeblocks:
Code:
:: === CvGameCoreDLL, Final Release ===
CvDLLPython.obj:: error LNK2019: unresolved external symbol "public: __thiscall CyMessageControl2::CyMessageControl2(void)" (??0CyMessageControl2@@QAE@XZ) referenced in function "public: __thiscall boost::python::objects::value_holder<class CyMessageControl2>::value_holder<class CyMessageControl2>(struct _object *)" (??0?$value_holder@VCyMessageControl2@@@objects@python@boost@@QAE@PAU_object@@@Z)
CvDLLPython.obj:: error LNK2019: unresolved external symbol "public: void __thiscall CyMessageControl2::sendDoCommand(int,int,int,int,bool)" (?sendDoCommand@CyMessageControl2@@QAEXHHHH_N@Z) referenced in function "void __cdecl DLLPublishToPython(void)" (?DLLPublishToPython@@YAXXZ)
..\Assets\CvGameCoreDLL.dll:: fatal error LNK1120: 2 unresolved externals
:: === Build finished: 3 errors, 0 warnings ===
The DLL IS created though, and the game starts and seems to be running fine. Can I ignored those error messages?
 
Bringa - Do you have a copy of the DLL located inside of one of your declared Library paths?
 
I don't think so. Should I?
 
I would think not - but the Assets\CvGameCoreDLL.dll makes me think that it might be there - or that it is trying to link it to itself somehow. Do a search of ALL files from within Code Blocks for "CvGameCoreDLL" and see if any of the include statements list it.

My guess --- and I am by no means even slightly knowledgeable about this stuff --- is that it is trying to link the DLL file to itself, recognizes that it shouldn't do this, aborts the attempt, and goes on its merry way .. and that in the end it doesn't affect anything, but would be nice to get rid of the errors.
 
Alright! If the errors ever annoy me I'll have a look at that. For now I'll just ignore them ;)

Hey, if you feel like it, why don't you post your new fireball code on the wiki? I'd like to give it a try!
 
I will post the code - and an explanation of everything that is needed to implement it, but there are two more changes I want to make to it. (one is the change in the autoexplore option governing the fireball, and the other is a slight modification of the attack behavior to test a hypothesis I have).
 
I'm just curious...
When you find the source (for the code) do you have to make a decision, the fundamental one about existance? The continuation of the human species or the love of your life?

Cause I'm just thinkin - whoa..
-Qes
 
Hi,

following Kael's method to compile the SDK, I get the following errors in codeblocks:
Code:
:: === CvGameCoreDLL, Final Release ===
CvDLLPython.obj:: error LNK2019: unresolved external symbol "public: __thiscall CyMessageControl2::CyMessageControl2(void)" (??0CyMessageControl2@@QAE@XZ) referenced in function "public: __thiscall boost::python::objects::value_holder<class CyMessageControl2>::value_holder<class CyMessageControl2>(struct _object *)" (??0?$value_holder@VCyMessageControl2@@@objects@python@boost@@QAE@PAU_object@@@Z)
CvDLLPython.obj:: error LNK2019: unresolved external symbol "public: void __thiscall CyMessageControl2::sendDoCommand(int,int,int,int,bool)" (?sendDoCommand@CyMessageControl2@@QAEXHHHH_N@Z) referenced in function "void __cdecl DLLPublishToPython(void)" (?DLLPublishToPython@@YAXXZ)
..\Assets\CvGameCoreDLL.dll:: fatal error LNK1120: 2 unresolved externals
:: === Build finished: 3 errors, 0 warnings ===
The DLL IS created though, and the game starts and seems to be running fine. Can I ignored those error messages?

Unfortunately, this has become a problem. I don't know where that first DLL came from, but it's not creating the DLL anymore.

My Search Directories for the linker are:
Boost-1.32.0\libs\
Python24\libs

There's definitely no CvGameCore.dll in them. Can anyone make a guess as to where this error is coming from? I followed Kael's instruction on installing and compiling the SDK to the letter, and on a first build run I got a .dll as well (which worked).

Maybe I've got my project in a bad place? I've got it here:

c:\program files\Firaxis\Sid Meier's Civilization 4\Mods\Fall From Heaven 2 016\source\CvGameCoreDLL\

I thought it shouldn't matter where I put my stuff. Anyhoo, above-mentioned errors still appear in the Build Messages, and this is the end of my Build log:

Code:
Linking dynamic library: ..\Assets\CvGameCoreDLL.dll
   Creating library ..\Assets\CvGameCoreDLL.lib and object ..\Assets\CvGameCoreDLL.exp
CvDLLPython.obj : error LNK2019: unresolved external symbol "public: __thiscall CyMessageControl2::CyMessageControl2(void)" (??0CyMessageControl2@@QAE@XZ) referenced in function "public: __thiscall boost::python::objects::value_holder<class CyMessageControl2>::value_holder<class CyMessageControl2>(struct _object *)" (??0?$value_holder@VCyMessageControl2@@@objects@python@boost@@QAE@PAU_object@@@Z)
CvDLLPython.obj : error LNK2019: unresolved external symbol "public: void __thiscall CyMessageControl2::sendDoCommand(int,int,int,int,bool)" (?sendDoCommand@CyMessageControl2@@QAEXHHHH_N@Z) referenced in function "void __cdecl DLLPublishToPython(void)" (?DLLPublishToPython@@YAXXZ)
..\Assets\CvGameCoreDLL.dll : fatal error LNK1120: 2 unresolved externals
Process terminated with status 1120 (9 minutes, 50 seconds)
3 errors, 0 warnings

I'm really C++ illiterate, and I've never used a programming language that had to be compiled much, so I'm pretty much lost here. I guess I will eventually go and google around a little, but I'm hoping someone who's more at home with C++ than me can have a look at this and tell me what could be going on.

Thanks!
 
There is a CyMessageControl2.cpp file in the source code directory. Try adding it to the project if it isn't already in.
 
Okay, that solved it! Strange that it wasn't in the project to begin with...

It's creating a DLL now that's 4,884KB big. Does that sound about right? The one that shipped with FFH2 is 3,704KB.

Wee! It works ;) I've got a log :D No longer weighing blindly... let's see what iValues the AI runs through in BestTech now. This should make weighing a lot more effective. Thanks for the help Kael!

(I'm enjoying myself way too much with the AI; I really hope that once we have a set of changes that work others will enjoy this only half as much as I am right now ;P I almost lost a game on Prince last night! It's incredible what a little pushing in the right direction can do for the AI :D)
 
I wee'd too early. I'm really spoiled by high level languages. Something as simple as putting a message that says "I'm now considering Agriculture" into my log turned out to be too much for me.

So, this is what I want to do: in the beginning of the loop of bestTech, I want to log what tech is currently being considered. This is where the trouble started. There is no getter for getting the tech's name. Instead of writing that, I decided to go with the tech's quote, which should make it perfectly obvious what tech the AI is looking at as well. So merrily I went about logging the current tech's getQuote... when I ran into a problem of converting from one char type to another.

ONE CHAR TYPE TO ANOTHER? What the hell is wrong with C++!

Anyhoo, I googled, and I've read things for hours, and my brain hurts and I can't figure this out, so I thought I'd ask for help again (maybe someone other than Kael? I would hate to take away time from Fire's completion).

This is my error:

CvPlayerAI.cpp:2072: error C2664: 'CvDLLUtilityIFaceBase::logMsg' : cannot convert parameter 2 from 'const wchar *' to 'const TCHAR *'
:: === Build finished: 1 errors, 0 warnings ===

Now I've googled, and I've found out that TCHAR is MS's magical way of saying "char if it's not a unicode environment, wchar_t if it is". (Right so far? :/) I'm really not sure what logMsg does expect. A simple ascii string would make most sense, of course. I've tried a LOT of things until I've at least found one way to get it to compile:

Code:
char temp;
temp = CHAR(GC.getTechInfo((TechTypes)iI).getQuote());
gDLL->logMsg("mylog.log", &temp);

However, this ends me up with broken characters in my log, so straight CHAR conversion doesn't seem to work.

Can someone tell me off the top of their head what the conversion I'm looking for is? I've wrestled with wcstombs, but it's stronger than me. And probably not what I'm looking for anyway. Help?
 
Back
Top Bottom