[MOD] Colonization: 2071

Well, I can see this being a big change for 2071. I have added tons of new XML tags in CvInfos so nearly every changed XML file in M:C will need to be merged into 2071. The GlobaldefinesAlt in M:C has many additions and if not in 2071 will cause all kinds of errors. This would take a whole lot of work I bet. I am thinking it would be easier to merge 2071's graphics into M:C. Any building or unit classes mentioned in the GlobalDefineAlt will need 2071 equivilants or removed from the DLL. Once the graphics are changed and working bug free then you could start to mod in 2071 features.
 
I am thinking it would be easier to merge 2071's graphics into M:C.

I would also really suggest you guys try it that way. :thumbsup:
(It is probably a lot easier and much less prone to errors.)

If orlanth wants to create a new Colonization:2071 the best way to do it, would be to take an existing mod and rebuild that step by step.
(It is basically the normal way of creating a Total Conversion.)

There is no doubt, that that would be a lot of work.
But anything else will most likely simply be a waste of time. :dunno:
 
I would also really suggest you guys try it that way. :thumbsup:
(It is probably a lot easier and much less prone to errors.)

If orlanth wants to create a new Colonization:2071 the best way to do it, would be to take an existing mod and rebuild that step by step.
(It is basically the normal way of creating a Total Conversion.)

There is no doubt, that that would be a lot of work.
But anything else will most likely simply be a waste of time. :dunno:

Yep, the more I think about it the more this would be a necessity. M:C's core game changes are just so extensive, even more so than the Inventor Mod that 2071 is based on. I don't think Nightinggale realizes just how extensive it is. You know what's scary, 2071 isn't that far away :) just 58 short years, heck I may still be alive. So, if there is a remake made I'd suggest calling it 2171 :scan:
 
copied your makefile into it, and included the bin folder inside it with fastdep and jom. I copied a project file to the directory using the one in the makefile link in your sig, opened it in Express 2010, and added the DLL files to the project; but when I try to Build it can't find boost or python and has a fatal error. (Where would I get these? they're not in the DLL_Sources folder & the modiki page doesn't mention where to find them, just that they're there..:confused:) sorry it's been years since I managed to compile a DLL and think I was using 2008 at the time! :crazyeye:
The makefile already committed to git is version 2.2, which is better suited for the task than 2.0 found in my signature.

The idea is that you get the source and you should be able to compile right away. Ok you should add jom.exe to compile fast. Also you should add the stuff to Makefile.settings that I wrote to be able to compile 2071 specific stuff, which currently is just different yields. However you shouldn't need to do anything except to open the project and compile if you want an M:C dll and you don't want to use a fast target.

The idea is that if you compile a 2071 DLL, you copy the DLL into 2071. This is why it will be way easier if you add YOURMOD to Makefile.settings with a path to 2071. That way it will automatically copy the DLL into 2071 once it's done compiling.

The XML files in the github branch are the standard M:C ones, do you think the 2071 XML should go there?
Well, I can see this being a big change for 2071. I have added tons of new XML tags in CvInfos so nearly every changed XML file in M:C will need to be merged into 2071.
Yeah it's likely better to start over. That way it is possible to change something and test it right away. Once it works it will be ready to commit (providing the 2071 is added to git) and then change the next thing.

It will also be the best way to get rid of 2071 specific bugs.

What I haven't figured out is how to add the files to git. Maybe it would be best to make a new git project for them. If we change them in the branch, then it will overwrite/merge the M:C files when the branch is merged back info the master branch. I think we should merge them as it reduces the work for keeping 2071 up to date with new features.

Maybe we should try out the fork function on github. One button to make a complete copy of of all files (with history?). That way it can be checked out into MODS and you can check out and commit from the same files as the game reads.

Oh and install a proper git client http://code.google.com/p/tortoisegit/


