The next limit for new building outputs is the bonus area in systInfo (default 48 slots, 45 used) resp. the corresponding address-map in trek.exe (default 45 slots).
Note that the systInfo bonus area is an empire-only feature, thus e.g. local military outputs like OBs are unneeded since not loaded from there due to the minor & rebel system issue. Also output slots for unrest orders and trade goods can be cleaned up, because they are no real buildings (exception AI trade goods bug).
Below patch decreases trek.exe address-map entry size from 4 to 2 bytes (i.e. 90 slots).
Additionaly, it features a switch marker for outputs not to store in systInfo resp. for ship construction only.
It comes in two versions:
Without output preview of partially scrapped main buildings (vanilla default)
Code: Select all
>> 0x3E42B 80
<< 0x3E42B 78
>> 0x3E5A7 BF D1 69 D2 28 03 00 00 A1 C8 36 5A 00 8A 44 02 4C 25 FF 00 00 00 66 8B 94 45 86 00 00 00 31 C0 8A 45 72 8B AC 24 74 01 00 00 8B 04 85 6C FC 58 00 01 E8 8B 8C 24 68 01 00 00 81 E2 FF FF
<< 0x3E5A7 B6 5D 72 66 8B 1C 5D 6C FC 58 00 80 FF 01 7F 35 7C 12 8B 01 33 D2 E8 9E 22 00 00 80 B9 7C 02 00 00 00 74 21 0F B6 C3 03 84 24 74 01 00 00 8B 51 4C 66 8B 94 55 86 00 00 00 8B 8C 24 68 01
#0043F028 8B8C24 78010000 MOV ECX, [ESP+178] // systInfo entry
#0043F1A6 0FB65D 72 MOVZX EBX,BYTE [EBP+72] // building output ID
#0043F1AA 66:8B1C5D 6CFC5800 MOV BX,WORD [EBX*2+58FC6C] // bonus position in systInfo
#0043F1B2 80FF 01 CMP BH,1 // if switch marker...
#0043F1B5 7F 35 JG SHORT 43F1EC // 2+ -> not stored
#0043F1B7 7C 12 JL SHORT 43F1CB // 0 -> store
#0043F1B9 8B01 MOV EAX,[ECX] // system ID
#0043F1BB 33D2 XOR EDX,EDX
#0043F1BD E8 9E220000 CALL 441460 // check ordInfo for build ship order in system
#0043F1C2 80B9 7C020000 00 CMP BYTE [ECX+27C],0 // if not build ship...
#0043F1C9 74 21 JE SHORT 43F1EC // ...not stored
#0043F1CB 0FB6C3 MOVZX EAX,BL
#0043F1CE 038424 74010000 ADD EAX,[ESP+174] // systInfo bonus/modus area
#0043F1D5 8B51 4C MOV EDX,[ECX+4C] // system owner ID
#0043F1D8 66:8B9455 86000000 MOV DX,[EBP+EDX*2+86] // edifice.bst building output
#0043F1E0 8B8C24 68010000 MOV ECX,[ESP+168]// number of 'not scrapped' buildings
With output preview of partially scrapped main buildings.
Partially scrapped main structures can remain active until the next turn! Might fix this output preview glitch:
viewtopic.php?p=48408#p48408
Code: Select all
>> 0x3E42B 80
<< 0x3E42B 78
>> 0x3E5A7 BF D1 69 D2 28 03 00 00 A1 C8 36 5A 00 8A 44 02 4C 25 FF 00 00 00 66 8B 94 45 86 00 00 00 31 C0 8A 45 72 8B AC 24 74 01 00 00 8B 04 85 6C FC 58 00 01 E8 8B 8C 24 68 01 00 00 81 E2 FF FF 00 00
<< 0x3E5A7 B6 5D 72 66 8B 1C 5D 6C FC 58 00 80 FF 01 7F 35 7C 12 8B 01 33 D2 E8 9E 22 00 00 80 B9 7C 02 00 00 00 74 21 0F B6 C3 03 84 24 74 01 00 00 8B 51 4C 66 8B 94 55 86 00 00 00 0F B7 0E 90 90 90 90
#0043F028 8B8C24 78010000 MOV ECX,[ESP+178] // systInfo entry
#0043F1A6 0FB65D 72 MOVZX EBX,BYTE[EBP+72] // building output ID
#0043F1AA 66:8B1C5D 6CFC5800 MOV BX,WORD[EBX*2+58FC6C] // bonus position in systInfo
#0043F1B2 80FF 01 CMP BH,1 // if switch marker...
#0043F1B5 7F 35 JG SHORT 43F1EC // 2+ -> not stored
#0043F1B7 7C 12 JL SHORT 43F1CB // 0 -> store
#0043F1B9 8B01 MOV EAX,[ECX] // system ID
#0043F1BB 33D2 XOR EDX,EDX
#0043F1BD E8 9E220000 CALL 441460 // check ordInfo for build ship order in system
#0043F1C2 80B9 7C020000 00 CMP BYTE[ECX+27C],0 // if not build ship...
#0043F1C9 74 21 JE SHORT 43F1EC ...not stored
#0043F1CB 0FB6C3 MOVZX EAX,BL
#0043F1CE 038424 74010000 ADD EAX,[ESP+174] // systInfo bonus/modus area
#0043F1D5 8B51 4C MOV EDX,[ECX+4C] // system owner ID
#0043F1D8 66:8B9455 86000000 MOV DX,[EBP+EDX*2+86] // edifice.bst building output
#0043F1E0 0FB70E MOVZX ECX,WORD[ESI] // number of buildings
#0043F1E3 90909090 NOP
Next is an adapted and cleaned up vanilla address-map (unneeded outputs get ignored, local morale bonuses share address[+8C]). It also unlocks the unused local static industry bonus for output ID 45 /0x2D i.e. new entry 46 in edifbnft.bst should be " Industry" (strings without % start with a space) and local "% Shipbuilding" for output ID 0x2E i.e. new entry 47.
Note: Albeit the
shipbuilding bonus preview-bug has been fixed (i.e. preview screen shows updated industry output when turning on/off building (or scrapping), there is still the
Build Queue update bug i.e. old bonuses until re-entering screen or changing worker/energy settings (cf. 'Dilithium Shortage' warning).
Code: Select all
trek.exe 0x18DA6C new address-map 0xB4 bytes:
00 00 04 00 08 00 0C 00 FF 02 28 00 2C 00 18 00 1C 00 20 00 38 00 40 00 44 00 10 00 14 00 48 00 FF 02 FF 02 FF 02 FF 02 8C 00 B8 00 60 00 64 00 68 00 6C 00 70 00 4C 00 74 00 78 00 B0 00 7C 00 AC 00 80 00 3C 00 50 00 FF 02 94 00 A4 00 98 00 88 00 90 00 A0 00 A8 01 BC 00 A8 00 14 01 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02
First byte of each entry is postion (unsigned) second byte the switch marker (signed): 0=store, 1=for ship construction only, 2=ignore. Ignored output types use FF 02 with the FF being pointless.
Output indexes are same as in edifbnft.bst (see above) i.e. entry postion = output ID * 2.
A How-To example: Adding a % Shipbuilding bonus to shipyards
In edifbnft.bst " Builds Ships" is entry 19 (i.e. ID 18 /0x12, since entry 1 is ID 0).
-> at 0x18DA6C +2*0x12 -> default FF 02 (ignored, since unused) former: 5C
-> systInfo bonus area +C0/+180h (see above link) +5C = 11C resp. 1DC
- systInfo wiki info:
Offset 0x011C to 0x011F = Builds Ships (i.e. yard output value -> unused)
Offset 0x01DC to 0x01DF = Builds Ships (i.e. yard output value -> unused)
Offset 0x00D4 to 0x00D7 = +% industry
Offset 0x0194 to 0x0197 = +% industry
-> D4/194h minus C0/180h = +14h
I.e. replacing the above default FF 02 with 14 01 (using the new switch marker) does the job.
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.