Page 1 of 1

Building minors ships after membership

Posted: Mon Apr 27, 2009 8:28 am
by thunderchero
This topic was split from "All The Ages Mod: FINAL RELEASE."

severenth wrote:Would it be possible ( in the modding area of the forum ) to show/explain/go through how you have changed the trek.exe to allow the building of minors?

or link to where its already shown
Thanks to DCER, :wink: he has made change very easy to do with UE.
this is only available using UE 0.7.0dev1
load trek.exe with UE
go to EDIT/GAME/Ship Building
then select "buildable minor ships inaddition to empire ships(major code modifactions)

this is out for testing this is why it has not become part of installer yet.


Posted: Mon Apr 27, 2009 1:44 pm
by Gh0st
Thanks alot DCER & Thunderchero. Buildable minor ships are a great expansion to the orignal game and it was long dream for many of us!

Posted: Thu Apr 30, 2009 3:42 am
severenth wrote:As great as UE is, and as much as a pain in the ass of a request it is, I personally think any modifacations to exe's could be described / listed / detailed as to how they work and what to do IF someone wants to do it without UE

Its similar to the making Large maps Huge, personally i'd like to see how this is done in the code ( and so I can build it into future mods I may decide to make )
I agree with your take on this.

As it's being done now the function sub_4F3D70 has to be rewritten.

