Skip to content

Commit

Permalink
Marathon/Duel/Settler settings fix
Browse files Browse the repository at this point in the history
Added in the complete table so that the PRIMARY KEY and the UNIQUE
constraints are set for the ID and Type columns.
  • Loading branch information
stackpoint committed Mar 1, 2014
1 parent 74b9e41 commit 6919000
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 17 deletions.
6 changes: 1 addition & 5 deletions Cat/Cat/AI/CEAI_FixTables.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ Can copy the modded tables into another set of tables that hasn't been cached be
--GameInfoCep.HandicapInfos = {}

function Game.GetWorldInfo()
local mapsize = Map.GetWorldSize(); --returns nil instead of 0 for Duel sized maps
if (not mapsize) then
return GameInfo.CepWorlds[0]
end
return GameInfo.CepWorlds[mapsize]
return GameInfo.CepWorlds[Map.GetWorldSize()]
end
function Game.GetSpeedInfo()
return GameInfo.CepGameSpeeds[Game.GetGameSpeedType()]
Expand Down
2 changes: 2 additions & 0 deletions Cat/Cat/_Project/CAT_AlterTables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ ALTER TABLE Flavors ADD PurchasePriority variant default 0;

ALTER TABLE GameOptions ADD Reverse boolean;

--ALTER TABLE changes to CepHandicapInfos in CAT_Info.xml
ALTER TABLE HandicapInfos ADD AIFreeXPPerEra integer default 0;
ALTER TABLE HandicapInfos ADD AIFreeXPPerTurn variant default 0;
ALTER TABLE HandicapInfos ADD AIFreeXPMax integer default 0;
Expand Down Expand Up @@ -499,6 +500,7 @@ ALTER TABLE UnitPromotions ADD RankList text;
ALTER TABLE UnitPromotions ADD RankNumber integer default 0;
ALTER TABLE UnitPromotions ADD Class text default 'PROMOTION_CLASS_PERSISTENT';

--ALTER TABLE changes to CepWorlds in CAT_Info.xml
ALTER TABLE Worlds ADD AISearchRange integer default 0;
ALTER TABLE Worlds ADD ResourceMod integer default 100;
UPDATE Worlds SET ResourceMod = 100;
Expand Down
8 changes: 4 additions & 4 deletions Cat/Cat/_Project/CAT_End.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--
CREATE TABLE CepWorlds AS SELECT * FROM Worlds;
CREATE TABLE CepGameSpeeds AS SELECT * FROM GameSpeeds;
CREATE TABLE CepHandicapInfos AS SELECT * FROM HandicapInfos;
--
INSERT INTO CepWorlds SELECT * FROM Worlds;
INSERT INTO CepGameSpeeds SELECT * FROM Worlds;
INSERT INTO CepHandicapInfos SELECT * FROM Worlds;

UPDATE LoadedFile SET Value=1 WHERE Type='CAT_End.sql';
156 changes: 156 additions & 0 deletions Cat/Cat/_Project/CAT_Info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,160 @@
<Value>0</Value>
</Row>
</Cep>

This comment has been minimized.

Copy link
@GrantSP

GrantSP Mar 1, 2014

Collaborator

@stackpoint I see you have made a fix.
Don't want to rain on your parade but you could have done this table creation in sql just before your INSERTS in Cat_End.sql & CEP_End.sql
CREATE table Cepworlds (ID int primary key, Type text NOT NULL, Description text, etc.) with all the columns set here. Then your INSERT INTOs would just copy the values correctly, primary key and all.
I thought you said you weren't using CREATE but rather ALTER? Must have misunderstood your email.

This comment has been minimized.

Copy link
@stackpoint

stackpoint Mar 1, 2014

Author Contributor

It was easier and less prone to human error to copy and paste the vanilla BNW xml code than to adapt all of it to sql. The SQL code I was using to duplicate the table before was:

CREATE TABLE CepWorlds AS SELECT * FROM Worlds;

