The subroutines controlling upgrades start at asm offset 488B2C (prefixed Game_Upgrade in the Standard IDA DB). These subroutines use tables of data starting at asm offset 590FE8.
Here's what the upgrade table for farms looks like when nicely formatted (asm offset 590FE8):
Code: Select all
c f h k r
/==========================
tech1 | 98 144 190 236 282
tech2 | 99 145 191 237 283
tech3 | 100 146 192 238 284
tech4 | 101 147 193 239 285
tech5 | 102 148 194 240 286
tech6 | 103 149 195 241 287
tech7 | 104 150 196 242 288
tech8 | 105 151 197 243 289
tech9 | 106 152 198 244 290
Following that, there are similar tables for industry, energy, research, and intel (in that order).
There is also an upgrade table for scanners at asm 005911AA:
Code: Select all
12, 13, 24, 14
The subroutines use this data to determine which structures can be upgraded from others. The subroutines are hardcoded to only work with those tables, so adding additional upgradeable building types cannot yet be supported.
My idea is to scrap this system, and totally rewrite those functions to read in the upgrade tables from a new file in STBOF.RES. That way, we can have upgradeable energy structures (like Type 2 Shields, etc.), more scanner types, and maybe even Future Tech farms... the sky is the limit!
I've fully figured out the signatures all the upgrade functions:
Code: Select all
00489984 ; int Game_Upgrade_GetBuildingID(int techLevel, int buildingType)
; Returns the building ID for a given tech level and building type.
004893DC ; int Game_Upgrade_GetUpgradedBuildingID(int buildingId, int buildingType)
; Returns the building ID for the upgraded version of the building with given ID and type.
00488B2C ; int Game_Upgrade_CompareBuildingTechLevels(int buildingId1, int buildingId2, int buildingType)
; returns 1 if buildingId1 has higher tech level than buildingId2
; returns 0 if they have same tech level
; return -1 if buildingId1 has lower tech level than buildingId2
If successful, this should allow for some serious mods