liberating foreign home systems (fix)

liberating foreign home systems (fix); support/discussion/questions

Moderator: thunderchero

User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1884
Joined: Sun Apr 27, 2008 2:00 am

liberating foreign home systems (fix)

Post by Spocks-cuddly-tribble »

A code error in BotF disables the liberation of foreign home systems (missing choice).


This solves the issue: :)

Code: Select all

trek.exe at 0xEB05A

replace:
0F 85 E4 00 00 00 80 7D 30 03 0F 85 DA 00 00 00 8A 5D 4C 80 FB 23 0F 84 CE 00 00 00
with:
75 0A 80 7D 30 03 74 0A 80 7D 30 06 0F 85 D8 00 00 00 8A 5D 4C 80 FB 23 74 0E 90 90


asm 4EBC5A:
jnz     short (10 bytes)
cmp     byte ptr [ebp+30h], 3
jz      short (10 bytes)
cmp     byte ptr [ebp+30h], 6
jnz     loc_4EBD44
mov     bl, [ebp+4Ch]
cmp     bl, 23h
jz      short (14 bytes)
nop nop
EDIT: Note part 2 of the fix :!:
Last edited by Spocks-cuddly-tribble on Fri Feb 18, 2011 7:13 am, 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.
Mentat
Commander
Commander
Posts: 360
Joined: Sun May 04, 2008 2:00 am

Post by Mentat »

Hi5 SCT, I think there is quite a number of us that were hoping this would get fixed one day.
Cheers!
Dominion Wars - Scenario
to be released for UDM3.0.1a !
User avatar
Tethys
Past Administrator
Past Administrator
Posts: 2392
Joined: Fri Jul 18, 2008 2:00 am
Location: Your mom's bed ;)
Contact:

Post by Tethys »

wow we may have a rewritten source code in no time lol... great work SCT once again
Not for the weak of heart...
Galaxies MOD v0.4.0 <--- GALM/Galaxies Mod latest version
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7849
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: liberating foreign home systems (fix)

Post by thunderchero »

Spocks-cuddly-tribble wrote:I leave it on you guys to test... :P
I finally had time to test code. :lol:

I was able to liberate foreign home system and system went back to correct race. I did also test if major would be able to be brought back after all systems were subjugated no option to liberate. (expected)

One note though I had no messages in turn summary so I checked and I did not get any morale boost for doing this since there are no entries in morale table? (also kind of expected this too)

thunderchero
Last edited by thunderchero on Thu Dec 24, 2009 10:40 pm, edited 1 time in total.
User avatar
Martok
Rear-Admiral
Rear-Admiral
Posts: 1208
Joined: Thu May 01, 2008 2:00 am

Post by Martok »

Spocks-cuddly-tribble wrote:So it's only a partial fix for now. I suggest we leave the option since it won't break anything aside of this. :)

Agreed. Previously, we'd been unable to build the other empire's special structures on their homeworld anyway, so nothing is lost in that respect. At least now we'll have the option of liberating home systems instead of just subjugating them. 8)
"Evil is easy, and has infinite forms." -- Pascal
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1884
Joined: Sun Apr 27, 2008 2:00 am

liberating foreign home systems (fix) part 2 & Liberate Foreign Morale fix

Post by Spocks-cuddly-tribble »

Spocks-cuddly-tribble wrote:morale code... there seems to be none for liberating foreign major systems in general.

... some additional code has to be edited as well (unkown yet) - otherwise the liberated system loses its home system status i.e. [systInfo+30] will be set to 1(native) instead of 0(home).
And here comes the missing part (to use in addition to the initial fix!):

Code: Select all

Trek.exe at 0x66D6C (33 bytes)
replace:
66 8B 70 44 66 83 FE 05 72 59 66 83 FE 23 77 53 66 83 FE 20 0F 83 F8 02 00 00 B8 01 00 00 00 89 F1
with:
80 78 30 06 75 04 C6 40 30 00 0F B6 48 44 83 F9 05 72 3A 83 F9 20 0F 83 FB 02 00 00 B8 01 00 00 00