At 0xF3170 paste this to replace sub_4F3D70 (works only on exe's based on Jokers patch in other versions of trek.exe it would look different):

Code: Select all

53 51 52 56 57 55 81 EC 30 01 00 00 BD 44 00 00 00 8B 3D A8 5D 59 00 8B 77 1A C1 FE 10 69 F6 28 03 00 00 A1 C8 36 5A 00 01 C6 31 C0 8A 04 2E 3C 04 77 0A 83 FD 4C 74 18 E9 8A 00 00 00 55 BD 10 20 5A 00 6B C0 40 8B 44 28 3C 5D 83 F8 01 74 E8 8A 04 2E E8 38 17 F6 FF E8 33 7D 02 00 89 C1 85 C0 0F 84 60 00 00 00 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 74 34 BA 03 00 00 00 31 C0 66 89 9C 24 28 01 00 00 66 8B 84 24 1C 01 00 00 89 94 24 20 01 00 00 89 84 24 2C 01 00 00 8D 94 24 20 01 00 00 8B 47 38 E8 C6 6F 02 00 89 C8 E8 6F 79 02 00 89 C1 85 C0 75 A0 83 FD 44 75 08 83 C5 08 E9 3D FF FF FF 81 C4 30 01 00 00 5D 5F 5E 5A 59 5B C3 00
In a disassembler it looks like this:

Code: Select all

AUTO:004F3D70 sub_4F3D70      proc near
AUTO:004F3D70 var_E0          = dword ptr -0E0h
AUTO:004F3D70 var_2C          = word ptr -2Ch
AUTO:004F3D70 var_28          = dword ptr -28h
AUTO:004F3D70 var_20          = word ptr -20h
AUTO:004F3D70 var_1C          = dword ptr -1Ch
AUTO:004F3D70                 push    ebx
AUTO:004F3D71                 push    ecx
AUTO:004F3D72                 push    edx
AUTO:004F3D73                 push    esi
AUTO:004F3D74                 push    edi
AUTO:004F3D75                 push    ebp
AUTO:004F3D76                 sub     esp, 130h
AUTO:004F3D7C                 mov     ebp, 44h
AUTO:004F3D81 loc_4F3D81:
AUTO:004F3D81                 mov     edi, ds:dword_595DA8
AUTO:004F3D87                 mov     esi, [edi+1Ah]
AUTO:004F3D8A                 sar     esi, 10h
AUTO:004F3D8D                 imul    esi, 328h
AUTO:004F3D93                 mov     eax, ds:dword_5A36C8
AUTO:004F3D98                 add     esi, eax
AUTO:004F3D9A                 xor     eax, eax
AUTO:004F3D9C                 mov     al, [esi+ebp]
AUTO:004F3D9F                 cmp     al, 4
AUTO:004F3DA1                 ja      short loc_4F3DAD
AUTO:004F3DA3                 cmp     ebp, 4Ch
AUTO:004F3DA6                 jz      short loc_4F3DC0
AUTO:004F3DA8 loc_4F3DA8:
AUTO:004F3DA8                 jmp     loc_4F3E37
AUTO:004F3DAD ; ---------------------------------------------------------------------------
AUTO:004F3DAD loc_4F3DAD:
AUTO:004F3DAD                 push    ebp
AUTO:004F3DAE                 mov     ebp, offset dword_5A2010
AUTO:004F3DB3                 imul    eax, 40h
AUTO:004F3DB6                 mov     eax, [eax+ebp+3Ch]
AUTO:004F3DBA                 pop     ebp
AUTO:004F3DBB                 cmp     eax, 1
AUTO:004F3DBE                 jz      short loc_4F3DA8
AUTO:004F3DC0 loc_4F3DC0:
AUTO:004F3DC0                 mov     al, [esi+ebp]
AUTO:004F3DC3                 call    sub_455500
AUTO:004F3DC8                 call    sub_51BB00
AUTO:004F3DCD                 mov     ecx, eax
AUTO:004F3DCF                 test    eax, eax
AUTO:004F3DD1                 jz      loc_4F3E37
AUTO:004F3DD7 loc_4F3DD7:
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
AUTO:004F3DF4                 jz      short loc_4F3E2A
AUTO:004F3DF6                 mov     edx, 3
AUTO:004F3DFB                 xor     eax, eax
AUTO:004F3DFD                 mov     [esp+148h+var_20], bx
AUTO:004F3E05                 mov     ax, [esp+148h+var_2C]
AUTO:004F3E0D                 mov     [esp+148h+var_28], edx
AUTO:004F3E14                 mov     [esp+148h+var_1C], eax
AUTO:004F3E1B                 lea     edx, [esp+148h+var_28]
AUTO:004F3E22                 mov     eax, [edi+38h]
AUTO:004F3E25                 call    sub_51ADF0
AUTO:004F3E2A loc_4F3E2A:
AUTO:004F3E2A                 mov     eax, ecx
AUTO:004F3E2C                 call    sub_51B7A0
AUTO:004F3E31                 mov     ecx, eax
AUTO:004F3E33                 test    eax, eax
AUTO:004F3E35                 jnz     short loc_4F3DD7
AUTO:004F3E37 loc_4F3E37:
AUTO:004F3E37                 cmp     ebp, 44h
AUTO:004F3E3A                 jnz     short loc_4F3E44
AUTO:004F3E3C                 add     ebp, 8
AUTO:004F3E3F                 jmp     loc_4F3D81
AUTO:004F3E44 ; ---------------------------------------------------------------------------
AUTO:004F3E44 loc_4F3E44:
AUTO:004F3E44                 add     esp, 130h
AUTO:004F3E4A                 pop     ebp
AUTO:004F3E4B                 pop     edi
AUTO:004F3E4C                 pop     esi
AUTO:004F3E4D                 pop     edx
AUTO:004F3E4E                 pop     ecx
AUTO:004F3E4F                 pop     ebx
AUTO:004F3E50                 retn
AUTO:004F3E50 sub_4F3D70      endp
This will make flagships not work if pasted over the flagship mod and also special ships are gone as well (had to be removed to gain space for new code).
and part of code depends on shiplist size
No, I'm sorry if I made the impression it did. This should generally work for any mod. Unless the function called by this function were moved or edited in some way that would break this one.

The main reason it hasn't been posted yet was because of the testing. Bugs could still pop up. I was also worried about the part where races taken by force won't allow you to build their ships. The new function is getting data from the alienInfo file which hasn't been researched in depth yet.