Flagship/heroship code changes

Flagship Mod; showcase and support/discussion/questions/suggestions/reviews

Moderator: thunderchero

User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7940
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: Flagship/heroship code changes

Post by thunderchero »

Spocks-cuddly-tribble wrote: Tue Apr 02, 2024 12:44 pm 'build minor ships' needs an extra variant, but all should be quite easy. :wink:
Flocke wrote: Tue Apr 02, 2024 5:52 pm I had a look and I'm not excited. Already now this patch is a mess! :lol:
with the code conflict between "buildable minor ships (major code modification)" it will need extra variant for "buildable minor ships (major code modification)"
Flocke wrote: Tue Apr 02, 2024 5:52 pm So just keep above code change and if it proofs to be a great change, at some later time we will see how to deal with it. :wink:
I suggest treat it like we did "structures above tech 10" and instruct users to uninstall patch before editing with UE. until we see what happens.

I did do a few more test game, none were ever built. I did have a few where hero ships were missing, but one edo was very close to home and others were at war and expect they were lost in combat.

here is patch I made for "protect Hero ships from destruction and theft via intel attacks:"

Code: Select all

NAME: Hero ships Intel protection
AUTHOR: Spocks-cuddly-tribble  
DESC: this patch will protect Hero ships from being stolen or destroyed due to intel
DESC: patch file name: hero_ship_protect.patch
URL: https://www.armadafleetcommand.com/onscreen/botf/viewtopic.php?p=61811#p61811
TAG: enhancement
 
# >>  = vanilla/original value

# <<  = new value

>> 0x00049127 31 c0 89 e2 8a 43 52 e8 8d 5c 02 00 8b 44 24 66 8b 94 24 98 01 00 00 c1 f8 10 39 d0 75

<< 0x00049127 8b d4 8a 43 52 e8 8f 5c 02 00 8a 44 24 68 3a 84 24 98 01 00 00 75 25 80 7c 24 64 ff 74

#protect Hero ships from destruction and theft via intel attacks:
#00449D27     8BD4              MOV EDX,ESP
#00449D29     8A43 52           MOV AL,BYTE PTR DS:[EBX+52]
#00449D2C     E8 8F5C0200       CALL trek.0046F9C0
#00449D31     8A4424 68         MOV AL,BYTE PTR SS:[ESP+68]
#00449D35     3A8424 98010000   CMP AL,BYTE PTR SS:[ESP+198]
#00449D3C     75 25             JNZ SHORT trek.00449D63
#00449D3E     807C24 64 FF      CMP BYTE PTR SS:[ESP+64],0FF  // Hero ship ?
#00449D43     74 1E             JE SHORT trek.00449D63
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1939
Joined: Sun Apr 27, 2008 2:00 am

Re: Flagship/heroship code changes

Post by Spocks-cuddly-tribble »

thunderchero wrote: Tue Apr 02, 2024 6:26 pmcode conflict between "buildable minor ships (major code modification)" it will need extra variant for "buildable minor ships"
I didn't check on this, but Flocke said there is no conflict (just a pointless UE check he might remove). :wink:
thunderchero wrote: Tue Apr 02, 2024 6:26 pmhere is patch I made for "protect Hero ships from destruction and theft via intel attacks:"
I'd add this as part of the main patch (we have already way to many patches). :idea:

Hence my upcoming combined multi patch with all new building output types (is working now). This should help with the patching madness. :mad:
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: 7940
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: Flagship/heroship code changes

Post by thunderchero »

Spocks-cuddly-tribble wrote: Tue Apr 02, 2024 6:40 pm
thunderchero wrote: Tue Apr 02, 2024 6:26 pmcode conflict between "buildable minor ships (major code modification)" it will need extra variant for "buildable minor ships"
I didn't check on this, but Flocke said there is no conflict (just a pointless UE check he might remove). :wink:
it think it would need some kind of patch, in my tests if "buildable minor ships (major code modification)" added by UE then patch with current change patch shows conflict (see image -- = UE changes << = patch changes)
build.jpg
build.jpg (58.02 KiB) Viewed 185 times
If i install patch anyway (not suggested) crash when entering build screen
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1939
Joined: Sun Apr 27, 2008 2:00 am

Re: Flagship/heroship code changes

Post by Spocks-cuddly-tribble »

In this case Flocke meant the modified code sequence is unchanged, but relocaded in the 'minor ships' patch.

