• Our friends from AlphaCentauri2.info are in need of technical assistance. If you have experience with the LAMP stack and some hours to spare, please help them out and post here.

Quick Modding Questions Thread

I'm trying to do something like mentioned below for power plants, and I'm running into a few issues.

1) First and foremost is I have absolutely no clue where to put the <Building_ResourceCosts> row. It doesn't go in the schema sql but it's also nto working when I create a separate Building_ResourceCosts.xml either. Where should I be putting this?

2) I'm not sure how the power plants are labeled? I see most of the major buildings but I'm not seeing coal, oil, nuclear plants in he same obvious way I'm seeing other things

For reference I've barely done any of this on my own so far, the only thing I've done successfully is to alter a resource's carbon output, add/remove strategic resource requirements for units, and some basic global tweaks. Basically all I'm trying to do is re-balance some of the climate change stuff so that like, a battleship is burning like a fraction of what a power plant in a city is burning. (I tried just doing a decimal value for the units' resource requirements, but that didn't fly)

also if someone's come up with a fix for the issue mentioned at the bottom and anyone knows where that is I'd love to see that as well

This might be getting outside my current understanding but I have been playing around with the (seemingly unused) table Building_ResourceCosts from GS.
Here's the table from the expansion 2 schema for reference (thanks for pointing this out @LeeS !!) :
Spoiler :

CREATE TABLE "Building_ResourceCosts" (
"BuildingType" TEXT NOT NULL,
"ResourceType" TEXT NOT NULL,
"StartProductionCost" INTEGER NOT NULL,
"PerTurnMaintenanceCost" INTEGER NOT NULL,
PRIMARY KEY(BuildingType, ResourceType),
FOREIGN KEY (BuildingType) REFERENCES Buildings(BuildingType) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (ResourceType) REFERENCES Resources(ResourceType) ON DELETE CASCADE ON UPDATE CASCADE);

Supposing I wanted a factory to cost iron, or something, I might try to add a new row like this:
Spoiler :

<Building_ResourceCosts>
<Row>
<BuildingType>BUILDING_FACTORY</BuildingType>
<ResourceType>RESOURCE_IRON</ResourceType>
<StartProductionCost>1</StartProductionCost>
<PerTurnMaintenanceCost>1</PerTurnMaintenanceCost>
</Row>
</Building_ResourceCosts>

I have found that this does seem to actually function in the game (yay!); you need the required amount of resource to begin construction, it is properly deducted; the maintenance is also properly deducted. However, it does not show up anywhere as being used; in the strategic resource bar, it correctly decrements your resource income (albeit doesn't display that any is being consumed even though it is,) and you'll get the warning if your try to make the building without the resource:
View attachment 538050
However, on the unit card, it doesn't show that "requires" line about needing resources like units do. Example from a knight:

Is "hooking up" this table so it displays similar to how units work in the purview of the .dll and not something I can change? Or does this fall into UI territory? If it's inaccessible I'm happy to just throw the cost in the description and let it be.
 
1) First and foremost is I have absolutely no clue where to put the <Building_ResourceCosts> row. It doesn't go in the schema sql but it's also nto working when I create a separate Building_ResourceCosts.xml either. Where should I be putting this?
I have a functioning personal mod and my implementation is like so:
<Gamedata>
<Building_ResourceCosts>
<Row>
<BuildingType>BUILDING_STEELWORKS_JPH</BuildingType>
<ResourceType>RESOURCE_IRON</ResourceType>
<StartProductionCost>10</StartProductionCost>
<PerTurnMaintenanceCost>2</PerTurnMaintenanceCost>
</Row>
<Row>
<BuildingType>BUILDING_CHEMICAL_PLANT_JPH</BuildingType>
<ResourceType>RESOURCE_NITER</ResourceType>
<StartProductionCost>10</StartProductionCost>
<PerTurnMaintenanceCost>2</PerTurnMaintenanceCost>
</Row>
</Building_ResourceCosts>
</Gamedata>

In this example I am making 2 new buildings, the "Steelworks" and the "Chemical Plant" cost 10 resources to build and 2 per turn upkeep.

Powerplants function differently! They are defined in <Buildings> but their power generation is defined in <Buildings_XP2>, there's a "resource type converted to power" column that handles it.

The table is created already, it's just empty; so you are only adding new rows. I added the resource costs into the building's text descriptions as a lazy way around the UI display issues.
 
So what would be the syntax?

for units it's ResourceMaintenanceAmount where

<Row UnitType="UNIT_FIGHTER" ResourceCost="1" ResourceMaintenanceType="RESOURCE_OIL" ResourceMaintenanceAmount="1"/>

means a fighter burns 1 oil per turn

For power buildings I see:

<Row BuildingType="BUILDING_POWER_PLANT" ResourceTypeConvertedToPower="RESOURCE_URANIUM"/>

But no equivalent to "amount=1" that says how much it's burning per turn, nor how much power it generates. Right now I think this particular building 1 uranium per turn to create 16 power, I see neither of these values anywhere so I'm not sure what syntax to plug in. I'd like to be able to play with both how much resource it burns and how much power it generates. All the stuff referring to "maintenance" in buildings.xml is referring to gold maintenance I believe.

edit: I tried both
<Row BuildingType="BUILDING_POWER_PLANT" ResourceTypeConvertedToPower="RESOURCE_URANIUM" PerTurnMaintenanceCost="4"/>

and

<Row BuildingType="BUILDING_POWER_PLANT" ResourceTypeConvertedToPower="RESOURCE_URANIUM" ResourceMaintenanceAmount="4"/>

both crashed the game
 
Last edited:
Short question about cultures artdef, is there an updated reference somewhere with images for all cities (with eras) and Palace tags since GS ?
 