YI don't think Nightinggale realizes just how extensive it is.
I think I do now. Adding the 2071 XML files one at a time might be less tricky. I still have the script to add default lines into XML. That may come in good use if we add one 2071 XML file and then need to add the M:C specific lines into it.

You know what's scary, 2071 isn't that far away :) just 58 short years, heck I may still be alive. So, if there is a remake made I'd suggest calling it 2171 :scan:
The same can be said about years like 1984 and 2001. I read a Donald Duck story from 1971 where he was sent 30 years into the future. That revealed the colonies on the moon and Mars and stuff like that :lol:
In reality most stuff is older than we think. Steam still powers the world (electricity) and we use binary systems. The math for those was founded in the 17th century and refined in the 19th century. Storing binary data was patented in 1801 (punchcards) and used by the industry right away to store weaving patterns. 50 Years later the looms were pulled by steam and worked on their own, still with programmable patterns. Just add thread and start it and it would work until it ran out of thread at super human speed. The change from that to today is the individual electric engine on each loom and today they are faster at the price of lower quality. It's not like a lot happened in the last 150 years.

We imagine all sorts of stuff from the future, some with more accuracy than others. I once found this video of predictions :lol:
 
Yeah I agree, with so many DLL changes in M:C it's likely not possible to get existing 2071 xml to work with it out of the box. It may be best to make a DLL branch or fork that's largely based on M:C with a few MC-specific features omitted, then start gradually rebuilding XML content using that as a base. I guess this is a blessing in disguise; the actual XML game content of the mod should be thought out and totally redesigned to take advantage of the many new features and options present in M:C DLL. (It'll take quite a long while to gradually build this xml, but hopefully be done by 2070 in time for those fancy new propeller-car monorails in nightingale's vid! :scan::p) The graphics won't affect the DLL and XML content itself, so many could be placeholders with appearance finalized last.

Nightingale's idea of trying to have a somewhat modular DLL code base is a good one if it can be done - ie use "ifdef Col2071" in a few sections where exceptions to the base M:C code is needed. If the need for this can be kept to only a few sections, it could enable easy updates or merges when needed and also greatly help out anyone else who might want to use this DLL as a base for modding.

Looking over the M:C XML it seems most of the new features (techs, promotions, Animals, etc) are good generalizable ones designed with moddability in mind, so I'm hoping it may be possible to use much of it with only a few changes. Even things like Papal Censures I'm hoping I could use for the Earth tyrants :scan: , as long as most features are exposed to XML rather than unique hardcoded tags they should be good for modding. I guess I'm not familiar with what's hardcoded and where, Kailric do you have any ideas of what especially to keep aware of?

The new combat system features with glancing blows etc are really good and have great generalizable use for modding, but the specific hardcoding as PLATE_ARMOR, MAIL, etc is what makes it hard for other mods. The proposal to expose these features to xml where possible (ie <glancingblowchance> in promotionsinfos) is a good one that would make these awesome for modding.
 
Nightingale's idea of trying to have a somewhat modular DLL code base is a good one if it can be done - ie use "ifdef Col2071" in a few sections where exceptions to the base M:C code is needed. If the need for this can be kept to only a few sections, it could enable easy updates or merges when needed and also greatly help out anyone else who might want to use this DLL as a base for modding.
It's actually a fairly common approach in open source programming except it's done to support multiple OSes. Download the source from some game or app, which supports a great number of platforms. Chances are that there is a directory called OS with windows.cpp, unix.cpp, macosx.cpp etc. and the compiler will compile ONE of them. Each off them then has the same function names meaning the rest of the code can call "draw this on the screen" without considering which platform it's on and those specialized files will make sure it happens.

We want to do the opposite, which is to make two "applications" for a single OS. However that approach has proven reliable and we should see if we can use it.

I came up with this approach. We make Yields.h and move all yield related into it (may need Yield.cpp too)
static inline bool YieldIsMetalArmor(YieldTypes eYield)
{
return eYield == YIELD_SCALE_ARMOR || eYield == YIELD_MAIL_ARMOR || eYield == YIELD_PLATE_ARMOR;​
}

