MP issue with Extending Edifbnft.bst (new building types/bonuses)

General Modding Information/Questions; support/discussion/questions

Moderator: thunderchero

Forum rules
:idea: Please search before starting new topic. :idea:
There is a good chance it has already been asked.
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1926
Joined: Sun Apr 27, 2008 2:00 am

Re: All in one 2.0.1 beta 3 available

Post by Spocks-cuddly-tribble »

thunderchero wrote: Sat Apr 30, 2022 10:39 amOffset 0x0228 to 0x022B = + Industry (local static bonus -> missing feature?)
Offset 0x02C4 to 0x02C7 = Industry output total after bonuses
so the systInfo deviations in bonus and output areas are in effective mode section (not UI preview)
thunderchero wrote: Sat Apr 30, 2022 10:39 amOffset 0x0084 to 0x0085 = invested industry
Offset 0x0092 to 0x00A7 unknown (Offset 0x0098 fed industry + bonus joining player -200 from host)
The wiki is outdated. Newest data is here: viewtopic.php?p=54338#p54338

0x98-0x99 first slot invested industry -> some copy of 0x84-0x85 ?

systInfo 0x94-0xA5 looks like a copy of 0x80-0x91? (first preview mode like the other areas?)
Spocks-cuddly-tribble wrote: Sat Apr 30, 2022 9:14 amNew ship bonus code(s) change the system output for bonuses (and later industry) IF [systInfo+80h] (order ID) = 3 (ship under construction)
Maybe patch needs to read for MP: (but would disable shipbonus display fix)?

0x94-0x97 1stBldOrd: first slot build order type, see bldOrd (new)

0043F1CB 807A 34 03 CMP BYTE [EDX+34], 3 // systInfo+80 = order ID

0043F1CB 807A 48 03 CMP BYTE [EDX+48], 3 // systInfo+94 = order ID

in patch code at 0x3E5CD (34) -> 48



But the two questions remain:

- are you willing to live with the risk of hidden MP issues with the MP deviations check removed?

- will AI get new ship bonuses?

Single player with new patch, same turn 1 game, fed AI default +200 bonus vs say +20000 bonus.

If new bonus works for AI it should build more ships with +20000.
Last edited by Spocks-cuddly-tribble on Sat Apr 30, 2022 5:42 pm, edited 1 time in total.
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7934
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: All in one 2.0.1 beta 3 available

Post by thunderchero »

I may have found something,

on vanilla as setup before
plus add/edit
added new edifbnft.bst file
edited fed structure to use % ship industry

I was able to get both static bonus and % bonus working at same time. with correct bonus given and no sync error
I still had old code changes to dis able sync message applied

0x0043b1c 98 00 00 00 -> 34 02 00 00 ; change % ship industry to be stored at same place as utopia

0x018dac2 A8 01 -> B4 00

problem is this patch conflict with my changes in MUM (in My tests this patch is not applied yet)


Code: Select all

trek.exe at 0x43AFA new code 0x39 bytes:

8B 51 50 66 01 50 10 8B 51 54 66 01 50 12 66 8B 91 88 00 00 00 66 01 50 02 8B 51 58 66 01 50 14 8B B1 98 00 00 00 66 01 70 04 8B 51 30 66 01 50 06 90 66 8B 78 16 66 8B 91

asm changes:

004446FA     8B51 50            MOV EDX, [ECX+50]
004446FD     66:0150 10         ADD [EAX+10], DX  // % economic intel
00444701     8B51 54            MOV EDX, [ECX+54]
00444704     66:0150 12         ADD [EAX+12], DX  // % scientific intel

00444713     8B51 58            MOV EDX, [ECX+58]
00444716     66:0150 14         ADD [EAX+14], DX  // % military intel
0044471A     8BB1 98000000      MOV ESI, [ECX+98]
00444720     66:0170 04         ADD [EAX+4], SI  // % raiding
00444724     8B51 30            MOV EDX, [ECX+30]
00444727     66:0150 06         ADD [EAX+6], DX  // % industry
0044472B     90                 NOP

00444730     66:8B91 90000000   MOV DX, [ECX+90]  // % traderoute credits
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1926
Joined: Sun Apr 27, 2008 2:00 am

Re: All in one 2.0.1 beta 3 available

Post by Spocks-cuddly-tribble »