Which let me duplicate all the entries and columns in a single line, except for the primary key and unique constraints. So I was trying to find an ALTER TABLE command that worked to add those constraits in SQLite, which unfortunately did not.


<!-- Copy of Worlds Table -->
<Table name="CepWorlds">
<Column name="ID" type="integer" primarykey="true" autoincrement="true"/>
<Column name="Type" type="text" notnull="true" unique="true"/>
<Column name="Description" type="text"/>
<Column name="Help" type="text"/>
<Column name="DefaultPlayers" type="integer"/>
<Column name="DefaultMinorCivs" type="integer"/>
<Column name="FogTilesPerBarbarianCamp" type="integer"/>
<Column name="NumNaturalWonders" type="integer"/>
<Column name="UnitNameModifier" type="integer"/>
<Column name="TargetNumCities" type="integer"/>
<Column name="NumFreeBuildingResources" type="integer"/>
<Column name="BuildingClassPrereqModifier" type="integer"/>
<Column name="MaxConscriptModifier" type="integer"/>
<Column name="GridWidth" type="integer"/>
<Column name="GridHeight" type="integer"/>
<Column name="MaxActiveReligions" type="integer"/>
<Column name="TerrainGrainChange" type="integer"/>
<Column name="FeatureGrainChange" type="integer"/>
<Column name="ResearchPercent" type="integer"/>
<Column name="NumCitiesUnhappinessPercent" type="integer"/>
<Column name="NumCitiesPolicyCostMod" type="integer"/>
<Column name="NumCitiesTechCostMod" type="integer"/>
<Column name="AdvancedStartPointsMod" type="integer"/>
<Column name="EstimatedNumCities" type="integer"/>
<Column name="PortraitIndex" type="integer" default="-1"/>
<Column name="IconAtlas" type="text" default="NULL" reference="IconTextureAtlases(Atlas)"/>

<!-- Custom Worlds Columns -->
<Column name="AISearchRange" type="integer" default="0"/>
<Column name="ResourceMod" type="integer" default="100"/>
</Table>

<!-- Copy of GameSpeeds Table -->
<Table name="CepGameSpeeds">
<Column name="ID" type="integer" primarykey="true" autoincrement="true"/>
<Column name="Type" type="text" notnull="true" unique="true"/>
<Column name="Description" type="text"/>
<Column name="Help" type="text"/>
<Column name="DealDuration" type="integer" default="0"/>
<Column name="GrowthPercent" type="integer" default="0"/>
<Column name="TrainPercent" type="integer" default="0"/>
<Column name="ConstructPercent" type="integer" default="0"/>
<Column name="CreatePercent" type="integer" default="0"/>
<Column name="ResearchPercent" type="integer" default="0"/>
<Column name="GoldPercent" type="integer" default="0"/>
<Column name="GoldGiftMod" type="integer" default="0"/>
<Column name="BuildPercent" type="integer" default="0"/>
<Column name="ImprovementPercent" type="integer" default="0"/>
<Column name="GreatPeoplePercent" type="integer" default="0"/>
<Column name="CulturePercent" type="integer" default="0"/>
<Column name="FaithPercent" type="integer" default="0"/>
<Column name="BarbPercent" type="integer" default="0"/>
<Column name="FeatureProductionPercent" type="integer" default="0"/>
<Column name="UnitDiscoverPercent" type="integer" default="0"/>
<Column name="UnitHurryPercent" type="integer" default="0"/>
<Column name="UnitTradePercent" type="integer" default="0"/>
<Column name="GoldenAgePercent" type="integer" default="0"/>
<Column name="HurryPercent" type="integer" default="0"/>
<Column name="InflationPercent" type="integer" default="0"/>
<Column name="InflationOffset" type="integer" default="0"/>
<Column name="ReligiousPressureAdjacentCity" type="integer" default="0"/>
<Column name="VictoryDelayPercent" type="integer" default="0"/>
<Column name="MinorCivElectionFreqMod" type="integer" default="0"/>
<Column name="OpinionDurationPercent" type="integer" default="0"/>
<Column name="SpyRatePercent" type="integer" default="0"/>
<Column name="PeaceDealDuration" type="integer" default="0"/>
<Column name="RelationshipDuration" type="integer" default="0"/>
<Column name="LeaguePercent" type="integer" default="0"/>
<Column name="PortraitIndex" type="integer" default="-1"/>
<Column name="IconAtlas" type="text" default="NULL" reference="IconTextureAtlases(Atlas)"/>
</Table>