So what would be the syntax?
In my last post I included a functioning example or how to use the Building_ResourceCosts table. If you want a building to consume strategic resources, you have to use this table as an addition to the regular buildings table.
Each table has its own set of columns that control what kind of data can be added to that table. You can't use a column that doesn't exist in the table; so in your example, "ResourceMaintenanceAmount" isn't a column in the buildings table (it's in units_xp2) so the game doesn't know what to do with this.

In Building_ResourceCosts, the column for per turn consumption is PerTurnMaintenanceCost. It's probably wise to include StartProductionCost > 0, though, otherwise you'll be able to build buildings that consume a resource when you have zero of it.
But no equivalent to "amount=1" that says how much it's burning per turn, nor how much power it generates. Right now I think this particular building 1 uranium per turn to create 16 power,
Power plants don't burn a set amount of resources. They burn as much as is needed to supply any power loads in their radius. They can only consume resources in integer quantities; so If a nuke plant must supply 1-16 power, it'll burn 1 uranium; 17-32, 2 uranium; etc. If there's no power demand, or another plant is supplying it, they burn zero. There's no "idle" cost with power plants.

The actual power conversion rate is based on the resource being burned and that is set elsewhere.
So any building burning coal for power with always have the same conversion factor. There is a modifier you can use (it's one of Magnus governor promotions) which can increase the power generated per resource from a specific power plant, if you need something more granular (like a unique building or a policy card effect.)
 
Got it. Thanks, this is literally my first attempt at modding a Civ game lol.

Did you ever figure out the UI stuff? getting it to display the build/maintenance requirement at the production window and getting it to count strategic resource usage correctly at the top?


In my last post I included a functioning example or how to use the Building_ResourceCosts table. If you want a building to consume strategic resources, you have to use this table as an addition to the regular buildings table.
Each table has its own set of columns that control what kind of data can be added to that table. You can't use a column that doesn't exist in the table; so in your example, "ResourceMaintenanceAmount" isn't a column in the buildings table (it's in units_xp2) so the game doesn't know what to do with this.

In Building_ResourceCosts, the column for per turn consumption is PerTurnMaintenanceCost. It's probably wise to include StartProductionCost > 0, though, otherwise you'll be able to build buildings that consume a resource when you have zero of it.

Power plants don't burn a set amount of resources. They burn as much as is needed to supply any power loads in their radius. They can only consume resources in integer quantities; so If a nuke plant must supply 1-16 power, it'll burn 1 uranium; 17-32, 2 uranium; etc. If there's no power demand, or another plant is supplying it, they burn zero. There's no "idle" cost with power plants.