static inline bool YieldIsArmor(YieldTypes eYield)
{
return eEquipment == YIELD_LEATHER_ARMOR || YieldIsMetalArmor(eYield);​
}

This mean we get the same result (even same speed) if we write this in the code
if (YieldIsArmor(eEquipment))
if (eEquipment == YIELD_LEATHER_ARMOR || eEquipment == YIELD_SCALE_ARMOR || eEquipment == YIELD_MAIL_ARMOR || eEquipment == YIELD_PLATE_ARMOR)
if (YieldIsMetalArmor(eEquipment))
if (eEquipment == YIELD_SCALE_ARMOR || eEquipment == YIELD_MAIL_ARMOR || eEquipment == YIELD_PLATE_ARMOR)

Now we define that is armor in a single location meaning adding more will be easier. Also we eliminated the risk that one of the checks forgets to check for YIELD_PLATE_ARMOR.
Another important factor here is that 2071 could have different functions for the check. Say we don't want to use the code for metal armors we can just write
static inline bool YieldIsMetalArmor(YieldTypes eYield)
{
return false;​
}
With a few well defined function checks for yield group we should be able to remove the majority of hardcoded yields from the general code. We can then define whatever we like for 2071.

A few yields will still stay hardcoded, such as YIELD_FOOD. That's not a major concern as those special functions are likely needed for both MODS. Luxury food might be an issue, but I think that's the only one, which might be an issue.

The new combat system features with glancing blows etc are really good and have great generalizable use for modding, but the specific hardcoding as PLATE_ARMOR, MAIL, etc is what makes it hard for other mods. The proposal to expose these features to xml where possible (ie <glancingblowchance> in promotionsinfos) is a good one that would make these awesome for modding.
Ideally we define everything in XML. If we don't, then we should change the code to do so. If speed force us to hardcode something, then we should do as I just wrote about with yields.

The question now is how to proceed now? Should we make a fork on github to provide XML/python files for 2071 to work on? Such a fork shouldn't bother with the DLL code as it should use M:C DLLs, including the M:C DLL updates. This mean working on col2071 means cloning "Colonization_2071" (or whatever we call the project) into MODS, play with that one, edit XML and commit those, but ignore the source code there. The source code comes from M:C meaning you will also have to clone M:C, set Makefile.settings to compile for 2071 and set YOURMOD to the path to MODS/Col2071 (or whatever it ends up being named). That way you open VC++ in M:C, compile and the DLL ends up inside col2071, ready for you to play with.

Now that I think about it, we don't have to fork anything. I already did that. I made a branch called colonization2071. Now we aren't going to modify the source like originally planned, which mean we don't need that branch. We might as well use it to keep track of col2071 XML files.

Now that I'm aware of at least two enums, which needs to be the same as XML I'm going to write some code to assert if XML doesn't live up to the DLL expectations. Also I will check if there are more like that. If we need XML and DLL to match, then at least check if that is the case instead of crash without any human readable error message.
 
Ok, I've been going through some git and github tutorials & think I'm finally getting the gist of it. (pun intended :p)

In looking further at M:C, it seems there's a lot of hardcoding of things like Luxury Food, Spice, Noble, Page, Knight, and individual Armors, as well as Castles & Monasteries etc. Do you still think it's feasible to use a modular DLL or would this start getting difficult? If needed, it may be simpler to try a single one-way fork off the current M:C DLL that comments out some M:C specific features for compatibility. This would come at the cost of being less easy to add any new features from M:C later, but I'd go for anything that makes it as simple & robust as possible while minimizing potential bugs.
 
Ok, I've been going through some git and github tutorials & think I'm finally getting the gist of it. (pun intended :p)
Oh man if I had that kind of documentation when I started with SVN. Back then I had never tried any version control system but was asked to get svn to get the source. I couldn't find a client and after hours of searching I finally found a beta source code. I then had to compile from source to get the command line client. No official builds and no real guides. While SVN might be easier to figure out than GIT, I say it should be easier to figure out today.