<!-- Copy of HandicapInfos Table -->
<Table name="CepHandicapInfos">
<Column name="ID" type="integer" primarykey="true" autoincrement="true"/>
<Column name="Type" type="text" notnull="true" unique="true"/>
<Column name="Description" type="text"/>
<Column name="Help" type="text"/>
<Column name="StartingLocPercent" type="integer" default="0"/>
<Column name="AdvancedStartPointsMod" type="integer" default="0"/>
<Column name="StartingPolicyPoints" type="integer" default="0"/>
<Column name="HappinessDefault" type="integer" default="0"/>
<Column name="ExtraHappinessPerLuxury" type="integer" default="0"/>
<Column name="NumCitiesUnhappinessMod" type="integer" default="0"/>
<Column name="PopulationUnhappinessMod" type="integer" default="0"/>
<Column name="Gold" type="integer" default="0"/>
<Column name="GoldFreeUnits" type="integer" default="0"/>
<Column name="ProductionFreeUnits" type="integer" default="0"/>
<Column name="ProductionFreeUnitsPerCity" type="integer" default="0"/>
<Column name="ProductionFreeUnitsPopulationPercent" type="integer" default="0"/>
<Column name="RouteCostPercent" type="integer" default="0"/>
<Column name="UnitCostPercent" type="integer" default="0"/>
<Column name="BuildingCostPercent" type="integer" default="0"/>
<Column name="ResearchPercent" type="integer" default="0"/>
<Column name="PolicyPercent" type="integer" default="0"/>
<Column name="ImprovementCostPercent" type="integer" default="0"/>
<Column name="CityProductionNumOptionsConsidered" type="integer" default="0"/>
<Column name="TechNumOptionsConsidered" type="integer" default="0"/>
<Column name="PolicyNumOptionsConsidered" type="integer" default="0"/>
<Column name="InflationPercent" type="integer" default="100"/>
<Column name="FreeCulturePerTurn" type="integer" default="0"/>
<Column name="AttitudeChange" type="integer" default="0"/>
<Column name="NoTechTradeModifier" type="integer" default="0"/>
<Column name="TechTradeKnownModifier" type="integer" default="0"/>
<Column name="BarbCampGold" type="integer" default="0"/>
<Column name="BarbSpawnMod" type="integer" default="0"/>
<Column name="BarbarianBonus" type="integer" default="0"/>
<Column name="AIBarbarianBonus" type="integer" default="0"/>
<Column name="EarliestBarbarianReleaseTurn" type="integer" default="0"/>
<Column name="BarbarianLandTargetRange" type="integer" default="0"/>
<Column name="BarbarianSeaTargetRange" type="integer" default="0"/>
<Column name="StartingDefenseUnits" type="integer" default="0"/>
<Column name="StartingWorkerUnits" type="integer" default="0"/>
<Column name="StartingExploreUnits" type="integer" default="0"/>
<Column name="AIStartingUnitMultiplier" type="integer" default="0"/>
<Column name="AIStartingDefenseUnits" type="integer" default="0"/>
<Column name="AIStartingWorkerUnits" type="integer" default="0"/>
<Column name="AIStartingExploreUnits" type="integer" default="0"/>
<Column name="AIDeclareWarProb" type="integer" default="0"/>
<Column name="AIWorkRateModifier" type="integer" default="0"/>
<Column name="AIUnhappinessPercent" type="integer" default="0"/>
<Column name="AIGrowthPercent" type="integer" default="0"/>
<Column name="AITrainPercent" type="integer" default="0"/>
<Column name="AIWorldTrainPercent" type="integer" default="0"/>
<Column name="AIConstructPercent" type="integer" default="0"/>
<Column name="AIWorldConstructPercent" type="integer" default="0"/>
<Column name="AICreatePercent" type="integer" default="0"/>
<Column name="AIWorldCreatePercent" type="integer" default="0"/>
<Column name="AIBuildingCostPercent" type="integer" default="0"/>
<Column name="AIUnitCostPercent" type="integer" default="0"/>
<Column name="AIUnitSupplyPercent" type="integer" default="0"/>
<Column name="AIUnitUpgradePercent" type="integer" default="0"/>
<Column name="AIInflationPercent" type="integer" default="100"/>
<Column name="AIPerEraModifier" type="integer" default="0"/>
<Column name="AIAdvancedStartPercent" type="integer" default="0"/>
<Column name="AIFreeXP" type="integer" default="0"/>
<Column name="AIFreeXPPercent" type="integer" default="0"/>
<Column name="PortraitIndex" type="integer" default="-1"/>
<Column name="IconAtlas" type="text" default="NULL" reference="IconTextureAtlases(Atlas)"/>