The actual power conversion rate is based on the resource being burned and that is set elsewhere.
So any building burning coal for power with always have the same conversion factor. There is a modifier you can use (it's one of Magnus governor promotions) which can increase the power generated per resource from a specific power plant, if you need something more granular (like a unique building or a policy card effect.)
 
Got it. Thanks, this is literally my first attempt at modding a Civ game lol.
You may find this resource by LeeS enormously useful, I know I did when i started:
https://www.dropbox.com/s/mx4h1unru1d94sc/CIVILIZATION 6 MODDING GUIDE.pdf?dl=0
It's a quick read and really covers the fundamentals.

For the UI part, you need to go beyond just XML/SQL, which kind of turned me off to it since I was just messing around for my own enjoyment. I don't think it would be that complex; the pieces are all there, you'd ultimately just be adding a new row to display and adding an extra variable into the equation that shows how much is being used. (It keeps track of it already, its just not displayed.)
 
Nice. Is that UI stuff in that guide? I'm surprised the buildings are this much of a pain, tweaking the resources was easy and messing with the units was seamlessly integrated into the game and the UI once I changed the numbers/resources. With just this extra resource maintenance on the power plants its doing weird stuff to the strategic resource numbers at the top (went from saying +12 to +-12)?

For the UI part, you need to go beyond just XML/SQL, which kind of turned me off to it since I was just messing around for my own enjoyment. I don't think it would be that complex; the pieces are all there, you'd ultimately just be adding a new row to display and adding an extra variable into the equation that shows how much is being used. (It keeps track of it already, its just not displayed.)
 
Is there a way via Lua to determine if a unit will be deterministically healing for its turn? Or has healed during the post-turn phase?

Also, and I believe I asked this last year, but there may be some new updates on it, is there any known way to modify the CO2 levels from Lua?
 
Not sure what you mean by "deterministically healing" but if you mean is there a direct provided method that is something like Unit:WillHeal() , then no there is no direct method provided for that.

There's no Unit:WasHealed() sort of thing either, but you can determine whether a unit has healed if you make an lua table recording all the damage-states of every unit, and then compare at the beginning of every player turn whether the Unit:GetDamage() value is less than it was when last saved into your lua table.

___________________________

So far as I am aware of all the "GameClimate.MethodSomething()" methods are "get" methods rather than "set" or "change" : you can read the values but not change them
Code:
local droughtChance :number = GameClimate.GetDroughtPercentChance();

local droughtIncrease	 :number = GameClimate.GetDroughtClimateIncreasedChance();

local nextIceLostTurns :number = GameClimate.GetNextIceLossTurns();
There are quite a few more similar "GameClimate" methods but as already mentioned they are all "read data" methods and not "set data" methods.
 
I am so sorry, but once again I have a minor issue I have no idea how to solve. It is so frustrating that every time I want to make changes to my mod I have to come here and ask for help.
Anyway, here's the mod: https://steamcommunity.com/sharedfiles/filedetails/?id=1660291558
All I've changed is a piece of text, "LOC_CITY_NAME_INCA_CITY_04" to be exact. I haven't messed up with any preferences, but the mod just doesn't want to work. I've changed some text in the base mod too, but it works. The problem is with this one.
 
As always: what's in Database.log ? What's in Modding.log ?
Here. I don't understand much of it, but it is like it fails to realize it needs to read from the mod files.
Spoiler Database.log :

[3362710.978] [Localization]: StartupErrorMessages.xml
[3362710.978] [Localization]: Input XML does not contain database entry tags. GameData, GameInfo or Database
[3362713.345] [Localization]: Validating Foreign Key Constraints...
[3362713.346] [Localization]: Passed Validation.
[3362713.355] [Configuration]: Validating Foreign Key Constraints...
[3362713.356] [Configuration]: Passed Validation.
[3362722.085] [FullTextSearch]: Initializing FullTextSearch
[3362722.550] [Gameplay]: Validating Foreign Key Constraints...
[3362722.561] [Gameplay]: Passed Validation.
[3362723.045] [Configuration]: Validating Foreign Key Constraints...
[3362723.045] [Configuration]: Passed Validation.
[3362724.382] [HallofFame]: Database found. Checking versions...
[3362724.383] [HallofFame]: Database is up-to-date!
[3362738.207] [FullTextSearch]: FTS - Creating Context
[3362760.511] [Configuration]: Validating Foreign Key Constraints...
[3362760.512] [Configuration]: Passed Validation.
[3362767.001] [Gameplay] ERROR: UNIQUE constraint failed: CivilizationLeaders.LeaderType, CivilizationLeaders.CivilizationType
[3362767.001] [Gameplay]: While executing - 'insert into CivilizationLeaders('CivilizationType', 'LeaderType', 'CapitalName') values (?, ?, ?);'
[3362767.001] [Gameplay]: In XMLSerializer while inserting row into table insert into CivilizationLeaders('CivilizationType', 'LeaderType', 'CapitalName') with values (CIVILIZATION_CANADA, LEADER_LAURIER, LOC_CITY_NAME_OTTAWA, ).
[3362767.001] [Gameplay]: In XMLSerializer while updating table CivilizationLeaders from file Expansion2_Civilizations_Major.xml.
[3362767.001] [Gameplay] ERROR: UNIQUE constraint failed: CivilizationLeaders.LeaderType, CivilizationLeaders.CivilizationType
[3362767.828] [Localization] ERROR: NOT NULL constraint failed: LocalizedText.Language
[3362767.828] [Localization]: While executing - 'insert into LocalizedText('Tag', 'Text') values (?, ?);'
[3362767.828] [Localization]: In XMLSerializer while inserting row into table insert into LocalizedText('Tag', 'Text') with values (TXT_KEY_CITY_NAME_POLAND_CITY_00, Варшава, ).
[3362767.828] [Localization]: In XMLSerializer while updating table LocalizedText from file PolandCityList.xml.
[3362767.828] [Localization] ERROR: NOT NULL constraint failed: LocalizedText.Language
[3362768.252] [Gameplay] ERROR: FOREIGN KEY constraint failed
[3362768.252] [Gameplay] ERROR: FOREIGN KEY constraint failed
[3362768.252] [Gameplay]: Validating Foreign Key Constraints...
[3362768.254] [Gameplay] ERROR: Invalid Reference on Buildings.TraitType - "TRAIT_CIVILIZATION_BUILDING_GRAND_BAZAAR" does not exist in Traits
[3362768.254] [Gameplay] ERROR: Invalid Reference on Buildings.TraitType - "TRAIT_CIVILIZATION_BUILDING_MARAE" does not exist in Traits
[3362768.254] [Gameplay] ERROR: Invalid Reference on Buildings.TraitType - "TRAIT_CIVILIZATION_BUILDING_THERMAL_BATH" does not exist in Traits
[3362768.257] [Gameplay] ERROR: Invalid Reference on Districts.TraitType - "TRAIT_CIVILIZATION_DISTRICT_COTHON" does not exist in Traits
[3362768.257] [Gameplay] ERROR: Invalid Reference on Districts.TraitType - "TRAIT_CIVILIZATION_DISTRICT_SUGUBA" does not exist in Traits
[3362768.260] [Gameplay] ERROR: Invalid Reference on Improvements.TraitType - "TRAIT_CIVILIZATION_IMPROVEMENT_OPEN_AIR_MUSEUM" does not exist in Traits
[3362768.260] [Gameplay] ERROR: Invalid Reference on Improvements.TraitType - "TRAIT_CIVILIZATION_IMPROVEMENT_ICE_HOCKEY_RINK" does not exist in Traits
[3362768.260] [Gameplay] ERROR: Invalid Reference on Improvements.TraitType - "TRAIT_CIVILIZATION_IMPROVEMENT_TERRACE_FARM" does not exist in Traits
[3362768.260] [Gameplay] ERROR: Invalid Reference on Improvements.TraitType - "TRAIT_CIVILIZATION_IMPROVEMENT_MAORI_PA" does not exist in Traits
[3362768.269] [Gameplay] ERROR: Invalid Reference on Units.TraitType - "TRAIT_CIVILIZATION_UNIT_CANADA_MOUNTIE" does not exist in Traits
[3362768.269] [Gameplay] ERROR: Invalid Reference on Units.TraitType - "TRAIT_CIVILIZATION_UNIT_HUNGARY_HUSZAR" does not exist in Traits
[3362768.269] [Gameplay] ERROR: Invalid Reference on Units.TraitType - "TRAIT_CIVILIZATION_UNIT_INCA_WARAKAQ" does not exist in Traits
[3362768.269] [Gameplay] ERROR: Invalid Reference on Units.TraitType - "TRAIT_CIVILIZATION_UNIT_MALI_MANDEKALU_CAVALRY" does not exist in Traits
[3362768.269] [Gameplay] ERROR: Invalid Reference on Units.TraitType - "TRAIT_CIVILIZATION_UNIT_MAORI_TOA" does not exist in Traits
[3362768.269] [Gameplay] ERROR: Invalid Reference on Units.TraitType - "TRAIT_CIVILIZATION_UNIT_OTTOMAN_BARBARY_CORSAIR" does not exist in Traits
[3362768.269] [Gameplay] ERROR: Invalid Reference on Units.TraitType - "TRAIT_CIVILIZATION_UNIT_PHOENICIA_BIREME" does not exist in Traits
[3362768.269] [Gameplay] ERROR: Invalid Reference on Units.TraitType - "TRAIT_CIVILIZATION_UNIT_SWEDEN_CAROLEAN" does not exist in Traits
[3362768.273] [Gameplay]: Failed Validation.
[3362771.665] [Configuration]: Validating Foreign Key Constraints...
[3362771.666] [Configuration]: Passed Validation.
[3362772.161] [FullTextSearch]: FTS - Creating Context
[3362781.661] [FullTextSearch]: FullTextSearch - Shutting down
 
First, you've got something seriously wrong going on because this set of messages is reporting a unique constraint error for a Gathering Storm base file:
Code:
[3362767.001] [Gameplay] ERROR: UNIQUE constraint failed: CivilizationLeaders.LeaderType, CivilizationLeaders.CivilizationType
[3362767.001] [Gameplay]: While executing - 'insert into CivilizationLeaders('CivilizationType', 'LeaderType', 'CapitalName') values (?, ?, ?);'
[3362767.001] [Gameplay]: In XMLSerializer while inserting row into table insert into CivilizationLeaders('CivilizationType', 'LeaderType', 'CapitalName') with values (CIVILIZATION_CANADA, LEADER_LAURIER, LOC_CITY_NAME_OTTAWA, ).
[3362767.001] [Gameplay]: In XMLSerializer while updating table CivilizationLeaders from file Expansion2_Civilizations_Major.xml.
[3362767.001] [Gameplay] ERROR: UNIQUE constraint failed: CivilizationLeaders.LeaderType, CivilizationLeaders.CivilizationType
This should never happen, and is causing everything at and after this line in the GS base file called "Expansion2_Civilizations_Major.xml" to fail loading into the game:
Code:
<CivilizationLeaders>
		<!-- Full Civs -->
		<Row CivilizationType="CIVILIZATION_CANADA" LeaderType="LEADER_LAURIER" CapitalName="LOC_CITY_NAME_OTTAWA"/>
Most likely a malformed mod is causing this issue. In no case should the end result of anything done in a mod be to create a Unique Constraint error when a Basegame, DLC, or Expansion file loads into the game.

The end result of this Unique Constraint error is all these Invalid Reference errors:
Code:
[3362768.254] [Gameplay] ERROR: Invalid Reference on Buildings.TraitType - "TRAIT_CIVILIZATION_BUILDING_GRAND_BAZAAR" does not exist in Traits
[3362768.254] [Gameplay] ERROR: Invalid Reference on Buildings.TraitType - "TRAIT_CIVILIZATION_BUILDING_MARAE" does not exist in Traits
[3362768.254] [Gameplay] ERROR: Invalid Reference on Buildings.TraitType - "TRAIT_CIVILIZATION_BUILDING_THERMAL_BATH" does not exist in Traits
[3362768.257] [Gameplay] ERROR: Invalid Reference on Districts.TraitType - "TRAIT_CIVILIZATION_DISTRICT_COTHON" does not exist in Traits
[3362768.257] [Gameplay] ERROR: Invalid Reference on Districts.TraitType - "TRAIT_CIVILIZATION_DISTRICT_SUGUBA" does not exist in Traits
[3362768.260] [Gameplay] ERROR: Invalid Reference on Improvements.TraitType - "TRAIT_CIVILIZATION_IMPROVEMENT_OPEN_AIR_MUSEUM" does not exist in Traits
[3362768.260] [Gameplay] ERROR: Invalid Reference on Improvements.TraitType - "TRAIT_CIVILIZATION_IMPROVEMENT_ICE_HOCKEY_RINK" does not exist in Traits
[3362768.260] [Gameplay] ERROR: Invalid Reference on Improvements.TraitType - "TRAIT_CIVILIZATION_IMPROVEMENT_TERRACE_FARM" does not exist in Traits
[3362768.260] [Gameplay] ERROR: Invalid Reference on Improvements.TraitType - "TRAIT_CIVILIZATION_IMPROVEMENT_MAORI_PA" does not exist in Traits
[3362768.269] [Gameplay] ERROR: Invalid Reference on Units.TraitType - "TRAIT_CIVILIZATION_UNIT_CANADA_MOUNTIE" does not exist in Traits
[3362768.269] [Gameplay] ERROR: Invalid Reference on Units.TraitType - "TRAIT_CIVILIZATION_UNIT_HUNGARY_HUSZAR" does not exist in Traits
[3362768.269] [Gameplay] ERROR: Invalid Reference on Units.TraitType - "TRAIT_CIVILIZATION_UNIT_INCA_WARAKAQ" does not exist in Traits
[3362768.269] [Gameplay] ERROR: Invalid Reference on Units.TraitType - "TRAIT_CIVILIZATION_UNIT_MALI_MANDEKALU_CAVALRY" does not exist in Traits
[3362768.269] [Gameplay] ERROR: Invalid Reference on Units.TraitType - "TRAIT_CIVILIZATION_UNIT_MAORI_TOA" does not exist in Traits
[3362768.269] [Gameplay] ERROR: Invalid Reference on Units.TraitType - "TRAIT_CIVILIZATION_UNIT_OTTOMAN_BARBARY_CORSAIR" does not exist in Traits
[3362768.269] [Gameplay] ERROR: Invalid Reference on Units.TraitType - "TRAIT_CIVILIZATION_UNIT_PHOENICIA_BIREME" does not exist in Traits
[3362768.269] [Gameplay] ERROR: Invalid Reference on Units.TraitType - "TRAIT_CIVILIZATION_UNIT_SWEDEN_CAROLEAN" does not exist in Traits
Invalid Reference errors always result in being shoved back to the main menu.


Every new row added to table "CivilizationLeaders" must have a unique combination of data for columns "CivilizationType" and "LeaderType": repeats are not allowed, nor is restating data that already exists in the game's base files.

And if a mod shoves this into the table before Gathering Storm loads
Code:
<CivilizationLeaders>
		<Row CivilizationType="CIVILIZATION_CANADA" LeaderType="LEADER_LAURIER" CapitalName="LOC_CITY_????"/>
Then when Gathering Storm loads the unique constraint error is created and the Gathering Storm code does not load properly. "????" in this case being a stand-in for an alteration from the normal CapitalName designation that Gathering Storm, etc., uses for Canada.

-----------------------------------------------

Database.log is also reporting an error where there is an attempt to add a row in table <LocalizedText> with no entry for the "Language" column:
Code:
[3362767.828] [Localization] ERROR: NOT NULL constraint failed: LocalizedText.Language
[3362767.828] [Localization]: While executing - 'insert into LocalizedText('Tag', 'Text') values (?, ?);'
[3362767.828] [Localization]: In XMLSerializer while inserting row into table insert into LocalizedText('Tag', 'Text') with values (TXT_KEY_CITY_NAME_POLAND_CITY_00, Варшава, ).
[3362767.828] [Localization]: In XMLSerializer while updating table LocalizedText from file PolandCityList.xml.
[3362767.828] [Localization] ERROR: NOT NULL constraint failed: LocalizedText.Language
NOT NULL constraint means that TableName.ColumnName (ie, in this example, LocalizedText.Language) cannot be missing an entry for the "Language" column in any row added to table "LocalizedText".


The error is located in a file called "PolandCityList.xml" This is what this line from the group of error messages is telling you
Code:
[3362767.828] [Localization]: In XMLSerializer while updating table LocalizedText from file PolandCityList.xml.
 
Last edited:
OK, this is very weird. Yes, there is a problem with the PolandCityList.xml. The cities in Russian are missing the "Language="ru_RU"" string. I am saying this is weird because the game has decided that only now it bothers it. Everything used to work just fine before I've updated the mod. I am going to fix the file (which is in a separate mod, by the way, and is not part of the mod that doesn't work) and see what happens.
Oh, wait, wasn't Poland part of the Gathering Storm expansion?
 