Another issue of unsupported and undocumented software. I noticed fastedep.exe isn't working in M:C anymore. After some research I learned that it's open source freeware, but it's from 2003 and the website is dead. No download link and no documentation. After searching some more I found a copy of the source code. I read that copy to figure out what arguments I should use to make it accept the new file layout in the new makefile. If only I have had a readme....
At least it appears to work locally for me now. I guess that mean we will have Makefile 2.3 soon.

In looking further at M:C, it seems there's a lot of hardcoding of things like Luxury Food, Spice, Noble, Page, Knight, and individual Armors, as well as Castles & Monasteries etc. Do you still think it's feasible to use a modular DLL or would this start getting difficult? If needed, it may be simpler to try a single one-way fork off the current M:C DLL that comments out some M:C specific features for compatibility. This would come at the cost of being less easy to add any new features from M:C later, but I'd go for anything that makes it as simple & robust as possible while minimizing potential bugs.
I think we should assume we can fix all issues and start the conversion. If it eventually turns out to be really hard to do, we can decide to make a fork for col2071. At the moment I think making a fork is the difficult choice. Sure it might be easier here and now, but then M:C gets a cool new feature and then we need to spend time moving it to a different source or col2071 will not gain access to it. In the long run it would be best to just solve the problems we encounter. M:C might even get better if we do it that way. Maybe not better gameplay, but easier to add new features as the code will end up being more modular. Right now it's a jigsaw of features mingled into each other and the low level of comments makes it really hard to read the code. Vanilla didn't provide a good code when it comes to this, but the modcomps certainly didn't help either.
 
I think we should assume we can fix all issues and start the conversion. If it eventually turns out to be really hard to do, we can decide to make a fork for col2071. At the moment I think making a fork is the difficult choice. Sure it might be easier here and now, but then M:C gets a cool new feature and then we need to spend time moving it to a different source or col2071 will not gain access to it. In the long run it would be best to just solve the problems we encounter. M:C might even get better if we do it that way. Maybe not better gameplay, but easier to add new features as the code will end up being more modular. Right now it's a jigsaw of features mingled into each other and the low level of comments makes it really hard to read the code. Vanilla didn't provide a good code when it comes to this, but the modcomps certainly didn't help either.

Ok, if you think it'll work I'm optimistic :king:
It'll help to plan for 2071 to reuse the existing M:C features as much as possible, to keep the # of needed changes or special cases down. It might be possible to have Armor types use the standard Multiple Professions per Building to avoid the need for additional hardcoded checks in CvCity.cpp . For special citytypes, an ifdef to let getCityType always return CITYTYPE_DEFAULT could make that modular.
 
Ok, if you think it'll work I'm optimistic :king:
I think the risk of failure isn't greatly affected by having a shared DLL source code.

For special citytypes, an ifdef to let getCityType always return CITYTYPE_DEFAULT could make that modular.
That's fully controlled from XML
ProfessionInfo said:
<iFoundCityType>CITYTYPE_MONASTERY</iFoundCityType>
Units without this tag will found normal cities. If you avoid using it at all, then even though the code may handle 3 types, the units will only be able to build one type.

I just finished and pushed checks for all enums vs XML (all 18 of them). Now we will know right away if one of them goes out of sync. In fact it did find one issue. DomainTypes had DOMAIN_AIR even though it isn't present in vanilla and not mentioned anywhere else in DLL or XML. It resulted in an incorrect count of domain types and I commented it out. I'm not sure if it affects anything, but now we know it will not produce a weird bug.

Tell me if you need to modify the XLM checks. It's a lot of code and I didn't bother writing it so I wrote a script. I give it the name of an enum and it looks up that enum in CvEnums.h and the it generates the whole check function automatically. It's designed to be really easy to make updates to the code if needed.