Means we need to create two variants of the Hero ships patch (with/without minor ships). I'll install 'minor ships' and edit trek.exe with OllyDbg for that.

Is this code still valid?: viewtopic.php?p=11328#p11328
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: 7940
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: Flagship/heroship code changes

Post by thunderchero »

Spocks-cuddly-tribble wrote: Tue Apr 02, 2024 7:50 pm Is this code still valid?: viewtopic.php?p=11328#p11328
I expect so, but here is patch created of current changes "buildable minor ships (major code modification)"
build_minor_ships.patch
(1.8 KiB) Downloaded 2 times
note # special ship structure was MUM change :wink:
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1939
Joined: Sun Apr 27, 2008 2:00 am

Re: Flagship/heroship code changes

Post by Spocks-cuddly-tribble »

thunderchero wrote: Tue Apr 02, 2024 7:53 pmI expect so, but here is patch created of current changes "buildable minor ships (major code modification)"
In this case we need to replace this part of "buildable minor ships (major code modification)":
AUTO:004F3DD7                 mov     bx, [ecx+4]
AUTO:004F3DDB                 xor     eax, eax
AUTO:004F3DDD                 mov     edx, esp
AUTO:004F3DDF                 mov     al, bl
AUTO:004F3DE1                 call    sub_46F9C0
AUTO:004F3DE6                 mov     edx, [esp+148h+var_E0]
AUTO:004F3DEA                 cmp     dx, 6
AUTO:004F3DEE                 jz      short loc_4F3E2A
AUTO:004F3DF0                 cmp     dx, 7
with:
MOV EBX,DWORD PTR DS:[ECX+4]
MOV EDX,ESP
MOV AL,BL
CALL 46F9C0
MOV AL,BYTE PTR SS:[ESP+68]
CMP AL,6
JE SHORT 4F3E2A
CMP AL,7
JE SHORT 4F3E2A
CMP BYTE PTR SS:[ESP+64],0FF
The updated "buildable minor ships (major code modification)" patch will replace this part in the second variant of the Hero ships patch:

Code: Select all

004F3DAD     8B59 04        MOV EBX,DWORD PTR DS:[ECX+4]
004F3DB0     8BD4           MOV EDX,ESP
004F3DB2     8AC3           MOV AL,BL
004F3DB4     E8 07BCF7FF    CALL trek.0046F9C0
004F3DB9     8A4424 68      MOV AL,BYTE PTR SS:[ESP+68]
004F3DBD     3C 06          CMP AL,6
004F3DBF     74 5E          JE SHORT trek.004F3E1F
004F3DC1     3C 07          CMP AL,7
004F3DC3     74 5A          JE SHORT trek.004F3E1F
004F3DC5     807C24 64 FF   CMP BYTE PTR SS:[ESP+64],0FF  // Hero ship ?
thunderchero wrote: Tue Apr 02, 2024 7:53 pmnote # special ship structure was MUM change :wink:
Vanilla utopia has three features (+X industry for ship construction, player special ships and extra morale)

This is build queue special code for ship industry bonus (new output types & fixes skip this code anyway, so pointless in MUM). :wink:
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: 7940
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: Flagship/heroship code changes

Post by thunderchero »

Here is new patch with options

Code: Select all

NAME: Hero ships with "buildable minor ships (major code modification)" already applied 
AUTHOR: Spocks-cuddly-tribble  
DESC: OPTION; buildable minor ships option just switch lines with and without # 
DESC: OPTION; Hero ships Intel protection remove # to add 
DESC: this patch will give a Hero ship as starting ships. the hero ship is not buildable by human or AI 
DESC: hero ships must be added to shiplist with UE and given special marker at +64h 00 -> FF
DESC: WARNING!!!! this patch must be edited to match the shiplist id's of hero ships
DESC: patch file name: hero_ship_build.patch
URL: https://www.armadafleetcommand.com/onscreen/botf/viewtopic.php?p=61800#p61800
TAG: enhancement
 
# >>  = vanilla/original value

# <<  = new value

#Hero ships Intel protection remove # to add
#protect Hero ships from destruction and theft via intel attacks: option
#>> 0x00049127 31 c0 89 e2 8a 43 52 e8 8d 5c 02 00 8b 44 24 66 8b 94 24 98 01 00 00 c1 f8 10 39 d0 75
#<< 0x00049127 8b d4 8a 43 52 e8 8f 5c 02 00 8a 44 24 68 3a 84 24 98 01 00 00 75 25 80 7c 24 64 ff 74

