GameInfoTypes no longer yields the object's ID

JFD

Kathigitarkh
Joined
Oct 19, 2010
Messages
9,132
Location
The Kingdom of New Zealand
The method to retrieve an object's id that I've used for a long time has always been GameInfoTypes[X], but inexplicably it has stopped retrieving the ID for a certain few of my modded civilisations (Norway, Nicholas II, and Peter), and, now, consistently returns numbers of indiscernible correlation (3, 2, 1, respectively). This has caused the code of a few of my civs to fail - yet the same GameInfoTypes method works for my other civs... Switching over to GameInfo.Civilizations[].ID fixes the problem, but the fact that this is a seemingly unprovoked issue is disconcerting. It also doesn't seem to be failing to retrieve the object ID of terrains or units, just Civs.

Does anyone have any idea why this might be happening?
 
No, Norway has 23 characters, though Nicholas has 32 and Peter has 31. Still, it was working not too long ago.

Some further testing:

In the combined pack of Prussia and Hungary, Hungary fails with the same problem - printing out GameInfoTypes["CIVILIZATION_JFD_HUNGARY"] returns the number 5, but the ID in the database is 50. However, this does not occur in the individual Hungary mod. Also, strangely, when print(GameInfoTypes["CIVILIZATION_JFD_HUNGARY"]) is called from within the Norway mod, it returns correctly the ID of 50... Yet Norway works in neither.



Should I not have added an Illuminati event in Bavaria? :lol: :confused: :(
 
I've seem this before once
if you happen to have a duplicate ID in two table, it may return the ID in the other table
my case is, I have
GameInfo.Buildings.BARRACKS.ID = 3
GameInfo.Technologies.BARRACKS.ID = 5
then
GameInfoTypes["BARRACKS"] may return 3 or 5 randomly
But that shouldn't happen because these would be BUILDING_BARACKS and TECH_BARACKS, right? Unless you are really working hard to break the unique Type system.

I haven't seen problem mentioned in OP. But curious what the problem might be. Any chance that other mods are adding a Type string that isn't unique?
 
I've tried to use the same Type name for building and tech before(with a building named "TECH_BARRACKS"), that do cause the GameInfoTypes problem, and I figure out a solution, by make the building and tech with the same Type name have identical ID too

but that will require to hand fix all the building ID to the tech ID, it's not easy

If there are other mod enabled, it's quite likely a conflict Type string defined by others
doing a text search of the bugy type string in the MODS dir, that will figure out the conflict
 
No other mods were enabled (other than IGE) and this problem still occurred. Changing the tag to something unique did not fix the problem, either. Nor re-creating the mod, nor deleting the cache, nor re-installing the game. The type string was absolutely unique.
 
I check the mod and I think the problem is here in a custom table:
Code:
--==========================================================================================================================
-- ML_CivCultures
--==========================================================================================================================
CREATE TABLE IF NOT EXISTS Civilization_HistoricalSpawnDates
	 (	ID INTEGER PRIMARY KEY AUTOINCREMENT,
		Type TEXT NOT NULL UNIQUE,
		StartYear INTEGER DEFAULT -10000,
		UnitType1 TEXT DEFAULT NULL,
		UnitType2 TEXT DEFAULT NULL,
		UnitType3 TEXT DEFAULT NULL,
		UnitType4 TEXT DEFAULT NULL,
		UnitType5 TEXT DEFAULT NULL,
		UnitType6 TEXT DEFAULT NULL,
		NoFreeTech BOOLEAN DEFAULT 0);

INSERT OR REPLACE INTO Civilization_HistoricalSpawnDates
		(Type,							StartYear,	NoFreeTech,	UnitType1,			UnitType2,		UnitType3,			UnitType4,		UnitType5,		UnitType6)
VALUES	('CIVILIZATION_JFD_HUNGARY',	1000,		0,			'UNIT_WARRIOR',		'UNIT_SCOUT',	'UNIT_SPEARMAN',	'UNIT_WORKER',	'UNIT_SETTLER',	'UNIT_WORKER');

here CIVILIZATION_JFD_HUNGARY is used as another unique Type string besides the Civilizations table

A solution is, change the "Type" to "CivType" and remove "NOT NULL UNIQUE"
Another way, you can drop this table and add columns in the Civilizations table directly, this will be better in performances
 
I check the mod and I think the problem is here in a custom table:
Code:
--==========================================================================================================================
-- ML_CivCultures
--==========================================================================================================================
CREATE TABLE IF NOT EXISTS Civilization_HistoricalSpawnDates
	 (	ID INTEGER PRIMARY KEY AUTOINCREMENT,
		Type TEXT NOT NULL UNIQUE,
		StartYear INTEGER DEFAULT -10000,
		UnitType1 TEXT DEFAULT NULL,
		UnitType2 TEXT DEFAULT NULL,
		UnitType3 TEXT DEFAULT NULL,
		UnitType4 TEXT DEFAULT NULL,
		UnitType5 TEXT DEFAULT NULL,
		UnitType6 TEXT DEFAULT NULL,
		NoFreeTech BOOLEAN DEFAULT 0);

INSERT OR REPLACE INTO Civilization_HistoricalSpawnDates
		(Type,							StartYear,	NoFreeTech,	UnitType1,			UnitType2,		UnitType3,			UnitType4,		UnitType5,		UnitType6)
VALUES	('CIVILIZATION_JFD_HUNGARY',	1000,		0,			'UNIT_WARRIOR',		'UNIT_SCOUT',	'UNIT_SPEARMAN',	'UNIT_WORKER',	'UNIT_SETTLER',	'UNIT_WORKER');

here CIVILIZATION_JFD_HUNGARY is used as another unique Type string besides the Civilizations table

A solution is, change the "Type" to "CivType" and remove "NOT NULL UNIQUE"
Another way, you can drop this table and add columns in the Civilizations table directly, this will be better in performances

Hm, I'll have to alert the author of Historical Spawn Dates about this; this was their suggestion of adding support for their mod. Thanks. Mystery solved.
 
Top Bottom