Wormholes, Territory, SectorClaimCheck

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
Tethys
Past Administrator
Past Administrator
Posts: 2404
Joined: Fri Jul 18, 2008 2:00 am
Location: Your mom's bed ;)
Contact:

Wormholes, Territory, SectorClaimCheck

Post by Tethys »

This issue has always bothered me in vanilla, but I think if I spend additional time on it I could probably figure it out eventually. I am hoping someone has already seen an area that I should be looking over before I throw more hours at it. Nothing stands out in the search results.

I was having a game this evening and discovered a wormhole, the endpoint of which lies inside Romulan space. I opened IDA and had a look around to see if I could disable the territory check (? asm loc 468BC9) so I could build an outpost inside their space; I have yet to make first contact. Eventually found my way to 40F3FC but forcing (90 E9) claim_OK_offensive did not work either. I looked deeper into 430350 (430396 > no_claim 01?) and (4303A5 > no_own_claim 0?). I also tried forcing jump to no_claim 74 2D and 74 25 > EB 2D and EB 25. The button for build outpost remains grey. However, I have hope that this route is possible considering how quickly no locked borders mod came to be. This route could lay the groundwork for a new ship type (Towable Base) with taskforce orders Avoid by default (inactive base, no territory or range added) and Engage (one sector shaded, range assigned). At the very least, turning off the sector claim without breaking contested territories..

A secondary question (which I probably should have led with): Is there a way to perhaps "give" some range to the wormhole's far side endpoint? It would make more sense to me that you should be able to go at least a short distance (1 sector at the very least, 2 being the max) from the endpoint. But probably a double edge sword, as I'm not sure how that would work considering range is calculated by tech level, and the wormhole can be used by any race, so there may be conflicts and massive bugs to deal with this route. And it's very likely not to work, or work improperly.

All that said, I am willing to do the investigation and code changes provided I can get some relevant info and pointers in the right direction, and the occasional Pakled question(naire) answered.. :roll:
Not for the weak of heart...
Galaxies MOD v0.4.0 <--- GALM/Galaxies Mod latest version
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1955
Joined: Sun Apr 27, 2008 2:00 am

Re: Wormholes, Territory, SectorClaimCheck

Post by Spocks-cuddly-tribble »

1. There is a check allowing colonizations in enemy territory if at war. Best find those codes and see if you can use a similar approach for building stations. Problem is extra check for inhabited systems and other present stations in sector.

2. Range would be about remaining/unused rest waypoints from the closest ally yard/station (i.e. too much work).
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
User avatar
Tethys
Past Administrator
Past Administrator
Posts: 2404
Joined: Fri Jul 18, 2008 2:00 am
Location: Your mom's bed ;)
Contact:

Re: Wormholes, Territory, SectorClaimCheck

Post by Tethys »

Thanks for the tips! I will look into that check as I totally forgot it was a thing. I rarely colonize that late in a game, its always subjugation and bombing at that point...

I kinda figured that about the range, being too much work. Perhaps I am still too overconfident in my asm abilities since adding new stellar objects. Eventually, it was my hope to be able to use the "Upgrade" slot in taskforce order menu to "Launch Probe" which would be a sort of second "Enter Wormhole" or "Build Outpost"; but instead of moving your ship through wormhole, it would spawn some new ship type with map stats to function like a space station or shipyard on the other side; but without granting the same sector ownership. <-lots more work than assigning a range to a wormhole endpoint I imagine :lol:

Or perhaps it could be a bit more simple? Disabling entering ship speed > set 0, and fashion a little code to transform the ship into the lowest level station in your shiplist as it exits the other side...(via adding event flag perhaps?) then it couldn't move and you'd have effective range for a second ship to explore until transformed ship's event flag is reset (go back through wormhole, return old ship type). Check may be needed for destruction event after tactical combat (reset flag, remove transformation, do not return old ship). I would probably favor this option over the ability to outright build bases in opponents space.

For the time being, though, and for testing purposes, I will be moving forward with trying to disable or alter the check for war colonization to see if I can gain the ability to colonize opponents territory while at peace (I can see the AI making use of this feature like they do with open borders)
Not for the weak of heart...
Galaxies MOD v0.4.0 <--- GALM/Galaxies Mod latest version
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1955
Joined: Sun Apr 27, 2008 2:00 am

Re: Wormholes, Territory, SectorClaimCheck

Post by Spocks-cuddly-tribble »

You should test this GUI code (the same sub is for system attacks):