#protect Hero ships from destruction and theft via intel attacks:
#00449D27     8BD4              MOV EDX,ESP
#00449D29     8A43 52           MOV AL,BYTE PTR DS:[EBX+52]
#00449D2C     E8 8F5C0200       CALL trek.0046F9C0
#00449D31     8A4424 68         MOV AL,BYTE PTR SS:[ESP+68]
#00449D35     3A8424 98010000   CMP AL,BYTE PTR SS:[ESP+198]
#00449D3C     75 25             JNZ SHORT trek.00449D63
#00449D3E     807C24 64 FF      CMP BYTE PTR SS:[ESP+64],0FF  // Hero ship ?
#00449D43     74 1E             JE SHORT trek.00449D63

#buildable minor ships option just switch lines with and without #
#vanilla player build ship UI 
#"buildable minor ships (major code modification)" already applied
>> 0x000f31d7 66 8b 59 04 31 c0 89 e2 88 d8 e8 da bb f7 ff 8b 54 24 68 66 83 fa 06 74 3a 66 83 fa 07
<< 0x000f31d7 8b 59 04 8b d4 8a c3 e8 dd bb f7 ff 8a 44 24 68 3c 06 74 3f 3c 07 74 3b 80 7c 24 64 ff

#vanilla player build ship UI 
#"buildable minor ships (major code modification)" not applied
#>> 0x000f31ad 66 8b 59 04 31 c0 89 e2 88 d8 e8 04 bc f7 ff 8b 54 24 68 66 83 fa 06 74 59 66 83 fa 07
#<< 0x000f31ad 8b 59 04 8b d4 8a c3 e8 07 bc f7 ff 8a 44 24 68 3c 06 74 5e 3c 07 74 5a 80 7c 24 64 ff

>> 0x00054759 8b 44
>> 0x0005475c 66 0f bf 11 c1 f8 10 39 d0 74 0f 7d 11
>> 0x00054776 31 d0

<< 0x00054759 80 7c
<< 0x0005475c 64 ff 74 1a 8a 44 24 68 3a 01 74 0e 90
<< 0x00054776 33 c0

>> 0x0005012b 0f 8e ae 02 00 00
>> 0x0005015b 0f 85 2f 02 00 00
>> 0x00050390 83 fa 04 0f 85 
>> 0x00050395 dc fd ff ff 8b 
>> 0x0005039a 80 e8 1a 5b 00 
>> 0x0005039f e8 7c a3 0c 00 
>> 0x000503a4 83 f8 01 e9 c9 
>> 0x000503a9 fd ff ff 83 fa 04
>> 0x000503b0 85 24 fe ff ff ba 01 00 00 00 e8 f1 44 00 00 0f bf d0 83 fa ff 0f 84 0e fe ff ff

<< 0x0005012b 90 90 90 90 90 90
<< 0x0005015b 75 18 90 90 90 90

#sorted by empire 0-4 each for starting level 0-4)I.e. cardassian 1-5, federation 1-5,.. 
#You can use same IDs for different levels if you want.
#cardassian 1-5
<< 0x00050390 00 00 00 00 00 
#federation 1-5
<< 0x00050395 15 15 15 15 15 
#ferengi 1-5
<< 0x0005039a 2f 2f 2f 2f 2f 
#klingon 1-5
<< 0x0005039f 44 44 44 44 44 
#romulan 1-5
<< 0x000503a4 59 59 59 59 59 

<< 0x000503a9 90 90 90 6b c0 05
<< 0x000503b0 b6 94 10 90 0f 45 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90

#sneaky way to solve my above techInfo issue
#sub_455340 get_ship_ID_for_type

#00455359     807C24 64 FF   CMP BYTE PTR SS:[ESP+64],0FF  // Hero ship ?
#0045535E     74 1A          JE SHORT trek.0045537A
#00455360     8A4424 68      MOV AL,BYTE PTR SS:[ESP+68]
#00455364     3A01           CMP AL,BYTE PTR DS:[ECX]
#00455366     74 0E          JE SHORT trek.00455376
#00455368     90             NOP

#00455376     33C0           XOR EAX,EAX