Code:
enum DllExport DomainTypes
{
	NO_DOMAIN = -1,

	DOMAIN_SEA,
	DOMAIN_LAND,
	DOMAIN_IMMOBILE,
	//DOMAIN_AIR, // why was this added without any mentioning in XML ???

#ifdef _USRDLL
	NUM_DOMAIN_TYPES
#endif
};
I noticed DOMAIN_IMMOBILE and I remember reading something about setting movements to 0 didn't work as intended. Now I know how it should be done :)
Well I have a guess to how it should be done.

Now I'm going to filter out yields and see if we can make it more mod friendly.
 
Great :cool: maybe it will be more achievable than I'd thought. If you're working with the Domains, do you think it'd be possible to include Space as a domain type, either by including Androrc's modcomp here or by repurposing DOMAIN_AIR?

Letting Space terrain have its own domain rather than using space=ocean allows for some planets to have Ocean and Coast terrains which isn't currently possible in the old version. (That would obviously be something using ifdef to not affect M:C, although the concept of the Ether was known to medieval philosophers :mischief:) The existing DOMAIN_IMMOBILE of M:C will be useful for this mod too; before I had to make a clumsy workaround requiring lots of XML for the Japanese AIs.

Here's a screenshot from Androrc's modcomp - as you can see there are some graphical artifacts in tiles where Coast terrain adjoins Space, but I'm thinking this can be dealt with by tweaking the Planets mapscript so Coast and Space are never adjacent (ie each planet which contains Ocean will have its outermost 2 tile circumference set either to all land or all ocean.)

Space%20Screenshot%202.png


I've made a Google Docs for the design document below that anyone can view. It's probably best to start thinking through design decisions, features, and balancing so would welcome any comments / suggestions / input from experienced modders & anyone who's played the mod! :scan:
https://docs.google.com/spreadsheet/ccc?key=0AgrARpL9eZDGdDh2Mm9INFlZMUd5bTVRaXRaSzlRVmc&usp=sharing
 
Great :cool: maybe it will be more achievable than I'd thought. If you're working with the Domains, do you think it'd be possible to include Space as a domain type, either by including Androrc's modcomp here or by repurposing DOMAIN_AIR?
DOMAIN_AIR is dead unless somebody enables it again. Adding the space domain might not be that hard. Maybe we can enable it in general and then let the M:C map scripts avoid making space. Whatever we do, I propose that we postpone this until later. Adding more domains has to be done in sync with XML changes and right now we have no 2071 XML changes. We should focus on other tasks first.

I've made a Google Docs for the design document below that anyone can view. It's probably best to start thinking through design decisions, features, and balancing so would welcome any comments / suggestions / input from experienced modders & anyone who's played the mod! :scan:
https://docs.google.com/spreadsheet/ccc?key=0AgrARpL9eZDGdDh2Mm9INFlZMUd5bTVRaXRaSzlRVmc&usp=sharing
Good idea. People come up with ideas to document how the game behaves, which is flawed as the game might behave differently tomorrow and the doc has to be constantly updated. This on the other hand is a document telling what should be changed in the code. It's very important to document such plans, specially if more people are involved in the process.

I didn't look into the details and can't comment on those. I just looked at the columns to see what kind of detailed the plan contain and all I can say is :goodjob:
 
I've started editing the XML files in the 2071 github branch to remove M:C specific XML content & create a blank framework for mod building. (I can tell getting even this far may take quite a bit of effort..)

I've made some progress, but on loading am getting some asserts for content like Nobleman and AI_Pedler which it says are triggered by xml/gameinfo/civ4forcecontrolinfos.xml . However I don't see any such file on github or in my mod folder :confused:

I'll try committing the XML edits to the 2071 github branch. (hopefully I've configured everything right & things go smoothly, if not feel free to roll it back!)
 