sub_4EB770 source\\ui\\maingal\\tfship

4EB88C claim_check

4EB8B7 war_check_loop

Code appears to be shared for different things, try:

Code: Select all

004EB891    jz      no_claim_or_only_own // -> jmp 0xEAC91 (0F 84) -> 90 E9
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
User avatar
Tethys
Past Administrator
Past Administrator
Posts: 2404
Joined: Fri Jul 18, 2008 2:00 am
Location: Your mom's bed ;)
Contact:

Re: Wormholes, Territory, SectorClaimCheck

Post by Tethys »

Yes, that works as far as allowing the colony ship to bypass the war check for colonization inside claimed and disputed territories. However, the issue I am facing is that the BUILD OUTPOST order never illuminates.

I have had success disabling the war check for other ship types as well for ATTACK SYSTEM (which is always illuminated, and tied to a lexicon entry; BUILD X does not have any lexicon warning)

I have also done some funny things, for example, I was able to construct an outpost in neutral territory and the territory remained neutral once completed. I am curious to see what would happen there, since the sector is unclaimed, if another empire could initiate a station construction (and probably cause a crash) 447802 base_check_territory_accessible? I believe is the call I removed which gave me the neutral outpost, so I investigated it and I just could not isolate the function responsible for that event. I did notice, however, that the additional territory squares (free and unpopulated systems within border, including wormhole) had disappeared for all races (this is also happens at 44749D = 05 -> 00). I suppose this technically does exactly what I asked, however it takes away the additional sectors gained from stations and "strings" of colonies, as well as disputed territory. I would like to preserve those functions.
botf2.png
botf2.png (338.2 KiB) Viewed 3001 times
If I knew what controlled the button illumination, I could progress. But I am stuck for now. :sad:
Not for the weak of heart...
Galaxies MOD v0.4.0 <--- GALM/Galaxies Mod latest version
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1955
Joined: Sun Apr 27, 2008 2:00 am

Re: Wormholes, Territory, SectorClaimCheck

Post by Spocks-cuddly-tribble »

Tethys wrote: Sun Feb 06, 2022 9:53 pmIf I knew what controlled the button illumination, I could progress. But I am stuck for now. :sad:
UI code is not in my wheelhouse (QD/DCER).

Most likely you search for an UI code reading claim from sector.lst like the example I gave you:

call sub_43DAB0 sector_lst_entry

[sector.lst+0Eh] is empire claims bitmask (yes, try the wiki for game files!)


Start with calls of sub_43DAB0 and work your way down the database (ignore calls from lower asm locations than 4DC6E8):

examples for load claim bitmask:

Code: Select all

AUTO:004DC722                 movzx   esi, byte ptr [esi+0Eh]

AUTO:004DFE82                 mov     dl, [ecx+0Eh]

AUTO:004DFEB1                 movzx   esi, byte ptr [esi+0Eh]

AUTO:004E2CF9                 mov     cl, [ebx+0Eh]
You can use mov reg,0 or xor reg,reg to test purpose of the codes.
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
User avatar
Tethys
Past Administrator
Past Administrator
Posts: 2404
Joined: Fri Jul 18, 2008 2:00 am
Location: Your mom's bed ;)
Contact:

Re: Wormholes, Territory, SectorClaimCheck

Post by Tethys »

Now we are getting somewhere. I was able to disable the claim for INHABITED star systems (44731A: 01 -> 00). Anomaly ID appears to also function as UNINHABITED claim.. so maybe I can reroute this to function like INHABITED system. However, it is possibly becoming apparent that the map_squares also have some effect on whether or not a station can be constructed (I may have to disable them for anomalous sectors to allow far side outposts within major territories). So I shall dig further and see what I can turn over...
botf3.png
botf3.png (374.73 KiB) Viewed 2937 times
:shock: :grin:
447442: 01 -> 00

But this also UNCLAIMS all territory which is not inhabited or with a station present, and also breaks CONTESTED sector feature. So, more digging will be done. But I am now very close! Thanks to your recent advice and the INVALUABLE website that one guy Flocke put together ;)
botf4.png
botf4.png (530.75 KiB) Viewed 2937 times
Now, I do have a question. I noticed at 4473D7 there is a ds: unknown ... is this systInfo * 4 ??? It appears in 2 other locations as well, in the is_accessible loop(s)
Not for the weak of heart...
Galaxies MOD v0.4.0 <--- GALM/Galaxies Mod latest version
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1955
Joined: Sun Apr 27, 2008 2:00 am