46796C     8078 30 06        CMP BYTE [EAX+30], 6
467970     75 04             JNZ SHORT 467976
467972     C640 30 00        MOV BYTE [EAX+30], 0
467976     0FB648 44         MOVZX ECX, BYTE [EAX+44]
46797A     83F9 05           CMP ECX, 5
46797D     72 3A             JB SHORT 4679B9
46797F     83F9 20           CMP ECX, 20  // error corrected
467982     0F83 FB020000     JNB 467C83
467988     B8 01000000       MOV EAX, 1
As a side effect this also fixes the missing morale effect bug, sharing the "Liberate Minor" labeled Morale Chart event, which should rather be called "Liberate Foreign". :)


EDIT: Corrected a small error at 0x66D81 (23) -> 20 (this affected diplomatic data of liberated minors with race IDs 20h+)
Last edited by Spocks-cuddly-tribble on Tue Apr 05, 2022 9:07 am, edited 3 times 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
Peter1981
Rear-Admiral
Rear-Admiral
Posts: 1118
Joined: Tue May 06, 2008 2:00 am
Location: England

Post by Peter1981 »

is this

Code: Select all

467972     C640 30 00        MOV BYTE [EAX+30], 0
is this where system status (i.e. [systInfo+30]) is set to 0 (home) instead of 1(native)?

however I view losing your home wolrd in the first place requires some punishment. therefore

Code: Select all

467972     C640 30 01        MOV BYTE [EAX+30], 1
would this set system status to native?

Spocks-cuddly-tribble wrote:In theory, yes, but note this produces inconsistencies within the code (home-system handling is connected with e.g. RToSInfo), with possibly fatal results, although you won't notice immediately. In fact I can't even see where in the original code for foreign major liberations [systInfo+30h] gets changed (if at all).

Second: For your purposes, you'd need to change also the default code for reconquering own home systems(not recommended as well), otherwise the penalty doesn't work as intended by you when reconquered by the owner:

Code: Select all

467D30                 mov     byte ptr [eax+30h], 0
thanks SCT -- what i'm trying to do is remove a liberated conqured home system's ability to build 'home system only' buildings. anyway thanks for the response.

Spocks-cuddly-tribble wrote:If you have the time to test the pants out of this, you can still give it a go. Maybe changing code at 467972(foreign fix) and 467D30 (native liberations) works flawless.

By default, if a currently conquered home system gets conquered by a second oppressor then it loses its home system status for all time.

Maybe this also happens when it frees itself on it's own through rebellion
Last edited by Peter1981 on Sun Feb 20, 2011 11:43 am, edited 1 time in total.
User avatar
DotAliscious
Cadet 2nd Year
Cadet 2nd Year
Posts: 6
Joined: Mon May 07, 2012 8:35 pm

Re: liberating foreign home systems (fix)

Post by DotAliscious »

I am using the no-cd version of the exe I downloaded from here, but I don't see the same hex codes as you guys do. I can't liberate Romulus. I settled for subjugating them and letting them rebel out of it and then made peace again.

Maybe I just need to use a different editor? What do you use?
User avatar
Peter1981
Rear-Admiral
Rear-Admiral
Posts: 1118
Joined: Tue May 06, 2008 2:00 am
Location: England

Re: liberating foreign home systems (fix)

Post by Peter1981 »

4##### are assembler not hex address (i.e. 0xXXXX) try using the tool for convertion in UE to convert for you.
runetraveller
Cadet 4th Year
Cadet 4th Year
Posts: 15
Joined: Mon Oct 20, 2008 2:00 am
Location: Republic of Cascadia
Contact:

Re: liberating foreign home systems (fix)

Post by runetraveller »

im wanting to try this, but i need a bit of help - i have the UE, i open the file trek.exe and go to tools/other/convert address ..... what do i type where to let me liberate foreign home systems?

i feel like a pakled in a room full of vulcans....
User avatar
QuasarDonkey
Code Analyst
Code Analyst
Posts: 433
Joined: Tue Jul 26, 2011 8:29 pm
Location: Ireland

Re: liberating foreign home systems (fix)

Post by QuasarDonkey »

Well what you really want here is a "hex editor". It will allow you to edit the bytes in the Trek.exe program. There's loads of free ones out there. I used to use WinHex (there are much simpler ones -- you only need a very simple hex editor).

Basically, you open Trek.exe in your hex editor, go to offset 0x000EB05A in the file, then overwrite the bytes that SpocksCuddlyTribble said to with the new sequence of bytes. Then save the file. And it's patched. You might want to save a copy of trek.exe beforehand, just in case you make a mistake.

:arrow: The 0xEB05A is just a number written in hexadecimal (base-16). That's 962650 in decimal.