I've made some progress, but on loading am getting some asserts for content like Nobleman and AI_Pedler which it says are triggered by xml/gameinfo/civ4forcecontrolinfos.xml . However I don't see any such file on github or in my mod folder :confused:
Rule no 1 of modding. When the file is missing the game will use the vanilla one. Check your assets directory inside program files.

I'll try committing the XML edits to the 2071 github branch. (hopefully I've configured everything right & things go smoothly, if not feel free to roll it back!)
First of all work on the col2071 branch. Secondly pushing your changes to github needs not only an account (a free one will do), but also that I give write permission to your account.
 
pushing your changes to github needs not only an account (a free one will do), but also that I give write permission to your account.
That explains why I wasn't able to sync the commit. :crazyeye: I have a github account https://github.com/orlanth , with email Colonization2071 at gmail , so if you can add permission I'll try it again. (I'm using git plus the github for windows application configured to login with that account).

When the file is missing the game will use the vanilla one. Check your assets directory inside program files.
There is a xml/gameinfo/civ4forcecontrolinfos.xml in the vanilla game's assets directory, but it doesn't refer to any M:C XML like Nobleman or AI_Pedler - I'm not sure how that file works, but possibly the DLL interacts with it in some way that's causing it to expect hardcoded content with those tags, and asserts if it isn't there.
 
There is a xml/gameinfo/civ4forcecontrolinfos.xml in the vanilla game's assets directory, but it doesn't refer to any M:C XML like Nobleman or AI_Pedler - I'm not sure how that file works, but possibly the DLL interacts with it in some way that's causing it to expect hardcoded content with those tags, and asserts if it isn't there.
Just for the record you need Art, Sounds and Medieval2.FPK from the stable release of M:C for the git version to work. Git isn't suited for big files and we keep mainly text based files there, which is what git is best at handling.

Now that you have permission to commit (do remember to commit in the col2071 branch only!) you will be able to share the asserts and just maybe I can figure out what goes wrong.

However maybe the approach is wrong. Maybe you should add to the end of the XML files instead. Once you have the 2071 units in the game, you can start deleting M:C units and slowly remove everything, which can be removed easily. We will then end up with some hardcoded issues, but then we know what's hardcoded and needs a closer look.

It's also important to remember that M:C has become quite picky regarding XML perfection. The game could be playable even if it asserts when it starts. It just tells that something is wrong, like the time the Muslim missionary was overwritten. The game plays just fine, but the unit would never appear ingame, hence the reason I added asserts for that kind of XML error. Who knows for how long that unit was missing as it is only used by the AI. In a way asserts are AI bugreports :lol:
 
ok, committed to the col2071 branch. :king: looks like it went ok, hope I didn't break anything.. yet :mischief:

It's best to start from a clean slate and be able to know up front what hardcoded content its expecting - designing & adding all the new content will likely be a gradual process on the order of months, so I wouldn't want to end up dealing with a hodgepodge of mixed content from both, where it can get quite hard to know what content depends on having what other tags present somewhere else in the filesystem, and especially hard to remove stuff while keeping what you want and not disrupting hidden XML tag interdependencies. As long as we're aware of specifically what's hardcoded, much of that may be possible to design around by making XML content using those specific tags.

I added back XML placeholders for a few of the hardcoded content items (nobleman, pedler etc) mentioned in the initial asserts. There are still some asserts triggered by promotions the game is apparently looking for: PROMOTION_COLONIST :confused: PROMOTION_TRAINED, PROMOTION_UNTRAINED etc. It can now actually load to the main menu which it couldn't before, but then has a CTD - but I hadn't included the release Art, Sounds and Medieval2.FPK in my local copy yet so this may be it, I'll do that now.
 
I committed the first step in cleaning the code from hardcoded yields.

So far the code is free from
  • YIELD_SILVER
  • YIELD_FUR
  • YIELD_BARLEY
  • YIELD_GRAPES
  • YIELD_CLOTH
  • YIELD_COATS

Yields with one or two references left:
  • YIELD_SALT
  • YIELD_COTTON
  • YIELD_ORE
  • YIELD_ALE
  • YIELD_WINE

All I did was write two functions like my example with the armor, except I haven't touched armor yet. One place was a bit tricky so I wrote test code to loop though all yields and call the function. It then checked the return value. Nomatter what it changed, the sequence of numbers the test produce should stay the same and it did.

This made me think of my old post http://forums.civfanatics.com/showpost.php?p=12694279&postcount=737

Now we are getting functions, which are basically lookup tables and they are fixed at compiletime. I came up with the idea that since the method of getting the results aren't important, only the results. At boottime when the game check the yield enum against the yield XML, it could also loop though all yields and check the functions. All it should do is to assert all the yields where it should return true and then loop though all yields and count the number of true replies. That's actually fairly simple and such a check allows the freedom to be "careless" about the functions. We could do something like
Code:
return eEquipment >= YIELD_LEATHER_ARMOR && eEquipment <= YIELD_PLATE_ARMOR;
We skip checking for YIELD_SCALE_ARMOR and YIELD_MAIL_ARMOR because the order of yields implies they are true too. It cuts the number of checks in half, but it will break if something changes the order. However the check function will tell us if it broke meaning we don't have to fear that scenario.

So we saved two checks. Big deal... actually it is in some cases because the functions I wrote handles somewhat more than 4 yields. Also the functions are used exclusively by the AI, but it looks like the AI would like to call it many times. Properly written functions might actually make a difference, specially as they are inline functions, meaning they are inserted where they are called and the compiler might optimize it with the surrounding code. At least the chance for that happening increases when the check is simplified.

Looks like M:C is already benefitting from 2071 approaching :)