#vanilla player build ship UI 
#with "buildable minor ships (major code modification)" already applied
#004F3DD7     8B59 04        MOV EBX,DWORD PTR DS:[ECX+4]
#004F3DDA     8BD4           MOV EDX,ESP
#004F3DDC     8AC3           MOV AL,BL
#004F3DDE     E8 DDBBF7FF    CALL trek.0046F9C0
#004F3DE3     8A4424 68      MOV AL,BYTE PTR SS:[ESP+68]
#004F3DE7     3C 06          CMP AL,6
#004F3DE9     74 3F          JE SHORT trek.004F3E2A
#004F3DEB     3C 07          CMP AL,7
#004F3DED     74 3B          JE SHORT trek.004F3E2A
#004F3DEF     807C24 64 FF   CMP BYTE PTR SS:[ESP+64],0FF

#vanilla player build ship UI 
#without "buildable minor ships (major code modification)" not applied
#004F3DAD     8B59 04        MOV EBX,DWORD PTR DS:[ECX+4]
#004F3DB0     8BD4           MOV EDX,ESP
#004F3DB2     8AC3           MOV AL,BL
#004F3DB4     E8 07BCF7FF    CALL trek.0046F9C0
#004F3DB9     8A4424 68      MOV AL,BYTE PTR SS:[ESP+68]
#004F3DBD     3C 06          CMP AL,6
#004F3DBF     74 5E          JE SHORT trek.004F3E1F
#004F3DC1     3C 07          CMP AL,7
#004F3DC3     74 5A          JE SHORT trek.004F3E1F
#004F3DC5     807C24 64 FF   CMP BYTE PTR SS:[ESP+64],0FF  // Hero ship ?

#Hero ship IDs in trek.exe at 0x50390 asm-450F90 (25 single byte values, sorted by empire 0-4 each for starting level 0-4)
#I.e. cardassian 1-5, federation 1-5,.. You can use same IDs for different levels if you want.

#00450D2B     90                NOP
#00450D2C     90                NOP
#00450D2D     90                NOP
#00450D2E     90                NOP
#00450D2F     90                NOP
#00450D30     90                NOP

#00450D5B     75 18             JNZ SHORT trek.00450D75
#00450D5D     90                NOP
#00450D5E     90                NOP
#00450D5F     90                NOP
#00450D60     90                NOP

#00450F90     90                   NOP
#00450F91     90                   NOP
#00450F92     90                   NOP
#00450F93     90                   NOP
#00450F94     90                   NOP
#00450F95     90                   NOP
#00450F96     90                   NOP
#00450F97     90                   NOP
#00450F98     90                   NOP
#00450F99     90                   NOP
#00450F9A     90                   NOP
#00450F9B     90                   NOP
#00450F9C     90                   NOP
#00450F9D     90                   NOP
#00450F9E     90                   NOP
#00450F9F     90                   NOP
#00450FA0     90                   NOP
#00450FA1     90                   NOP
#00450FA2     90                   NOP
#00450FA3     90                   NOP
#00450FA4     90                   NOP
#00450FA5     90                   NOP
#00450FA6     90                   NOP
#00450FA7     90                   NOP
#00450FA8     90                   NOP
#00450FA9     90                   NOP
#00450FAA     90                   NOP
#00450FAB     90                   NOP
#00450FAC     6BC0 05              IMUL EAX,EAX,5
#00450FAF     0FB69410 900F4500    MOVZX EDX,BYTE PTR DS:[EAX+EDX+450F90]
#00450FB7     90                   NOP
#00450FB8     90                   NOP
#00450FB9     90                   NOP
#00450FBA     90                   NOP
#00450FBB     90                   NOP
#00450FBC     90                   NOP
#00450FBD     90                   NOP
#00450FBE     90                   NOP
#00450FBF     90                   NOP
#00450FC0     90                   NOP
#00450FC1     90                   NOP
#00450FC2     90                   NOP
#00450FC3     90                   NOP
#00450FC4     90                   NOP
#00450FC5     90                   NOP
#00450FC6     90                   NOP
#00450FC7     90                   NOP
#00450FC8     90                   NOP
#00450FC9     90                   NOP
#00450FCA     90                   NOP
User avatar
Flocke
BORG Trouble Maker
BORG Trouble Maker
Posts: 3256
Joined: Sun Apr 27, 2008 2:00 am
Location: Hamburg, Germany
Contact:

Re: Flagship/heroship code changes

Post by Flocke »

Spocks-cuddly-tribble wrote: Tue Apr 02, 2024 7:50 pm In this case Flocke meant the modified code sequence is unchanged, but relocaded in the 'minor ships' patch.
I didn't look into it but yes. But was it request to also add in minor ship build patch?
If so, a better patch would be to restore code location so the patches become independent.
But again, before investing time, better give that patch some time to be tested.
Some time later we might simply hook and replace the whole subroutine. :razz:
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7940
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: Flagship/heroship code changes

Post by thunderchero »

Flocke wrote: Wed Apr 03, 2024 2:46 am But was it request to also add in minor ship build patch?
Studmaster mod topic has already stated he has added "buildable minor ships (major code modification)"

as expected here "read/write error" with new patch applied with "buildable minor ships (major code modification)".
minor.jpg
minor.jpg (45.67 KiB) Viewed 148 times
if changes can be ignored? I would consider this a mod development patch and not for the basic user to add?

example; if Hero patch is found applied, don't allow any changes to special ships sub section?
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1939
Joined: Sun Apr 27, 2008 2:00 am

Re: Flagship/heroship code changes

Post by Spocks-cuddly-tribble »

Flocke wrote: Wed Apr 03, 2024 2:46 ama better patch would be to restore code location so the patches become independent.
Was intended, but I tried to avoid additional calculations and redundant extra file loading (important for the countless iterating AI part of the patch).
Since this part is player UI only code it wouldn't matter, correct. But the two patch variants by thunderchero do the job, so case closed. :wink:
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: 7940
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: Flagship/heroship code changes

Post by thunderchero »

Flocke wrote: Wed Apr 03, 2024 2:46 am If so, a better patch would be to restore code location so the patches become independent.
So not to conflict with UE "buildable minor ships (major code modification)" code changes
I changed the call at 004F4D96 and moved sub 4F3D70 into relocation table with Hero patch changes and buildable minor ships patch.
hero_ship_build_reloc.patch
(7.47 KiB) Downloaded 1 time
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1939
Joined: Sun Apr 27, 2008 2:00 am

Re: Flagship/heroship code changes

Post by Spocks-cuddly-tribble »

Great, but I think you work way too hard. Be aware this will disable the UE warning messages, but can in fact worsen UE usability:

UE now might display wrong/unused code and allow editing disabled special ship code/IDs and/or show 'minor ships patch' installed if Hero Ship patch enforces the other variant (it reads/adds/removes unused code). So your suggestion to remove Hero patch during UE editing might be better?
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: 7940
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: Flagship/heroship code changes

Post by thunderchero »

Spocks-cuddly-tribble wrote: Thu Apr 04, 2024 6:57 pm Great, but I think you work way too hard. Be aware this will disable the UE warning messages, but can in fact worsen UE usability:

UE now might display wrong/unused code and allow editing disabled special ship code/IDs and/or show 'minor ships patch' installed if Hero Ship patch enforces the other variant (it reads/adds/removes unused code). So your suggestion to remove Hero patch during UE editing might be better?
I disagree, while UE is a vital tool to edit BOTF, even Dcer said it was never intended to cover every modification we make.

I agree this is a very interesting modification, but with it's limited usage the developer of mod should be able to handle changes when needed. I doubt anyone would add this patch to a personal mod.

As far as UE with hero patch applied, yes some UE functions will make changes that have no effect.
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1939
Joined: Sun Apr 27, 2008 2:00 am

Re: Flagship/heroship code changes

Post by Spocks-cuddly-tribble »

I see, so other players, editing unrelated settings in any mod using this patch, don't get confusing UE warnings?
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: 7940
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: Flagship/heroship code changes

Post by thunderchero »

Spocks-cuddly-tribble wrote: Mon Apr 08, 2024 12:43 pm I see, so other players, editing unrelated settings in any mod using this patch, don't get confusing UE warnings?
Flocke would have to answer that one, but I don't expect any warning

I would suggest if at 004F4D96 (call statment) is changed
gray out options
gray.jpg
gray.jpg (82.55 KiB) Viewed 59 times
gray1.jpg
gray1.jpg (128.43 KiB) Viewed 59 times
gray2.jpg
gray2.jpg (177.88 KiB) Viewed 59 times
Post Reply

Return to “Flagship Mod”