Just to clarify, after you go to the offset (hex EB05A), you literally type in the letters/numbers, e.g. 75 0A 80 7D... (Don't type the ASM, JNZ stuff). And don't forget the second part to the patch, at 0x66D6C.
runetraveller
Cadet 4th Year
Cadet 4th Year
Posts: 15
Joined: Mon Oct 20, 2008 2:00 am
Location: Republic of Cascadia
Contact:

Re: liberating foreign home systems (fix)

Post by runetraveller »

okay then - downloaded a hex editor.... couldnt find the line 0xEB05A ..... nearest i found was 000eb050 .... and the numbers after didnt match what you posted at all .... am i looking in the right area?
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7849
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: liberating foreign home systems (fix)

Post by thunderchero »

the last digit is for the column. so 000eb050 would be same line column 1 and 0xEB05A would be column A. that is where code would start.

thunderchero
User avatar
QuasarDonkey
Code Analyst
Code Analyst
Posts: 433
Joined: Tue Jul 26, 2011 8:29 pm
Location: Ireland

Re: liberating foreign home systems (fix)

Post by QuasarDonkey »

You're in the right area. Any hex editor will usually display the file something like this:

Code: Select all

 Offset     0  1  2  3  4  5  6  7   8  9  A  B  C  D  E  F
000eb040  00 0f 83 30 01 00 00 89  c1 b8 01 00 00 00 d3 e0  |...0....Á¸....Óà|
000eb050  8b 15 50 2b 5a 00 89 c1  21 d1 0f 85 e4 00 00 00  |..P+Z..Á!Ñ..ä...|
000eb060  80 7d 30 03 0f 85 da 00  00 00 8a 5d 4c 80 fb 23  |.}0...Ú....]L.û#|
000eb070  0f 84 ce 00 00 00 31 c0  31 d2 88 d8 66 8b 55 44  |..Î...1À1Ò.Øf.UD|
000eb080  39 d0 0f 84 bc 00 00 00  8b 77 0c ba 09 00 00 00  |9Ð..¼....w.º....|
000eb090  89 f0 e8 b9 cf f5 ff 85  c0 0f 84 a5 00 00 00 31  |.ðè¹Ïõÿ.À..¥...1|
000eb0a0  c0 8a 45 4c e8 6b f4 f9  ff 50 31 c0 66 8b 45 44  |À.ELèkôùÿP1Àf.ED|
Here I told the hex editor to go to offset 0xEB05A. This positions the edit cursor at line 000EB050 down, in column A (because EB050 + A = EB05A). So I can start typing the new code in straight away.

If you're wondering what all the weird symbols on the right are, they're just ASCII text representations of the bytes in the file. So if you opened a text file with the hex editor, you'd see the text of the file on the right.

Anyway, at offset position 0xEB05A you should see the bytes (in the example above, you'll see them on the second line 000EB050, under column A):

Code: Select all

0F 85 E4 00 00 00 80 7D 30 03 0F 85 DA 00 00 00 8A 5D 4C 80 FB 23 0F 84 CE 00 00 00
Replace those bytes with these (by just typing over them):

Code: Select all

75 0A 80 7D 30 03 74 0A 80 7D 30 06 0F 85 D8 00 00 00 8A 5D 4C 80 FB 23 74 0E 90 90
The second part of the patch is at offset 0x66D6C
Replace:

Code: Select all

66 8B 70 44 66 83 FE 05 72 59 66 83 FE 23 77 53 66 83 FE 20 0F 83 F8 02 00 00 B8 01 00 00 00 89 F1
with:

Code: Select all

80 78 30 06 75 04 C6 40 30 00 0F B6 48 44 83 F9 05 72 3A 83 F9 23 0F 83 FB 02 00 00 B8 01 00 00 00
Like I said, keep a backup copy of trek.exe in case you make a mistake, and then feel free to experiment.

:idea: I totally forgot, I made a patching program for Trek.exe last Christmas. It has a database of patches including this one. I'll fix it up and post it soon.
runetraveller
Cadet 4th Year
Cadet 4th Year
Posts: 15
Joined: Mon Oct 20, 2008 2:00 am
Location: Republic of Cascadia
Contact:

Re: liberating foreign home systems (fix)

Post by runetraveller »

im hoping this works! however - small problem... it seems that 66d60 (or c) doesnt exist.... goes right from 66d40 to 66d80..... ???
Post Reply

Return to “liberating foreign home systems (fix)”