Re: Wormholes, Territory, SectorClaimCheck

Post by Spocks-cuddly-tribble »

Tethys wrote: Tue Feb 08, 2022 12:59 amNow, I do have a question. I noticed at 4473D7 there is a ds: unknown ... is this systInfo * 4 ???
There is no unknown, it's just empire ID *4 (loop 0-4 for all empires):

Code: Select all

004473D7                 lea     ebx, ds:0[eax*4] // = mov ebx, 4*eax (+0)
The loop reads empsInfo+124h
Offset 0x0124 to 0x0137 (5empires * 4bytes) = territory accessible: 0=No, 1=Yes

if No & that empire has a sector claim it sets sector.lst+54h
Offset 0x0054 to 0x0067= (5empires * 4bytes) = sector accessible: 0=No, 1=Yes (cf. empsInfo+124h)


You don't want to change the claims themselves, just the UI code reading them for outpost constructions. Given your results try this:

Code: Select all

AUTO:004471B7                 jbe     short loc_4471BE -> jmp 0x465B7 (76) -> EB
EDIT: hex error corrected
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
User avatar
Tethys
Past Administrator
Past Administrator
Posts: 2404
Joined: Fri Jul 18, 2008 2:00 am
Location: Your mom's bed ;)
Contact:

Re: Wormholes, Territory, SectorClaimCheck

Post by Tethys »

Spocks-cuddly-tribble wrote: Tue Feb 08, 2022 5:16 am
You don't want to change the claims themselves, just the UI code reading them for outpost constructions. Given your results try this:

Code: Select all

AUTO:004471B7                 jbe     short loc_4471BE -> jmp 0x465B7 (76) -> EB
EDIT: hex error corrected
The effect here is that all uninhabited and unsecured (no station present) territory squares are disappeared, but the empire claims to those sectors is still present. Ideally, we probably like to disable claim for anomalous sector ONLY, or setup some type of cmp to wormhole claim (FF? or 0A).

So I think creating a claim exception for wormhole sector may be the solution. It would prevent any race from claiming wormhole as territory by default, and would force one to construct a station for claim. The added strategy is now that if you do not establish stationary claim to the wormhole, you literally open the door to invasion. A nice caveat is that you could also destroy the station and thus remove the claim for expansion :D

LOL :lol:
botf5.png
botf5.png (339.54 KiB) Viewed 2891 times
Not for the weak of heart...
Galaxies MOD v0.4.0 <--- GALM/Galaxies Mod latest version
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1955
Joined: Sun Apr 27, 2008 2:00 am

Re: Wormholes, Territory, SectorClaimCheck

Post by Spocks-cuddly-tribble »

Tethys wrote: Tue Feb 08, 2022 2:49 pmIdeally, we probably like to disable claim for anomalous sector ONLY, or setup some type of cmp to wormhole claim (FF? or 0A).

So I think creating a claim exception for wormhole sector may be the solution. It would prevent any race from claiming wormhole as territory by default, and would force one to construct a station for claim. The added strategy is now that if you do not establish stationary claim to the wormhole, you literally open the door to invasion. A nice caveat is that you could also destroy the station and thus remove the claim for expansion :D
Shouldn't be too hard to insert such a check in sub_4472B0.

Hints for a code that might work:

@ 447439 insert new check for anomaly

movsx eax, word [edi+A] sector.lst anomalyID -1 if none
cmp eax,-1
jz go set claim (ex 447439)
imul eax,58h
cmp byte [5A36CC + eax], A // stellInfo entry type of anomaly = wormhole
jz 447493 no claim
else or jnz -> go ex 447439


All anomalies is even easier:

cm word [edi+A],-1
jnz 447493 no claim
else or jz -> go ex 447439
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
User avatar
Tethys
Past Administrator
Past Administrator
Posts: 2404
Joined: Fri Jul 18, 2008 2:00 am
Location: Your mom's bed ;)
Contact:

Re: Wormholes, Territory, SectorClaimCheck

Post by Tethys »

Spocks-cuddly-tribble wrote: Thu Feb 10, 2022 9:18 am movsx eax, word [edi+A] sector.lst anomalyID -1 if none
cmp eax,-1
jz go set claim (ex 447439)
imul eax,58h
cmp byte [5A36CC + eax], A // stellInfo entry type of anomaly = wormhole
jz 447493 no claim
else or jnz -> go ex 447439
Preliminary diagnostic

Code: Select all