thunderchero wrote: Sat Apr 30, 2022 5:40 pmI was able to get both static bonus and % bonus working at same time. with correct bonus given and no sync error

0x0043b1c 98 00 00 00 -> 34 02 00 00 ; change % ship industry to be stored at same place as utopia
If you mean this default code:

0044471B mov dx, [edx+98h] // 0xC0 / 0x180 + 98h = raiding

It just reads the raiding bonus from systInfo and later adds it to empsInfo.

edx = systinfo+ 0xC0 / 0x180 (depending on preview mode)

if you read [systInfo 0x234 + 0xC0 / 0x180] it just adds random data to vanilla unused empsInfo raiding area.
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7934
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: All in one 2.0.1 beta 3 available

Post by thunderchero »

Spocks-cuddly-tribble wrote: Sat Apr 30, 2022 6:30 pm
thunderchero wrote: Sat Apr 30, 2022 5:40 pmI was able to get both static bonus and % bonus working at same time. with correct bonus given and no sync error

0x0043b1c 98 00 00 00 -> 34 02 00 00 ; change % ship industry to be stored at same place as utopia
If you mean this default code:

0044471B mov dx, [edx+98h] // 0xC0 / 0x180 + 98h = raiding

It just reads the raiding bonus from systInfo and later adds it to empsInfo.

edx = systinfo+ 0xC0 / 0x180 (depending on preview mode)

if you read [systInfo 0x234 + 0xC0 / 0x180] it just adds random data to vanilla unused empsInfo raiding area.
I yield to your superior coding skills :oops:
changing x0043b1c 98 00 00 00 -> 34 02 00 00
really had no effect.
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7934
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: MP issue with Extending Edifbnft.bst (new building types/bonuses)

Post by thunderchero »

Spocks-cuddly-tribble wrote: Sat Apr 30, 2022 5:04 pm Maybe patch needs to read for MP: (but would disable shipbonus display fix)?

0x94-0x97 1stBldOrd: first slot build order type, see bldOrd (new)

0043F1CB 807A 34 03 CMP BYTE [EDX+34], 3 // systInfo+80 = order ID

0043F1CB 807A 48 03 CMP BYTE [EDX+48], 3 // systInfo+94 = order ID

in patch code at 0x3E5CD (34) -> 48
I have only done 1 test on mum
but no sync error but the displayed bonus on gui is given on first build turn then bonus corrects next turn. very strange
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7934
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: MP issue with Extending Edifbnft.bst (new building types/bonuses)

Post by thunderchero »

since 0x3E5CD (34) -> 48 prevents sync error, would it help if this was added someplace else that would not disable display fix?

Or if there is any code you want added for testing
just tell me where and what code and I will use relocation for testing.
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1926
Joined: Sun Apr 27, 2008 2:00 am

Re: MP issue with Extending Edifbnft.bst (new building types/bonuses)

Post by Spocks-cuddly-tribble »

thunderchero wrote: Sun May 01, 2022 12:44 pmsince 0x3E5CD (34) -> 48 prevents sync error, would it help if this was added someplace else that would not disable display fix?

Or if there is any code you want added for testing
just tell me where and what code and I will use relocation for testing.
I'm not certain about the logic of some mechanics.

IF

systInfo 0x80-0x93 = preview mode
and
systInfo 0x94-0xA7 = effective mode

THEN

my patch might need an extra switch depending on mode (still might not work): viewtopic.php?p=32929#p32929

Code: Select all

0043F1CB     807A 34 03           CMP BYTE [EDX+34], 3  // systInfo+80 = order ID
0043F1CF     75 1B                JNZ SHORT 43F1EC  // if not 3 = build ship -> not stored

-> replace with long jump to relocation & nop

E9 XXXXXXXX 90

@ relocation

6B8C24 70010000 14    IMUL ECX,DWORD PTR SS:[ESP+170],14 // mode (0 preview / 1 effective) * 14h to ECX for switch
807C11 34 03          CMP BYTE PTR DS:[ECX+EDX+34],3
JNZ 43F082
JMP 43F1D1
EDIT2: corrected code! Flocke messed up some data here: viewtopic.php?p=54338#p54338
0xA8 = adr player production Queue and more... http://flocke.bplaced.net/botfwiki/inde ... g#systInfo

EDIT: And don't forget to test whether the ship bonuses work for AI :!:


Side Note: The modding index mainly should be for solutions i.e. this working topic fits more in General Modding Information/Questions :wink:

Once we get it to work we will update the main topic with the fix :idea:
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7934
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: MP issue with Extending Edifbnft.bst (new building types/bonuses)

Post by thunderchero »

Spocks-cuddly-tribble wrote: Sun May 01, 2022 2:37 pm my patch might need an extra switch depending on mode (still might not work):
first test looks very good
MP no sync error
ship industry bonus does not apply or display bonus when building structures.
shipbonus display fix working even with power up delay working (on the turn of structure power up it will display new bonus value, but that turn does not get bonus) note; if toggle off then on will reset bonus delay (no bonus that turn)
working using A8 01 and 14 01 settings

here is changes in ida
ok.jpg
ok.jpg (408.67 KiB) Viewed 2196 times
Spocks-cuddly-tribble wrote: Sun May 01, 2022 2:37 pm EDIT: And don't forget to test whether the ship bonuses work for AI :!:
still needs to be tested (not sure how to test AI mainly buys ships, so saved game review I expect would not give any info. other than if structure is built.
Spocks-cuddly-tribble wrote: Sun May 01, 2022 2:37 pm Side Note: The modding index mainly should be for solutions i.e. this working topic fits more in General Modding Information/Questions :wink:

Once we get it to work we will update the main topic with the fix :idea:
agreed.

Edit;
I did some more testing all with positive results so if anyone else want to test here are required files
file removed Code still needs work
test install; vanilla 800 x 600 (any resolution should also work)
extract files
add files in "res file" folder to stbof.res (edifice.bst changes Daystrom Institute to 25% shipbuilding industry) (edifbnft.bst extended benefit list)
use bofpatcher to install "relocation3.patch" first
use bofpatcher to install patches
"Extending_Edifbnft_bst.patch" Extending Edifbnft.bst (new building types/bonuses) MP fix, adds % intel total two-in-one bug & unlock % intel (local) fix % research (local) fix
"production_Bonus_Popup_2%.patch" adds improved popups in production screen (optional)
"production_food_energy_deficit_warning_2%.patch" for AI building behavior, the auto-build feature & food/energy deficit warning?: (optional)

start new t5 game so structures will be available.
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1926
Joined: Sun Apr 27, 2008 2:00 am

Re: MP issue with Extending Edifbnft.bst (new building types/bonuses)

Post by Spocks-cuddly-tribble »

thunderchero wrote: Sun May 01, 2022 3:51 pmI did some more testing all with positive results
Very nice! This explains the missing data logic in systInfo. I'll post the updated info and adr corrections for Flocke.

The main patch will be optimized without need of relocation code (soon).

This just leaves the AI question.


thunderchero wrote: Sun May 01, 2022 3:51 pmif toggle off then on will reset bonus delay (no bonus that turn)
I don't get 'Bonus delay'. Increased industry should be added to 'industry invested' between turns.

Is this a new bug or just a part of the old display bugs?
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).
When adding/removing ship to/from Build Queue just use e.g. arrow key left/right to update industry output display.
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7934
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: MP issue with Extending Edifbnft.bst (new building types/bonuses)

Post by thunderchero »

Spocks-cuddly-tribble wrote: Sun May 01, 2022 6:06 pm
thunderchero wrote: Sun May 01, 2022 3:51 pmif toggle off then on will reset bonus delay (no bonus that turn)
I don't get 'Bonus delay'. Increased industry should be added to 'industry invested' between turns.

Is this a new bug or just a part of the old display bugs?
when i first noticed it I thought about orbital batteries
when powering up an OB middle of a turn you get no benefit that turn,
but on next turn when OB had power during turn process you get the benefit.

same thing with % ship industry and static ship industry
if you power it up in the middle of a turn no bonus that turn (it must have power during turn process) mid-turn will still show what industry will be but only apply industry without bonuses that turn
so if it is already powered do not turn off then back on or turn delay happens.
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1926
Joined: Sun Apr 27, 2008 2:00 am

Re: MP issue with Extending Edifbnft.bst (new building types/bonuses)

Post by Spocks-cuddly-tribble »

thunderchero wrote: Sun May 01, 2022 6:36 pmif you power it up in the middle of a turn no bonus that turn (it must have power during turn process) mid-turn will still show what industry will be but only apply industry without bonuses that turn
But this does not happen with old utopia code?