First, you've got something seriously wrong going on because this set of messages is reporting a unique constraint error for a Gathering Storm base file:
Code:
[3362767.001] [Gameplay] ERROR: UNIQUE constraint failed: CivilizationLeaders.LeaderType, CivilizationLeaders.CivilizationType
[3362767.001] [Gameplay]: While executing - 'insert into CivilizationLeaders('CivilizationType', 'LeaderType', 'CapitalName') values (?, ?, ?);'
[3362767.001] [Gameplay]: In XMLSerializer while inserting row into table insert into CivilizationLeaders('CivilizationType', 'LeaderType', 'CapitalName') with values (CIVILIZATION_CANADA, LEADER_LAURIER, LOC_CITY_NAME_OTTAWA, ).
[3362767.001] [Gameplay]: In XMLSerializer while updating table CivilizationLeaders from file Expansion2_Civilizations_Major.xml.
[3362767.001] [Gameplay] ERROR: UNIQUE constraint failed: CivilizationLeaders.LeaderType, CivilizationLeaders.CivilizationType
This should never happen, and is causing everything at and after this line in the GS base file called "Expansion2_Civilizations_Major.xml" to fail loading into the game:
Code:
<CivilizationLeaders>
        <!-- Full Civs -->
        <Row CivilizationType="CIVILIZATION_CANADA" LeaderType="LEADER_LAURIER" CapitalName="LOC_CITY_NAME_OTTAWA"/>
