Please help me fix a sql problem!

anansethespider

Warlord
Joined
Oct 27, 2016
Messages
288
I want to add a new district to the game that requires adjacency to an existing district, in much the same fashion as wonders like the Great Library require campus adjacency. Just so we're not speaking in abstracts, lets say I am trying to add a district called Jeweler's Quarter that requires adjacency to a commercial hub.

I added the Jeweler's Quarter to the game with xml, copied icons and artdefs. That was all easy enough. But the problem began when I started trying to give it that requirement of an existing commercial hub. You see, the sql table that defines what districts can and can't do does not have any column for AdjacentDistricts or PrereqDistricts. So when you copy over those commands from a Wonder, they do nothing at all.

I thought I could around this by editing the 01_GameplaySchema.sql file, which defines the tables in the game including Districts. Here's the code I added to the table:

(-----under TABLE Districts)

"AdjacentDistrict" TEXT,
"PrereqDistrict" TEXT,

FOREIGN KEY (PrereqDistrict) REFERENCES Districts(DistrictType) ON DELETE SET DEFAULT ON UPDATE SET DEFAULT,
FOREIGN KEY (AdjacentDistrict) REFERENCES Districts(DistrictType) ON DELETE SET DEFAULT ON UPDATE SET DEFAULT,


(----at the bottom of the file)

INSERT INTO NavigationProperties("BaseTable", "PropertyName", "TargetTable", "IsCollection", "Query") VALUES("Districts", "AdjacentDistrictReference", "Districts", 0,"SELECT T1.rowid from Districts as T1 inner join Districts as T2 on T2.AdjacentDistrict = T1.DistrictType where T2.rowid = ? ORDER BY T1.rowid ASC LIMIT 1");

INSERT INTO NavigationProperties("BaseTable", "PropertyName", "TargetTable", "IsCollection", "Query") VALUES("Districts", "PrereqDistrictReference", "Districts", 0,"SELECT T1.rowid from Districts as T1 inner join Districts as T2 on T2.PrereqDistrict = T1.DistrictType where T2.rowid = ? ORDER BY T1.rowid ASC LIMIT 1");


And with this combination of code the game runs stable, which is to say it doesn't crash, but neither the adjacency requirement nor district prerequisites have any effect. This leads me to believe I am writing the code correctly, but misunderstanding something fundamental about what needs to be done. I would really appreciate any help or guidance from more experienced modders, and thank you in advance :)


edit, in case it helps, here's the relevant part of code for the modded district from the xml file:

<Row DistrictType="DISTRICT_JEWELERY" Name="LOC_DISTRICT_JEWELERY_NAME" Description="LOC_DISTRICT_JEWELERY_DESCRIPTION" PrereqTech="TECH_CURRENCY" PlunderType="PLUNDER_GOLD" PlunderAmount="50" AdvisorType="ADVISOR_GENERIC" Cost="100" CostProgressionModel="COST_PROGRESSION_NUM_UNDER_AVG_PLUS_TECH" CostProgressionParam1="25" RequiresPlacement="true" RequiresPopulation="true" PrereqDistrict="DISTRICT_COMMERCIAL_HUB" AdjacentDistrict="DISTRICT_COMMERCIAL_HUB" Aqueduct="false" NoAdjacentCity="false" InternalOnly="false" ZOC="false" TradeRouteCapacity="1" CaptureRemovesBuildings="false" CaptureRemovesCityDefenses="false" MilitaryDomain="NO_DOMAIN" TravelTime="3" CityStrengthModifier="2"/>
 
Top Bottom