It might be a bug in the main patch.
Last edited by Spocks-cuddly-tribble on Sun May 01, 2022 6:52 pm, edited 1 time in total.
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7934
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: MP issue with Extending Edifbnft.bst (new building types/bonuses)

Post by thunderchero »

Spocks-cuddly-tribble wrote: Sun May 01, 2022 6:46 pm
thunderchero wrote: Sun May 01, 2022 6:36 pmif you power it up in the middle of a turn no bonus that turn (it must have power during turn process) mid-turn will still show what industry will be but only apply industry without bonuses that turn
But this does not happen with old utopia code?
correct just tested vanilla code and utopia give bonus on same turn as power up

edit
before latest changes it also gave bonus on same turn as power up
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1926
Joined: Sun Apr 27, 2008 2:00 am

Re: MP issue with Extending Edifbnft.bst (new building types/bonuses)

Post by Spocks-cuddly-tribble »

thunderchero wrote: Sun May 01, 2022 6:51 pmcorrect just tested vanilla code and utopia give bonus on same turn as power up

edit
before latest changes it also gave bonus on same turn as power up
Very strange. Maybe we still misinterpret systInfo +80 vs +94 :?:

You might try this extra code, but I don't think it will solve issue:

Code: Select all

0043F1E4     0FB70E               MOVZX ECX, WORD [ESI]
0043F1E7     0FAFD1               imul  edx, ecx

-> replace with long jump to relocation loc 2 & nop

E9 XXXXXXXX 90

@ relocation area 2

mov     ecx, [esp+168h]
imul    edx, ecx
JMP 43F1EA
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7934
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: MP issue with Extending Edifbnft.bst (new building types/bonuses)

Post by thunderchero »

Spocks-cuddly-tribble wrote: Sun May 01, 2022 7:34 pm You might try this extra code, but I don't think it will solve issue:

Code: Select all

0043F1E4     0FB70E               MOVZX ECX, WORD [ESI]
0043F1E7     0FAFD1               imul  edx, ecx

-> replace with long jump to relocation loc 2 & nop

E9 XXXXXXXX 90

@ relocation area 2

mov     ecx, [esp+168h]
imul    edx, ecx
JMP 43F1EA
no change
here is new code flow
flow.jpg
flow.jpg (403.12 KiB) Viewed 2126 times
if you want to check my work

Edit;
just for info I checked the vanilla sysinfo file and found maybe some new info

both files matched host and join player files (expected)
Offset 0x02C4 to 0x02C7 = Industry output total after bonuses ; wrong, this industry before bonus (1539 credits)
Offset 0x0084 to 0x0085 = invested industry ; correct (1739 credits)
Offset 0x0092 to 0x00A7 unknown (Offset 0x0098 fed industry + bonus joining player -200 from host) ; correct (1739 credits)

your original patch was setting Offset 0x02C4 to 0x02C7 wrong?
If you want I can double check results
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1926
Joined: Sun Apr 27, 2008 2:00 am

Re: MP issue with Extending Edifbnft.bst (new building types/bonuses)

Post by Spocks-cuddly-tribble »

thunderchero wrote: Sun May 01, 2022 7:53 pmno change
It reads just a copy of the same data. Sorry for wasting your time.

thunderchero wrote: Sun May 01, 2022 7:53 pmvanilla sysinfo file

Offset 0x02C4 to 0x02C7 = Industry output total after bonuses ; wrong, this industry before bonus (1539 credits)
As told Vanilla utopia is not a real system output bonus (not added to industry), but some workaround implementation with many preview and GUI bugs.

thunderchero wrote: Sun May 01, 2022 7:53 pmyour original patch was setting Offset 0x02C4 to 0x02C7 wrong?
It adds ship bonuses as real system bonuses, but causes a MP deviation in 'effective mode' bonus area due to reading 'preview mode' ship data (GUI inputs/displays) for both modes, which prevents the one turn delay.

I did not consider that the missing preview data of other MP players could cause a deviation (to a sync check my exploit patch looks like cheating).

As told a MP fix (without one turn delay) needs to read data from ordInfo instead of preview mode (too complicated).

If that's right, the original patch prevented the delay for player but might not work for AI (I'm not sure AI uses preview data).

Also now there should be the same one turn delay when adding a ship and previous build was not a ship?
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
Post Reply

Return to “General Modding Information/Questions”