Most likely a malformed mod is causing this issue. In no case should the end result of anything done in a mod be to create a Unique Constraint error when a Basegame, DLC, or Expansion file loads into the game.

The end result of this Unique Constraint error is all these Invalid Reference errors:
Code:
[3362768.254] [Gameplay] ERROR: Invalid Reference on Buildings.TraitType - "TRAIT_CIVILIZATION_BUILDING_GRAND_BAZAAR" does not exist in Traits
[3362768.254] [Gameplay] ERROR: Invalid Reference on Buildings.TraitType - "TRAIT_CIVILIZATION_BUILDING_MARAE" does not exist in Traits
[3362768.254] [Gameplay] ERROR: Invalid Reference on Buildings.TraitType - "TRAIT_CIVILIZATION_BUILDING_THERMAL_BATH" does not exist in Traits
[3362768.257] [Gameplay] ERROR: Invalid Reference on Districts.TraitType - "TRAIT_CIVILIZATION_DISTRICT_COTHON" does not exist in Traits
[3362768.257] [Gameplay] ERROR: Invalid Reference on Districts.TraitType - "TRAIT_CIVILIZATION_DISTRICT_SUGUBA" does not exist in Traits
[3362768.260] [Gameplay] ERROR: Invalid Reference on Improvements.TraitType - "TRAIT_CIVILIZATION_IMPROVEMENT_OPEN_AIR_MUSEUM" does not exist in Traits
[3362768.260] [Gameplay] ERROR: Invalid Reference on Improvements.TraitType - "TRAIT_CIVILIZATION_IMPROVEMENT_ICE_HOCKEY_RINK" does not exist in Traits
[3362768.260] [Gameplay] ERROR: Invalid Reference on Improvements.TraitType - "TRAIT_CIVILIZATION_IMPROVEMENT_TERRACE_FARM" does not exist in Traits
[3362768.260] [Gameplay] ERROR: Invalid Reference on Improvements.TraitType - "TRAIT_CIVILIZATION_IMPROVEMENT_MAORI_PA" does not exist in Traits
[3362768.269] [Gameplay] ERROR: Invalid Reference on Units.TraitType - "TRAIT_CIVILIZATION_UNIT_CANADA_MOUNTIE" does not exist in Traits
[3362768.269] [Gameplay] ERROR: Invalid Reference on Units.TraitType - "TRAIT_CIVILIZATION_UNIT_HUNGARY_HUSZAR" does not exist in Traits
[3362768.269] [Gameplay] ERROR: Invalid Reference on Units.TraitType - "TRAIT_CIVILIZATION_UNIT_INCA_WARAKAQ" does not exist in Traits
[3362768.269] [Gameplay] ERROR: Invalid Reference on Units.TraitType - "TRAIT_CIVILIZATION_UNIT_MALI_MANDEKALU_CAVALRY" does not exist in Traits
[3362768.269] [Gameplay] ERROR: Invalid Reference on Units.TraitType - "TRAIT_CIVILIZATION_UNIT_MAORI_TOA" does not exist in Traits
[3362768.269] [Gameplay] ERROR: Invalid Reference on Units.TraitType - "TRAIT_CIVILIZATION_UNIT_OTTOMAN_BARBARY_CORSAIR" does not exist in Traits
[3362768.269] [Gameplay] ERROR: Invalid Reference on Units.TraitType - "TRAIT_CIVILIZATION_UNIT_PHOENICIA_BIREME" does not exist in Traits
[3362768.269] [Gameplay] ERROR: Invalid Reference on Units.TraitType - "TRAIT_CIVILIZATION_UNIT_SWEDEN_CAROLEAN" does not exist in Traits
Invalid Reference errors always result in being shoved back to the main menu.


