Conditional text for Info objects

Leoreth

Bofurin
Retired Moderator
Joined
Aug 23, 2009
Messages
38,050
Location
風鈴高等学校
My mod represents Christianity as three religions: Orthodox Christianity, Catholicism and Protestantism. The way it is supposed to go is: Orthodoxy is founded with Theology as normal, and later in the game the other two denominations branch off following special events (great schism and reformation).

The awkward thing about this is that when Christianity is still united (before Catholicism enters the picture) it is still displayed as Orthodoxy in the game, and the same applies to its buildings and units. I would prefer if Orthodoxy would simply be displayed as Christianity before other Christian religions exist, with the same applying to its associated units and buildings, while keeping the art and effects the same.

I wonder if there is a convenient way to make the text (description, help ...) conditional on some aspect of the game state (in this case, which religions have already been founded). I have looked into the corresponding methods in the CvInfoBase class that are inherited by the other Info classes.

In principle I am willing to do some dirty hacks in those methods (i.e. check if religion exists and then do text key substitution with simple hardcoded if clauses), but I think editing CvInfoBase is excessive. Unfortunately, overriding the methods in the correct subclasses (CvReligionInfos, CvBuildingInfos, CvUnitInfos) does not seem to work (as in, overriding methods do not seem to be called). It appears that this is because of object slicing, but I am not fluent enough in C++ to be sure of that.

I'm hesitant to edit CvInfoBase itself because then those additional checks would affect all Info classes, which seems excessive.

Is there any other way that allows me to make e.g. religion names conditional (or change them over the course of the game) without having to edit the game code in too many places (i.e. everywhere those strings are displayed)?

I am aware that I could create a fourth religion to represent unified Christianity, but that would mean extra buildings and units and a lot of extra work to handle the resulting special cases and making this workaround opaque to the player.

All ideas welcome, I hope I have made my problem sufficiently clear.
 
Sounds like what dynamic civ names are doing.
Expose a function to update civ name in python.
Upon events, update civ names.
All functions to get civ names will then retrieve updated names.

In this case, it is religions.
 
Yeah, but in the DLL player instances and their attributes are already persisted. Info classes are simply initialized from XML every time the game is launched, after which their attributes remain constant. In other words, even if I would expose a setter for such an attribute, the new value would not be persisted.

Conversely, it is not feasible to add persistence to Info classes because that would blow up save game sizes. I expect to run into the same problem as for hardcoded changes: I cannot override the subclasses because of object slicing, and making that change for the base class would mean everything would also write its text content into the save files.
 
Back
Top Bottom