Pazyryk
Deity
- Joined
- Jun 13, 2008
- Messages
- 3,584
Hard-coded table items used in the dll play hell with modders that do a lot of table changes, particularly total conversion modders. Knowing what is and isn't hard-coded is important whether you are a dll or non-dll modder.
Many items are hard-coded as enums in the dll. But in most cases these enums are never used so it is safe to change corresponding table items (just remember to use, for example, GameInfoTypes.IMPROVEMENT_FARM rather than ImprovementTypes.IMPROVEMENT_FARM if you modify the Improvements table). When these enums are used in dll, then it is important that your table IDs match the corresponding enum integer used in dll.
In other cases, the dll doesn't use an enum but instead uses the actual type string (e.g., "UNIT_WORKER"). In these cases, table ID doesn't matter but you do need the exact matching type string for the dll to recognize it.
I've listed hard-coding cases below and which situation (above) applies. This is not guarantied to be complete. Please post if you know of items that should be added.
Hard-coded in dll by table ID integer mad: The worst kind because you won't find in dll source by text search)
Builds
14 (BUILD_REMOVE_JUNGLE) --these 4 in CvUnitMission:ushMission, look for "// todo: future proof this"
15 (BUILD_REMOVE_FOREST) --you have to recode dll or else avoid changing these 4 table IDs
16 (BUILD_REMOVE_MARSH)
17 (BUILD_SCRUB_FALLOUT)
Hard-coded enums actually used in dll (Your table ID must match base to work properly. Don't delete and don't change IDs!)
FEATURE_<ICE thru FALLOUT> (ID 0-6) --these are hard-coded in many places (including the graphics engine)
YIELD_ ...
TERRAIN_ ...
PLOT_ ...
ROUTE_ ...
DOMAIN_ ...
UNITAI_ ...
MINOR_CIV_TRAIT_ ... --note name inconsistency with table: MINOR_CIV_TRAIT_RELIGIOUS vs. MINOR_TRAIT_RELIGIOUS
Notes: Many more enums are defined in dll and passed to Lua, but can be safely ignored as long as you always use GameInfoTypes rather than the type-specific identifiers (e.g., BeliefTypes, ImprovementTypes, etc.). For enums that are used in dll, don't screw up corresponding table IDs by deleting! However, you can in some cases add to these tables. For example, I add several new minor civ traits that have effects only on the Lua side. The dll only checks for the types that it knows when applying trait effects, and safely skips over new ones.
Hard-coded by table Type string (Table ID doesn't matter, but exact Type string does. Most of these can be deleted, but their presence in this table should worry you enough to investigate further.)
Buildings
"BUILDING_WRITERS_GUILD" --next 3 in CvEconomicAI
"BUILDING_ARTISTS_GUILD"
"BUILDING_MUSICIANS_GUILD"
"BUILDING_BROADCAST_TOWER" --in CvCultureClasses
Features (note: also above so that section's more restrictive warnings apply)
"FEATURE_JUNGLE" --same CvUnitMission:ushMission code that used Builds IDs above
"FEATURE_FOREST"
"FEATURE_MARSH"
"FEATURE_FALLOUT"
Units
"UNIT_WORKER" --many references in AI code (note: renamed worker units mostly do work; but some AI logic missing)
"UNIT_WRITER" -- next 3 in CvPlayerTraits::ChooseMayaBoost only (safe to remove if you don't use Maya trait)
"UNIT_MUSICIAN"
"UNIT_GREAT_ADMIRAL"
"UNIT_ENGINEER" -- next 4 in ChooseMayaBoost and also in CvPlayerAI
"UNIT_GREAT_GENERAL"
"UNIT_ARTIST"
"UNIT_MERCHANT"
"UNIT_SCIENTIST"
"UNIT_PROPHET" -- in ChooseMayaBoost and in CvReligionClasses
"UNIT_INQUISITOR" -- next 2 in CvReligionClasses
"UNIT_MISSIONARY" --(note from personal experience: will CTD if you don't have this unit and enhance a religion!)
"UNIT_CARAVAN" --these 2 in CvTradeClasses
"UNIT_CARGO_SHIP"
"UNIT_JAPANESE_SAMURAI" --in CvUnit
"UNIT_ARCHAEOLOGIST" --in CvEconomicAI
Others used in many instances
"AICITYSTRATEGY_ ..."
"ECONOMICAISTRATEGY_ ..."
"MILITARYAISTRATEGY_ ..."
Note: I'm skipping all references that are used only for achievements.
List above is for BNW dll. Note that four features are listed in both section 2 and 3. That means that if you change IDs for these, parts of the dll will be OK with the ID change (section 3) but other parts will be screwed up (section 2). In other words, it will be screwed up.
This is really just a starting point in figuring out if you can safely delete a unit, or supply a different unit that is supposed to have some base functionality (e.g., worker). For example, it's perfectly safe to delete UNIT_JAPANESE_SAMURAI. On the other hand, if you delete UNIT_MISSIONARY, then you will get a CTD if/when you use Lua to enhance a religion. My own mod has >1 worker units ("workers" and "slaves" for 3 fantasy races) and these mostly work in unmodded dll despite references. But some AI logic (like scrapping) is missing, so proper implementation requires some dll re-coding. Non-dll modders have to carefully step around these issues.
Many items are hard-coded as enums in the dll. But in most cases these enums are never used so it is safe to change corresponding table items (just remember to use, for example, GameInfoTypes.IMPROVEMENT_FARM rather than ImprovementTypes.IMPROVEMENT_FARM if you modify the Improvements table). When these enums are used in dll, then it is important that your table IDs match the corresponding enum integer used in dll.
In other cases, the dll doesn't use an enum but instead uses the actual type string (e.g., "UNIT_WORKER"). In these cases, table ID doesn't matter but you do need the exact matching type string for the dll to recognize it.
I've listed hard-coding cases below and which situation (above) applies. This is not guarantied to be complete. Please post if you know of items that should be added.
Hard-coded in dll by table ID integer mad: The worst kind because you won't find in dll source by text search)
Builds
14 (BUILD_REMOVE_JUNGLE) --these 4 in CvUnitMission:ushMission, look for "// todo: future proof this"
15 (BUILD_REMOVE_FOREST) --you have to recode dll or else avoid changing these 4 table IDs
16 (BUILD_REMOVE_MARSH)
17 (BUILD_SCRUB_FALLOUT)
Hard-coded enums actually used in dll (Your table ID must match base to work properly. Don't delete and don't change IDs!)
FEATURE_<ICE thru FALLOUT> (ID 0-6) --these are hard-coded in many places (including the graphics engine)
YIELD_ ...
TERRAIN_ ...
PLOT_ ...
ROUTE_ ...
DOMAIN_ ...
UNITAI_ ...
MINOR_CIV_TRAIT_ ... --note name inconsistency with table: MINOR_CIV_TRAIT_RELIGIOUS vs. MINOR_TRAIT_RELIGIOUS
Notes: Many more enums are defined in dll and passed to Lua, but can be safely ignored as long as you always use GameInfoTypes rather than the type-specific identifiers (e.g., BeliefTypes, ImprovementTypes, etc.). For enums that are used in dll, don't screw up corresponding table IDs by deleting! However, you can in some cases add to these tables. For example, I add several new minor civ traits that have effects only on the Lua side. The dll only checks for the types that it knows when applying trait effects, and safely skips over new ones.
Hard-coded by table Type string (Table ID doesn't matter, but exact Type string does. Most of these can be deleted, but their presence in this table should worry you enough to investigate further.)
Buildings
"BUILDING_WRITERS_GUILD" --next 3 in CvEconomicAI
"BUILDING_ARTISTS_GUILD"
"BUILDING_MUSICIANS_GUILD"
"BUILDING_BROADCAST_TOWER" --in CvCultureClasses
Features (note: also above so that section's more restrictive warnings apply)
"FEATURE_JUNGLE" --same CvUnitMission:ushMission code that used Builds IDs above
"FEATURE_FOREST"
"FEATURE_MARSH"
"FEATURE_FALLOUT"
Units
"UNIT_WORKER" --many references in AI code (note: renamed worker units mostly do work; but some AI logic missing)
"UNIT_WRITER" -- next 3 in CvPlayerTraits::ChooseMayaBoost only (safe to remove if you don't use Maya trait)
"UNIT_MUSICIAN"
"UNIT_GREAT_ADMIRAL"
"UNIT_ENGINEER" -- next 4 in ChooseMayaBoost and also in CvPlayerAI
"UNIT_GREAT_GENERAL"
"UNIT_ARTIST"
"UNIT_MERCHANT"
"UNIT_SCIENTIST"
"UNIT_PROPHET" -- in ChooseMayaBoost and in CvReligionClasses
"UNIT_INQUISITOR" -- next 2 in CvReligionClasses
"UNIT_MISSIONARY" --(note from personal experience: will CTD if you don't have this unit and enhance a religion!)
"UNIT_CARAVAN" --these 2 in CvTradeClasses
"UNIT_CARGO_SHIP"
"UNIT_JAPANESE_SAMURAI" --in CvUnit
"UNIT_ARCHAEOLOGIST" --in CvEconomicAI
Others used in many instances
"AICITYSTRATEGY_ ..."
"ECONOMICAISTRATEGY_ ..."
"MILITARYAISTRATEGY_ ..."
Note: I'm skipping all references that are used only for achievements.
List above is for BNW dll. Note that four features are listed in both section 2 and 3. That means that if you change IDs for these, parts of the dll will be OK with the ID change (section 3) but other parts will be screwed up (section 2). In other words, it will be screwed up.
This is really just a starting point in figuring out if you can safely delete a unit, or supply a different unit that is supposed to have some base functionality (e.g., worker). For example, it's perfectly safe to delete UNIT_JAPANESE_SAMURAI. On the other hand, if you delete UNIT_MISSIONARY, then you will get a CTD if/when you use Lua to enhance a religion. My own mod has >1 worker units ("workers" and "slaves" for 3 fantasy races) and these mostly work in unmodded dll despite references. But some AI logic (like scrapping) is missing, so proper implementation requires some dll re-coding. Non-dll modders have to carefully step around these issues.