In case you haven't realized: if the yield is only mentioned in Yields.h, then we can remove it as that file will contain the #ifdef for 2071. In other words we can have any number of yields in each mod (not the same count) with the correct names as long as the functions exist for both mods.
 
great, thanks for all those efforts :cool: so the bottom line is it will eventually be possible to make Yield XML names however you want, and then specify them appropriately in an enum in a single place in DLL? That will indeed save lots of effort/confusion and vastly improve stability for modmodding.. Trying to reuse all the existing XML tagnames had initially seemed like a good strategy, but it got more & more confusing to keep track of as time went on (remembering to keep Uranium everywhere as Tobacco etc) and would be even more frustrating for anyone else trying to actually make sense of the XML :crazyeye: Anyway, bottom line is that any opportunity for standardization / modularity is most welcome for modmodding.

I synced another commit to the 2071 github branch:

1) cleaned eventtriggerinfos and diplomacyinfos from M:C-specific content

2) added XML placeholders for following asserted tags:
PROFESSION_HUNTSMAN
PROMOTION_ESCORT_GUARD
PROMOTION_BUILD_HOME
PROMOTION_TRAINED
PROMOTION_UNTRAINED
PROMOTION_COLONIST
Actually I'm hoping each of these could be adapted & used for 2071 content, avoiding the need to change M:C DLL for them. (I'm not sure what exact effect they have though that made them hardcoded in DLL in the first place, so would be important to clarify)

current remaining asserts on loading include:
TRADING_GUILDS
TRADING_TRADE_ROUTE_2
TRADING_TRADEPOST
FUEDALISM
BUILDINGCLASS_THE_FAIR

I guess we should also keep a list somewhere to track what placeholder content (UNIT_NOBLEMAN etc) has been added, to keep aware of specifically what content is required by hardcoding. After the above commit and adding the base mod graphics to my local copy, it now loads to the mainmenu with just the above 5 asserts and remains stable there :cool: though still CTDs on starting a game perhaps due to these asserts.