Every new row added to table "CivilizationLeaders" must have a unique combination of data for columns "CivilizationType" and "LeaderType": repeats are not allowed, nor is restating data that already exists in the game's base files.

And if a mod shoves this into the table before Gathering Storm loads
Code:
<CivilizationLeaders>
        <Row CivilizationType="CIVILIZATION_CANADA" LeaderType="LEADER_LAURIER" CapitalName="LOC_CITY_????"/>
Then when Gathering Storm loads the unique constraint error is created and the Gathering Storm code does not load properly. "????" in this case being a stand-in for an alteration from the normal CapitalName designation that Gathering Storm, etc., uses for Canada.

-----------------------------------------------

Database.log is also reporting an error where there is an attempt to add a row in table <LocalizedText> with no entry for the "Language" column:
Code:
[3362767.828] [Localization] ERROR: NOT NULL constraint failed: LocalizedText.Language
[3362767.828] [Localization]: While executing - 'insert into LocalizedText('Tag', 'Text') values (?, ?);'
[3362767.828] [Localization]: In XMLSerializer while inserting row into table insert into LocalizedText('Tag', 'Text') with values (TXT_KEY_CITY_NAME_POLAND_CITY_00, Варшава, ).
[3362767.828] [Localization]: In XMLSerializer while updating table LocalizedText from file PolandCityList.xml.
[3362767.828] [Localization] ERROR: NOT NULL constraint failed: LocalizedText.Language
NOT NULL constraint means that TableName.ColumnName (ie, in this example, LocalizedText.Language) cannot be missing an entry for the "Language" column in any row added to table "LocalizedText".


The error is located in a file called "PolandCityList.xml" This is what this line from the group of error messages is telling you
Code:
[3362767.828] [Localization]: In XMLSerializer while updating table LocalizedText from file PolandCityList.xml.
OK, I have fixed the Poland cities file, but the mod still doesn't work.
Same problem:
Spoiler Database Error :

