An Idiots Guide to Editing the DLL

Brilliant stuff, Xienwolf! :goodjob: You're bringing back my motivation to get into modding again. I haven't read all of your writings yet, except for all the filler posts at the bottom. ;)
 
I LOVE YOU!!!!!!

Oh man, thios is what I have been waiting for! Holy crap!!!! :goodjob:

Just one suggestions
could you possibly add 'common functions' that are called a lot? For example, functions that deal with how many Civs there are, or the status of a Civ as a vassal or a master...etc
 
I would suggest some info like "Where can you find What?". While it seems obvious that CvUnit.cpp is where you can deal with units it is not always the case. Also how a CvXXXXAI.cpp will differ from a CvXXXX.cpp. Some general situations like when should expose my custom code to python and when I shouldn't bother. How should I deal with a selection set and what I should watch out for when doing so (a major point of infinite loops and CTDs in many mods).

I won't ask for a whole map for the SDK files and what each does. This would be too much and I am sure your too busy to even start thinking of such an endeavor. Also I don't expect you to have already played with every single file there because simply no modders has ever needed to do so. Just a simple road map to commonly and frequently treaded paths through files for the clueless.
 
Gooblah: It would be a bit tricky to decide precistly what are commonly called functions. Those which you can safely say are common are easily found and copy/pasted when needed. The rest... Well the main goal is that by the end of these tutorials someone is comfortable enough in the DLL that they understand how to find such things (go to the header file and search for the data type you are seeking to work with usually)

Kalimakhus: Kinda the same response as Gooblah got in the end: The hope is that by the time I am done writing all of these, someone is familiar enough that they can find whatever they need. There are numerous exceptions and unexpected twists which could take up far more space than I reserved for myself to cover completely, and will in many cases be so specialized in scope that the one piece you need is buried among a thousand pieces you don't need and so you'll not find it. I do intend to choose challenging examples which force me to spread throughout the code so that I can point out as much as possible, but in a context which makes it relevant.

As for when to expose to python: Make a callback when you MUST do so, but everything else you should ALWAYS expose, it doesn't cost you any processor time, barely affects the size of the DLL, and saves you a headache in the future when you decide you need to access some variable from python.

Selectionset... not sure what you are talking about there actually.

You are right about the not much time though :) Unfortunately it may be another month until I can finish writing the boolean I am in the middle of, let alone start up on the INTs.
 
Gooblah: It would be a bit tricky to decide precistly what are commonly called functions. Those which you can safely say are common are easily found and copy/pasted when needed. The rest... Well the main goal is that by the end of these tutorials someone is comfortable enough in the DLL that they understand how to find such things (go to the header file and search for the data type you are seeking to work with usually)

Gotcha, that makes sense. My main trouble right now is attempting to right for loops; when you refer to a Civ, does that mean the Civ whose turn it is RIGHT NOW, or is it the human? A specific number? :confused:
 
You can't actually tell whose turn it is right now very easily. You can loop over all the players and check if their turn is active, but most likely you are talking about getActivePlayer, which always means the person behind the keyboard. That is most certainly something which I should mention somewhere early on, and then repeatedly after.


Otherwise, in the SDK you generally don't refer to a specific Civ (well, except for the Barbarians), that's hardcoding :) You would refer to a player or a team which have certain attributes, and it will just so happen that in your mod, only one specific Civ has those attributes.
 
When I talked about "Where to find What" I meant things that worth mentioning and are found somewhat in an unexpected place. Anyway, I think your plan will end up covering most if not all the points a beginner modder will need. By the time a modder is ready to go into unexplored areas of code he will be familiar enough with the DLL that he can find his way on his own.

Selection Set.. I meant the times when you need to loop through the units on some plot and do something to all, or some of them. In many mods this is a place where problems tend to arise. They are usually hard to discover because the code seems quite innocent. What usually happens is that while looping through the (selection set) some of the units attributes may change or some units may actually become unavailable (moved, killed, or replaced).. This how many infinite loops and null pointers access violations come from. What I am asking you to do is to explain through examples some of the common mistakes in this area. My guess is that FfF and FF work extensively with such situations where the existence of unit X may give units of type y the z promotion if illegible or casting some spell will affect some units but not others based on some attributes or the fact that the units have moved for this turn or not etc.

Anyway, it may not be the time for asking for specific things. It is better to let you go on with your plan then if a point that is worth asking for is need one may ask you about it.
 
I think I see now what type of issues you mean with the selection set. Actually not something I have done much with so far for precisely that reason. Usually the best way to avoid the issues is to come at things from another angle in my experience.
 
I am using the newest FF core DLL.
Could anyone point me to what dll handles terain improvement.
Esentialy, I want to check if unit A is standing on improvement B. For example:
If(Mage is on Farm)

Where can I find a function that returns the improvement on a certain location?
 
I guess the idiot's guide is a better place for me than the modder's guides to FF. I just noticed any changes I do to the sourcecode(FF) breaks the ability to build a dll. Commenting out a line and undoing it again results in failure to build.

This is just mad:crazyeye: any idea what I might do wrong? The strange thing is I compiled a lot of dlls in the past without problems altering quite a bit of code...

Edit: nevermind I don't experience problems using FFH code just FF gives me all sorts of problems, guess I'll just wait until you provide the full sources
 
Actually either thread would work, I just happened to check this one first that time around. My answer would be rather different in the other thread than it would be here though :) Almost didn't realize that it was the same question from the same person actually :)
 
Actually either thread would work, I just happened to check this one first that time around. My answer would be rather different in the other thread than it would be here though :) Almost didn't realize that it was the same question from the same person actually :)

It's the same person but actually not the same question:p
But nevermind I'm happily editing FFH sourcecode now. Just FF resisted every attempt to alter it therefore I'll grab what I need from there later.;)
 
I just realized I still have the full source from before last patch uploaded on the first patch of the modder's guide, so if you downloaded that it should all work and have almost everything that is current anyway.

If the patchL download contains the full source - well that's where all the trouble started. I will redownload it later and try again just to make sure.
 
:wow: what work :goodjob:.


I have a question, because i can't find it somewhere, and the pro is here :D:
Is it possible, to add a new function to the CvEventManager.py?

I've tried to add
PHP:
virtual void setTerrainType(CvPlot *pPlot, TerrainTypes eNewValue, bool bRecalculate,  bool bRebuildGraphics) = 0;

to CvDLLEventReporterIFaceBase.h (in the last line), and

PHP:
gDLL->getEventReporterIFace()->setTerrainType(this, eNewValue, bRecalculate, bRebuildGraphics);

in CvPlot.cpp in the void CvPlot::setTerrainType(TerrainTypes eNewValue, bool bRecalculate, bool bRebuildGraphics) function.

I've also modified the CvEventManager.py.
The dll is compiled, but the game crashes when initialising the map.

Can it be done, or is it not possible?
Or am i just stupid?
 
Top Bottom