Using GameConfiguration Values in Ingame SQL/XML


May 2, 2021
There are a few places in the Frontend configuration where database queries can vary depending on the value(s) of one or more GameConfiguration settings. Take the following examples from SetupParameters.xml, which together define the range of the City-States slider:
 <Row QueryId="CityStateCountRange" SQL="SELECT 'CityStateCountRange' AS Domain, ?1 AS MinimumValue, ?2 AS MaximumValue LIMIT 1"/>

 <Row QueryId="CityStateCountRange" Index="1" ConfigurationGroup="Map" ConfigurationId="MAP_MIN_MINOR_PLAYERS"/>
 <Row QueryId="CityStateCountRange" Index="2" ConfigurationGroup="Map" ConfigurationId="MAP_MAX_MINOR_PLAYERS"/>

In ENWS, I use similar code for the Natural Wonder slider, with some alterations to cap the maximum value to the lesser of two values, as follows:
INSERT INTO Queries (QueryId, SQL)
    ('StandardNaturalWonderCountRange', 'SELECT ''StandardNaturalWonderCountRange'' AS Domain, ?1 AS MinimumValue, (SELECT CASE WHEN (SELECT Count(*) FROM NaturalWonders WHERE Domain = ''StandardNaturalWonders'') < ?2 THEN (SELECT Count(*) FROM NaturalWonders WHERE Domain = ''StandardNaturalWonders'') ELSE ?2 END) AS MaximumValue LIMIT 1');

  <Row QueryId="StandardNaturalWonderCountRange" Index="1" ConfigurationGroup="Map" ConfigurationId="MAP_MIN_NATURAL_WONDERS"/>
  <Row QueryId="StandardNaturalWonderCountRange" Index="2" ConfigurationGroup="Map" ConfigurationId="MAP_MAX_NATURAL_WONDERS"/>

Is there any way to do something similar in the Ingame database? Specifically, when updating table T, if a particular GameConfiguration setting S = 1, then set column C = X; if S != 1, then set C = Y. Substituting the GameConfiguration setting directly in the query unsurprisingly doesn't seem to work, and there doesn't appear to be any mechanism in that database similar to the way the above-referenced tables work together to produce variable queries.

Using <Criteria> and <UpdateDatabase> tags with corresponding files in the .modinfo file, it is possible to simulate the behavior I'm looking for, like so:
  <Criteria id="Dummy_Setting_Enabled" any="1">

  <UpdateDatabase id="Dummy_Setting_Changes" criteria="Dummy_Setting_Enabled">

Here, Path/To/File.sql contains any changes to make to the Ingame DB when DUMMY_SETTING = 1. This solution quickly becomes unwieldy with any more than a handful of GameConfiguration settings, so it's close, but not quite what I'm looking for. Is what I'm looking for even possible?
Last edited:
Top Bottom