[3406771.382] [Gameplay] ERROR: UNIQUE constraint failed: CivilizationLeaders.LeaderType, CivilizationLeaders.CivilizationType
[3406771.382] [Gameplay]: While executing - 'insert into CivilizationLeaders('CivilizationType', 'LeaderType', 'CapitalName') values (?, ?, ?);'
[3406771.382] [Gameplay]: In XMLSerializer while inserting row into table insert into CivilizationLeaders('CivilizationType', 'LeaderType', 'CapitalName') with values (CIVILIZATION_CANADA, LEADER_LAURIER, LOC_CITY_NAME_OTTAWA, ).
[3406771.382] [Gameplay]: In XMLSerializer while updating table CivilizationLeaders from file Expansion2_Civilizations_Major.xml.
[3406771.382] [Gameplay] ERROR: UNIQUE constraint failed: CivilizationLeaders.LeaderType, CivilizationLeaders.CivilizationType
[3406773.897] [Gameplay] ERROR: FOREIGN KEY constraint failed
[3406773.897] [Gameplay] ERROR: FOREIGN KEY constraint failed
[3406773.897] [Gameplay]: Validating Foreign Key Constraints...
[3406773.900] [Gameplay] ERROR: Invalid Reference on Buildings.TraitType - "TRAIT_CIVILIZATION_BUILDING_GRAND_BAZAAR" does not exist in Traits
[3406773.900] [Gameplay] ERROR: Invalid Reference on Buildings.TraitType - "TRAIT_CIVILIZATION_BUILDING_MARAE" does not exist in Traits
[3406773.900] [Gameplay] ERROR: Invalid Reference on Buildings.TraitType - "TRAIT_CIVILIZATION_BUILDING_THERMAL_BATH" does not exist in Traits
[3406773.902] [Gameplay] ERROR: Invalid Reference on Districts.TraitType - "TRAIT_CIVILIZATION_DISTRICT_COTHON" does not exist in Traits
[3406773.902] [Gameplay] ERROR: Invalid Reference on Districts.TraitType - "TRAIT_CIVILIZATION_DISTRICT_SUGUBA" does not exist in Traits
[3406773.905] [Gameplay] ERROR: Invalid Reference on Improvements.TraitType - "TRAIT_CIVILIZATION_IMPROVEMENT_OPEN_AIR_MUSEUM" does not exist in Traits
[3406773.905] [Gameplay] ERROR: Invalid Reference on Improvements.TraitType - "TRAIT_CIVILIZATION_IMPROVEMENT_ICE_HOCKEY_RINK" does not exist in Traits
[3406773.905] [Gameplay] ERROR: Invalid Reference on Improvements.TraitType - "TRAIT_CIVILIZATION_IMPROVEMENT_TERRACE_FARM" does not exist in Traits
[3406773.905] [Gameplay] ERROR: Invalid Reference on Improvements.TraitType - "TRAIT_CIVILIZATION_IMPROVEMENT_MAORI_PA" does not exist in Traits
[3406773.913] [Gameplay] ERROR: Invalid Reference on Units.TraitType - "TRAIT_CIVILIZATION_UNIT_CANADA_MOUNTIE" does not exist in Traits
[3406773.913] [Gameplay] ERROR: Invalid Reference on Units.TraitType - "TRAIT_CIVILIZATION_UNIT_HUNGARY_HUSZAR" does not exist in Traits
[3406773.913] [Gameplay] ERROR: Invalid Reference on Units.TraitType - "TRAIT_CIVILIZATION_UNIT_INCA_WARAKAQ" does not exist in Traits
[3406773.913] [Gameplay] ERROR: Invalid Reference on Units.TraitType - "TRAIT_CIVILIZATION_UNIT_MALI_MANDEKALU_CAVALRY" does not exist in Traits
[3406773.913] [Gameplay] ERROR: Invalid Reference on Units.TraitType - "TRAIT_CIVILIZATION_UNIT_MAORI_TOA" does not exist in Traits
[3406773.913] [Gameplay] ERROR: Invalid Reference on Units.TraitType - "TRAIT_CIVILIZATION_UNIT_OTTOMAN_BARBARY_CORSAIR" does not exist in Traits
[3406773.913] [Gameplay] ERROR: Invalid Reference on Units.TraitType - "TRAIT_CIVILIZATION_UNIT_PHOENICIA_BIREME" does not exist in Traits
[3406773.913] [Gameplay] ERROR: Invalid Reference on Units.TraitType - "TRAIT_CIVILIZATION_UNIT_SWEDEN_CAROLEAN" does not exist in Traits
[3406773.917] [Gameplay]: Failed Validation.
[3406779.491] [Configuration]: Validating Foreign Key Constraints...
[3406779.492] [Configuration]: Passed Validation.
[3406780.664] [FullTextSearch]: FTS - Creating Context
[3406789.625] [FullTextSearch]: FullTextSearch - Shutting down


I have disabled all other mods I have running. The problem persists. Something is wrong with the mod for some reason. Again, it used to work just fine until I made a minor change in a text string. Maybe it is about that loading order again?

I mean, all my other mods are built exactly the same, and they work.

Here is what this mod is supposed to do:
<CivilizationLeaders>
<Replace CivilizationType="CIVILIZATION_CANADA" LeaderType="LEADER_LAURIER" CapitalName="LOC_CITY_NAME_CANADA_CITY_00"/>
<Replace CivilizationType="CIVILIZATION_ENGLAND" LeaderType="LEADER_ELEANOR_ENGLAND" CapitalName="LOC_CITY_NAME_ENGLAND_CITY_00"/>
<Replace CivilizationType="CIVILIZATION_FRANCE" LeaderType="LEADER_ELEANOR_FRANCE" CapitalName="LOC_CITY_NAME_FRANCE_CITY_36"/>
<Replace CivilizationType="CIVILIZATION_HUNGARY" LeaderType="LEADER_MATTHIAS_CORVINUS" CapitalName="LOC_CITY_NAME_HUNGARY_CITY_00"/>
<Replace CivilizationType="CIVILIZATION_INCA" LeaderType="LEADER_PACHACUTI" CapitalName="LOC_CITY_NAME_INCA_CITY_00"/>
<Replace CivilizationType="CIVILIZATION_MALI" LeaderType="LEADER_MANSA_MUSA" CapitalName="LOC_CITY_NAME_MALI_CITY_03"/>
<Replace CivilizationType="CIVILIZATION_MAORI" LeaderType="LEADER_KUPE" CapitalName="LOC_CITY_NAME_MAORI_CITY_06"/>
<Replace CivilizationType="CIVILIZATION_OTTOMAN" LeaderType="LEADER_SULEIMAN" CapitalName="LOC_CITY_NAME_OTTOMAN_CITY_01"/>
<Replace CivilizationType="CIVILIZATION_PHOENICIA" LeaderType="LEADER_DIDO" CapitalName="LOC_CITY_NAME_PHOENICIA_CITY_00"/>
<Replace CivilizationType="CIVILIZATION_SWEDEN" LeaderType="LEADER_KRISTINA" CapitalName="LOC_CITY_NAME_SWEDEN_CITY_00"/>
</CivilizationLeaders>
<CityNames>
<Delete CivilizationType="CIVILIZATION_CANADA"/>
<Delete CivilizationType="CIVILIZATION_HUNGARY"/>
<Delete CivilizationType="CIVILIZATION_INCA"/>
<Delete CivilizationType="CIVILIZATION_MALI"/>
<Delete CivilizationType="CIVILIZATION_MAORI"/>
<Delete CivilizationType="CIVILIZATION_OTTOMAN"/>
<Delete CivilizationType="CIVILIZATION_PHOENICIA"/>
<Delete CivilizationType="CIVILIZATION_SWEDEN"/>
<!-- Canada -->
<Row CivilizationType="CIVILIZATION_CANADA" CityName="LOC_CITY_NAME_CANADA_CITY_00"/>
<Row CivilizationType="CIVILIZATION_CANADA" CityName="LOC_CITY_NAME_CANADA_CITY_01"/>
And so on...
It all seems correct to me.
 