0F BF 47 0A
83 F8 FF
74 xx                     or                0F 84 xx xx xx xx      (depending on location)
6B C0 58
80 B8 CC 36 5A 00 0A
74 xx                     or                0F 84 xx xx xx xx      ()
75 xx                     or                0F 85 xx xx xx xx      ()
Spocks-cuddly-tribble wrote: Thu Feb 10, 2022 9:18 amAll anomalies is even easier:

cm word [edi+A],-1
jnz 447493 no claim
else or jz -> go ex 447439
edit: corrected hex error (BB -> B8) I guess my eyes are going bad. Say, anyone got a pair to spare ???

My code, doesn't work. I will come back to it when I have some time during the week (work tomorrow). I would attach the idb, but its too big...

0x046839

Code: Select all

0F BF 47 0A 83 F8 FF 0F 84 BA 56 24 00 6B C0 58 80 B8 CC 36 5A 00 0A 74 41 0F 85 A8 56 24 00 90 90
                                                                           ^
also tried:

Code: Select all

0F BF 47 0A 83 F8 FF 0F 84 BA 56 24 00 6B C0 58 80 B8 CC 36 5A 00 0A 74 41 90 E9 A8 56 24 00 90 90
                                                                           ^
reloc table
0x01A1EFF

Code: Select all

90 8B 04 24 8A 0C 24 89 45 10 B0 01 8A 7F 0E D2 E0 08 C7 31 C0 88 C8 69 C0 BC 01 00 00 BA 98 1A 5B 00 E9 34 A9 DB FF
I observed no visible change in the game. I suspect it is not recognizing the wormhole.
Not for the weak of heart...
Galaxies MOD v0.4.0 <--- GALM/Galaxies Mod latest version
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1955
Joined: Sun Apr 27, 2008 2:00 am

Re: Wormholes, Territory, SectorClaimCheck

Post by Spocks-cuddly-tribble »

Tethys wrote: Fri Feb 11, 2022 9:03 pm
Spocks-cuddly-tribble wrote: Thu Feb 10, 2022 9:18 am movsx eax, word [edi+A] sector.lst anomalyID -1 if none
cmp eax,-1
jz go set claim (ex 447439)
imul eax,58h
cmp byte [5A36CC + eax], A // stellInfo entry type of anomaly = wormhole
jz 447493 no claim
else or jnz -> go ex 447439
I can't tell whether your hex code is right or my suggestion doesn't work for some reason or you need to start a new game.

But of course you need to adapt the code depending on how you optimize code and use the relocation table.

For example: Replace with long jump to relocation code loc:

Code: Select all

AUTO:00447439                 mov     eax, [esp]
AUTO:0044743C                 mov     cl, [esp]

AUTO:0044743F                 mov     [ebp+10h], eax // unchanged
@ relocation loc

Code: Select all

movsx eax, word [edi+A] sector.lst anomalyID -1 if none -> you can try (mov  eax, [edi+8] & sar  eax, 10h) but shouldn't matter
cmp eax,-1
jz go loc X below -> set claim
imul eax,58h
cmp byte [5A36CC + eax], A // stellInfo entry type of anomaly = wormhole -> you can try (cmp dword) but again it shouldn't matter
jz 447493 no claim
loc X: set claim
mov     eax, [esp]
mov     cl, [esp]
jmp 44743F
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
User avatar
Tethys
Past Administrator
Past Administrator
Posts: 2404
Joined: Fri Jul 18, 2008 2:00 am
Location: Your mom's bed ;)
Contact:

Re: Wormholes, Territory, SectorClaimCheck

Post by Tethys »

Hastily written so probably an error on my part. But codes are small, and trek.exe does not crash, however there is no change from vanilla that I can immediately see. I won't be able to investigate until probably later tonight or next week unfortunately. Thank you for trying at least. Hopefully I can use your data in a constructive way.

I will update the code with ida data this evening and partition it proper.

Here is a (newest version) GALM sav with wormhole in Romulan territory with a TT on the Romulan side, ready for testing (if anyone gets curious)
game5.sav
(560.02 KiB) Downloaded 48 times
Not for the weak of heart...
Galaxies MOD v0.4.0 <--- GALM/Galaxies Mod latest version
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1955
Joined: Sun Apr 27, 2008 2:00 am

Re: Wormholes, Territory, SectorClaimCheck

Post by Spocks-cuddly-tribble »