In making a new total conversion modmod from an existing mod, a lot of the initial work is actually cleaning/removing the mod-specific content from the original mod, and getting down to a base framework with solid stability that you can then incrementally add your new content to, making it easy at each step to determine the effects of each new item added. Once we've got to a standard "modding framework" version that can load and run stably with minimal M:C-specific XML content in place, it could be useful to save this branch as a standard base that anyone can use to start building their own new modmods on top of.
 
great, thanks for all those efforts :cool: so the bottom line is it will eventually be possible to make Yield XML names however you want, and then specify them appropriately in an enum in a single place in DLL? That will indeed save lots of effort/confusion and vastly improve stability for modmodding.. Trying to reuse all the existing XML tagnames had initially seemed like a good strategy, but it got more & more confusing to keep track of as time went on (remembering to keep Uranium everywhere as Tobacco etc) and would be even more frustrating for anyone else trying to actually make sense of the XML :crazyeye: Anyway, bottom line is that any opportunity for standardization / modularity is most welcome for modmodding.
We can't make the code clean from hardcoded yields. However we can trick it into thinking it is if we write the following code:
Yields.cpp said:
FAssertMsg(!strcmp(GC.getYieldInfo(YIELD_FOOD).getType(), "YIELD_NUTRIENTS"), CvString::format("XML error. Found %s instead of YIELD_NUTRIENTS at index %d", GC.getYieldInfo(YIELD_FOOD).getType(), YIELD_FOOD).c_str());
CyEnumsPythonInterface.cpp said:
.value("YIELD_NUTRIENTS", YIELD_FOOD)
The blue name is the enum hardcoded into C++, which we can't touch. The red name is the name for the same yield in XML. The green name is the name for the same yield in python. We aren't doomed due to hardcoded names. Needless to say all 3 are set to YIELD_FOOD right now, but there is no technical reason not to have 3 different names. We can do as we like.

Actually I'm hoping each of these could be adapted & used for 2071 content, avoiding the need to change M:C DLL for them. (I'm not sure what exact effect they have though that made them hardcoded in DLL in the first place, so would be important to clarify)
That is likely the easiest approach.

In making a new total conversion modmod from an existing mod, a lot of the initial work is actually cleaning/removing the mod-specific content from the original mod, and getting down to a base framework with solid stability that you can then incrementally add your new content to, making it easy at each step to determine the effects of each new item added. Once we've got to a standard "modding framework" version that can load and run stably with minimal M:C-specific XML content in place, it could be useful to save this branch as a standard base that anyone can use to start building their own new modmods on top of.
That could lead to some quite interesting results. Too bad we didn't do this in 2008. Who knows what kind of mods we would have today :drool:

I committed a check for the yield group functions. Setting the list of the content of a group is now strait forward.
Code:
void CheckYieldIsBonusResource::build()
{
	YieldVector.push_back(YIELD_SALT);
	YieldVector.push_back(YIELD_SILVER);
	YieldVector.push_back(YIELD_COTTON);
	YieldVector.push_back(YIELD_FUR);
	YieldVector.push_back(YIELD_BARLEY);
	YieldVector.push_back(YIELD_GRAPES);
	YieldVector.push_back(YIELD_ORE);
	YieldVector.push_back(YIELD_CLOTH);
	YieldVector.push_back(YIELD_COATS);
	YieldVector.push_back(YIELD_ALE);
	YieldVector.push_back(YIELD_WINE);
}
Naturally we can have multiple of each function using #ifdef. We are then free to code the function to get those yields just like we want and know that if it fails we will know. The actual function can then be something like:
Code:
return eYield & 1;
I don't know why we would want a group, which includes every second of the yields, but the check for it is extremely fast, yet extremely unreadable. I would never code anything like that if it's not tested often. Remember that adding just a single yield would break that function. Somehow I don't except the fast yield group checks to be a major speed improvement, but on the other hand not looping though equipment cost arrays when they were all 0 reduced the AI's time from 35 to 33 seconds in RaRE. Sometimes CPU time is spent in less obvious places.
 
Back
Top Bottom