Last edited:
Poland was part of DLC
 
The problem will almost certainly be a LoadOrder issue.

If this code loads before Gathering Storm
Code:
<CivilizationLeaders>
     <Replace CivilizationType="CIVILIZATION_CANADA" LeaderType="LEADER_LAURIER" CapitalName="LOC_CITY_NAME_CANADA_CITY_00"/>
     ...etc.....
The effect will be the same as If you had stated
Code:
<CivilizationLeaders>
     <Row CivilizationType="CIVILIZATION_CANADA" LeaderType="LEADER_LAURIER" CapitalName="LOC_CITY_NAME_CANADA_CITY_00"/>
     ...etc.....
<Replace> only alters an existing row in the table if there is a match for the primary keys within that table. If there is no match, then <Replace> adds a new row with the stated data.

If Gathering Storm has not loaded yet, your <Replace> commands have nothing to "replace" and will therefore crate new rows. Then, when Gathering Storm attempts to load, it encounters a row in table <CivilizationLeaders> with the exact same data for "CivilizationType" and "LeaderType" as Gathering Storm is attempting to add to the table -- this causes the base Gathering Storm file to fail, and you get all those Invalid Reference errors because the Gathering Storm file was not able to complete the loading process into the Database.

The only stable way to ensure a proper order of loading with respect to the game base code, expansions, and DLC is to add a LoadOrder value to all your UpdateDatabase, UpdateText, UpdateIcons, ImportFiles type of Actions on the InGame Side. Otherwise there are far too many otherwise innocuous things that can happen which can juggle the order in which code loads into the game, resulting in the sort of thing you are seeing. Generally a LoadOrder of 300 is sufficient but a LoadOrder of 500 would be even better.
 
The problem will almost certainly be a LoadOrder issue.

If this code loads before Gathering Storm
Code:
<CivilizationLeaders>
     <Replace CivilizationType="CIVILIZATION_CANADA" LeaderType="LEADER_LAURIER" CapitalName="LOC_CITY_NAME_CANADA_CITY_00"/>
     ...etc.....
The effect will be the same as If you had stated
Code:
<CivilizationLeaders>
     <Row CivilizationType="CIVILIZATION_CANADA" LeaderType="LEADER_LAURIER" CapitalName="LOC_CITY_NAME_CANADA_CITY_00"/>
     ...etc.....
<Replace> only alters an existing row in the table if there is a match for the primary keys within that table. If there is no match, then <Replace> adds a new row with the stated data.

If Gathering Storm has not loaded yet, your <Replace> commands have nothing to "replace" and will therefore crate new rows. Then, when Gathering Storm attempts to load, it encounters a row in table <CivilizationLeaders> with the exact same data for "CivilizationType" and "LeaderType" as Gathering Storm is attempting to add to the table -- this causes the base Gathering Storm file to fail, and you get all those Invalid Reference errors because the Gathering Storm file was not able to complete the loading process into the Database.

The only stable way to ensure a proper order of loading with respect to the game base code, expansions, and DLC is to add a LoadOrder value to all your UpdateDatabase, UpdateText, UpdateIcons, ImportFiles type of Actions on the InGame Side. Otherwise there are far too many otherwise innocuous things that can happen which can juggle the order in which code loads into the game, resulting in the sort of thing you are seeing. Generally a LoadOrder of 300 is sufficient but a LoadOrder of 500 would be even better.
I did it and it still doesn't work.
Here's the modinfo:
Spoiler Modinfo :

<?xml version="1.0" encoding="utf-8"?>
<Mod id="4365a6cc-c4b9-4334-b448-97ed54b0a51e" version="1">
<Properties>
<Name>Alternate City Lists - Gathering Storm</Name>
<Description>A mod that changes city lists, adding cities, changing names into native names.</Description>
<Created>1588288179</Created>
<Teaser>A mod that changes city lists.</Teaser>
<Authors>Igor</Authors>
<CompatibleVersions>1.2,2.0</CompatibleVersions>
<LoadOrder>500</LoadOrder>
</Properties>
<Dependencies>
<Mod id="9786606e-c741-4c51-9833-88999c0c193f" title="Alternate City Lists" />
</Dependencies>
<References>
<Mod id="4873eb62-8ccc-4574-b784-dda455e74e68" title="Expansion: Gathering Storm" />
</References>
<FrontEndActions>
<UpdateText id="GSTextUpdate">
<File priority="500">Names.xml</File>
</UpdateText>
</FrontEndActions>
<InGameActions>
<UpdateDatabase id="DatabaseUpdate">
<File priority="500">Database GS.xml</File>
</UpdateDatabase>
<UpdateText id="CityListTextUpdate">
<File priority="500">City Lists GS.xml</File>
</UpdateText>
<UpdateText id="InGame Text">
<File priority="500">Names.xml</File>
</UpdateText>
</InGameActions>
<Files>
<File>City Lists GS.xml</File>
<File>Database GS.xml</File>
<File>Names.xml</File>
</Files>
</Mod>
 
Back
Top Bottom