Tethys wrote: Fri Feb 11, 2022 9:03 pmI suspect it is not recognizing the wormhole.
I see the problem. An oversight on my side. stellInfo has a dynamic/variable position and therefore cannot be addressed directly.

replace -> cmp byte [5A36CC + eax], 0A (won't work)

use instead:

add eax, [5A36CC]
cmp byte [eax], 0A
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
User avatar
Tethys
Past Administrator
Past Administrator
Posts: 2404
Joined: Fri Jul 18, 2008 2:00 am
Location: Your mom's bed ;)
Contact:

Re: Wormholes, Territory, SectorClaimCheck

Post by Tethys »

Ok, so now we have

Code: Select all

447439 (new code)
0F BF 47 0A                                     movsx   eax, word ptr [edi+0Ah]
83 F8 FF                                        cmp     eax, 0FFFFFFFFh
0F 84 BA 56 24 00                               jz      loc_68CB00

6B C0 58                                        imul    eax, 58h 
03 05 33 36 5A 00                               add     eax, ds:dword_5A3633
80 38 0A                                        cmp     byte ptr [eax], 0Ah
74 3F                                           jz      short loc_447493

90 E9 A6 56 24 00                               jmp     loc_68CB00

68CB00 (vanilla values from section used for above)
8B 04 24                                        mov     eax, [esp+30h+var_30]
8A 0C 24                                        mov     cl, byte ptr [esp+30h+var_30]
89 45 10                                        mov     [ebp+10h], eax
B0 01                                           mov     al, 1
8A 7F 0E                                        mov     bh, [edi+0Eh]
D2 E0                                           shl     al, cl 
08 C7                                           or      bh, al
31 C0                                           xor     eax, eax
88 C8                                           mov     al, cl
69 C0 BC 01 00 00                               imul    eax, 1BCh  
BA 98 1A 5B 00                                  mov     edx, offset save_empsInfo
E9 34 A9 DB FF                                  jmp     loc_44745A   (finish to section I broke into)
This cause crash on save game, and crash on new game. I have only added your suggestion and edited the 2 jumps accordingly. Something else going on here. Should 80 38 0A cmp byte ptr [eax], 0Ah instead be 66 80 38 0A cmp word ptr [eax], 0Ah ? This would be unfortunate, because then I must shift more bytes, which I should have done to begin with... I would be better off moving the whole section and using the jump statement to return to next section. SO I will go ahead and just do that now to free up additional codespace.

Edit: I think I see a problem at the jnz, one moment while I diagnose...

It was an issue but it wasn't the issue. jnz was going into middle of section, changed to e9. It frees up a byte if i need to use word ptr instead of byte..

NEW

Code: Select all

447439 (new code)
0F BF 47 0A                                     movsx   eax, word ptr [edi+0Ah]
83 F8 FF                                        cmp     eax, 0FFFFFFFFh
0F 84 BA 56 24 00                               jz      loc_68CB00

6B C0 58                                        imul    eax, 58h 
03 05 33 36 5A 00                               add     eax, ds:dword_5A3633
80 38 0A                                        cmp     byte ptr [eax], 0Ah
74 3F                                           jz      short loc_447493

90 E9 A6 56 24 00                               jmp     loc_68CB00

90 ... -> (additional codespace 13 bytes)

68CB00 (vanilla values from section used for above)
8B 04 24                                        mov     eax, [esp+30h+var_30]
8A 0C 24                                        mov     cl, byte ptr [esp+30h+var_30]
89 45 10                                        mov     [ebp+10h], eax
B0 01                                           mov     al, 1
8A 7F 0E                                        mov     bh, [edi+0Eh]
D2 E0                                           shl     al, cl 
08 C7                                           or      bh, al
31 C0                                           xor     eax, eax
88 C8                                           mov     al, cl
69 C0 BC 01 00 00                               imul    eax, 1BCh  
BA 98 1A 5B 00                                  mov     edx, offset save_empsInfo
89 FE                                           mov     esi, edi
88 4C 24 10                                     mov     [esp+30h+var_20], cl
88 7F 0E                                        mov     [edi+0Eh], bh
01 C2                                           add     edx, eax 
31 C0                                           xor     eax, eax 
E9 34 A9 DB FF                                  jmp     loc_447467   (next section)
Edit 2: My word pointer idea didn't work either. I'm on hold until Tuesday :(

Image
Not for the weak of heart...
Galaxies MOD v0.4.0 <--- GALM/Galaxies Mod latest version
Post Reply

Return to “General Modding Information/Questions”