<!-- Custom Worlds Columns -->
<Column name="AIFreeXPPerEra" type="integer" default="0"/>
<Column name="AIFreeXPPerTurn" type="variant" default="0"/>
<Column name="AIFreeXPMax" type="integer" default="0"/>
<Column name="AIFreePromotion" type="text"/>
<Column name="AIResearchPercent" type="variant" default="0"/>
<Column name="AIResearchPercentPerEra" type="variant" default="0"/>
<Column name="AIProductionPercentPerEra" type="variant" default="0"/>
<Column name="AIGold" type="integer" default="0"/>
<Column name="AISearchRange" type="integer" default="0"/>
<Column name="AICapitalYieldPeaceful" type="integer" default="0"/>
<Column name="AICapitalYieldMilitaristic" type="integer" default="0"/>
</Table>
</GameData>
1 change: 0 additions & 1 deletion Cat/Cat/_Project/CAT_Start.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ INSERT INTO LoadedFile(Type, Value) VALUES ('CAT_Start.sql' , 0);
INSERT INTO LoadedFile(Type, Value) VALUES ('CAT_Misc.sql' , 0);
INSERT INTO LoadedFile(Type, Value) VALUES ('Cat_Options.sql' , 0);
INSERT INTO LoadedFile(Type, Value) VALUES ('Cat_Promotions.sql' , 0);
INSERT INTO LoadedFile(Type, Value) VALUES ('Cep_Options.sql' , 0);
INSERT INTO LoadedFile(Type, Value) VALUES ('CAT_AlterTables.sql' , 0);
INSERT INTO LoadedFile(Type, Value) VALUES ('YL_General.xml' , 0);
INSERT INTO LoadedFile(Type, Value) VALUES ('TW_BuildingStats.sql' , 0);
Expand Down
14 changes: 7 additions & 7 deletions Ceg/Ceg/_Project/CEP_End.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
--
DROP TABLE CepWorlds;
DROP TABLE CepGameSpeeds;
DROP TABLE CepHandicapInfos;
--
DELETE FROM CepWorlds;
DELETE FROM CepGameSpeeds;
DELETE FROM CepHandicapInfos;

CREATE TABLE CepWorlds AS SELECT * FROM Worlds;
CREATE TABLE CepGameSpeeds AS SELECT * FROM GameSpeeds;
CREATE TABLE CepHandicapInfos AS SELECT * FROM HandicapInfos;
INSERT INTO CepWorlds SELECT * FROM Worlds;
INSERT INTO CepGameSpeeds SELECT * FROM GameSpeeds;
INSERT INTO CepHandicapInfos SELECT * FROM HandicapInfos;

UPDATE LoadedFile SET Value=1 WHERE Type='_CEP_End.sql';

0 comments on commit 6919000

Please sign in to comment.