more savegames

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: 1961
Joined: Sun Apr 27, 2008 2:00 am

Re: more savegames

Post by Spocks-cuddly-tribble »

Tethys wrote: Sun Oct 01, 2023 4:30 pmI see 50 listed a few times as well. This is just in one subroutine as well. Dozens of these might exist.

Code: Select all

004F0C5D 01C 8D B7 38 01 00 00       lea     esi, [edi+138h] ; end of ID table +4? (new 50 01?)
Yes for one more slot this would be 0x150 (138h+18h).

+138h = pointer to start of 50 byte ingame save description strings (12*50 bytes)

32h 50 dec is size ingame save description strings (ignore this)

many 120h are (0xC * 0x18) -> i.e. hidden cmp 0xC checks for slot loops :wink:

So 120h and 138h -> each +0x18(24dec) per new save slot


And I agree with thunderchero, we need a project patch with all code values labeled with asm locations to help (cf. my newer patches).

Good news is sub_4F0250 loadsave_ESP doesn't seem to need esp adjustments (only 4F02A1/120h 4F0375/138h) and there is no MP issue. :up:


So I guess about 70 values: one 0xC, many (0x120, 0x138, 0x390 and 0x394) one size 0x3C8

As told -> 0x120/0x138 each +0x18 per new slot -> 0x390/0x394 and 0x3C8 each +0x4A per new slot


Plus all the widget/wdf stuff (e.g. four for total number of widgets cf. xrefs to wdf widget IDs).
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: 7965
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: more savegames

Post by thunderchero »

thunderchero wrote: Sun Oct 01, 2023 8:42 am personally I would rather see a different approach, I always like the way MPR++ saved game to a new folder with saved game name ("playing race" "turn".sav) on start of each turn automatically.

we should be able to do this if we call to a new sub right before auto sav sub returns.
new sub would create a copy of auto.sav and rename to example federation 0.sav to the "save" folder.

we have examples of code calling folder (english/german) folder
we have examples of coping and renaming sav file (auto -> last.sav)
I have not found location but we should have example of code reading race and turn of sav file when it adds text to a blank sav.
what else would we need?
I started taking a look at this, so far I had to separate where auto.sav and game%d.sav get written (they used same write code)

this way only after auto.sav is written I can add new code without new code being used when game%d.sav get written.

I also was able to get auto.sav renamed to turn.sav into a new folder named "save" folder without effecting how original last.sav gets renamed.

Now the tough part, adding a string %d_turn_%d.sav into example; Federation_turn_154.sav instead of turn.sav now.
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1961
Joined: Sun Apr 27, 2008 2:00 am

Re: more savegames

Post by Spocks-cuddly-tribble »

thunderchero wrote: Tue Oct 03, 2023 9:05 pmNow the tough part, adding a string %d_turn_%d.sav into example; Federation_turn_154.sav instead of turn.sav now.
In sub_438630 you discovered it deletes last.sav then copies auto.sav to last.sav and updates auto.sav from active game files.

So sub_51D886 copy_file_EAX_to_name_EDX should be able to do what you want if you create your composed string at address EDX.

Sub_4EFCC0 ingame_sav_default_strings creates the composed string from the gameInfo (empire, turn, gal size and shape).

But loading such custom name sav files might be tricky in ASM (size limit 0xC). Albeit MPR++ code should be able to do it?

How about player empire abbreviation (c,h,f,k,r) plus turn number?

Just read:

5A2B2A GI_252_b_player_empire -> movzx eax, byte [5A2B2A] call 43AB80 Get_initial_letter_raceEAX

5A2918 gameInfo_40_Turn_Number -> convert from hex to dec (four digits) and compose string
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: 7965
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: more savegames

Post by thunderchero »

Spocks-cuddly-tribble wrote: Tue Oct 03, 2023 10:48 pm How about player empire abbreviation (c,h,f,k,r) plus turn number?
thanks for info,

I also noticed 0C limit the other day, I might try to use 5A2B2A GI_252_b_player_empire but limit string to 3 to use (Car, Fed/Ter, Fer/Dom/Bor, Kli, Rom).

This project I am just doing when I have time, so expect slow progress.

Edit; have you seen code for "copy file" only thing I have seen is "move file"
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1961
Joined: Sun Apr 27, 2008 2:00 am

Re: more savegames

Post by Spocks-cuddly-tribble »

thunderchero wrote: Wed Oct 04, 2023 8:46 amhave you seen code for "copy file" only thing I have seen is "move file"
Just a deduction from the default game behavior and your last.sav -> game0.sav patch.

Partially wrong, MoveFileA is rather 'rename into' and not 'copy and save as':
0043863F         jnz     short create_and_update_new_auto_sav?
00438641         mov     eax, offset aLast_sav             ; "last.sav"
00438646         mov     edx, offset aLast_sav             ; "last.sav"
0043864B         call    delete_file_EAX                   ; last.sav
00438650         mov     eax, offset aAuto_sav             ; "auto.sav"
00438655         call    rename_file_EAX_into_name_EDX     ; auto.sav -> last.sav


sub_51D886 rename_file_EAX_into_name_EDX

0051D887         push    edx                               ; lpNewFileName
0051D888         push    eax                               ; lpExistingFileName
0051D889         call    cs:MoveFileA
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: more savegames

Post by Tethys »

Hmm.. ok so I was wondering since it is hard to extend the saves.. maybe it would not be as hard to do the following (since we have this nice call @ 438655 called rename_file)

Add button to loadsave.wdf that when pressed will clear all the saves from the current list. In reality though, these saves are not deleted but are only renamed and either left in the BotF directory or shoved into a subfolder by code. Now all slots are blank, and you can save another game0-11.save list. The button would not be next page. It would only seemingly function that way. It will actually rename all the saves in the directory to something like game12-24.sav which will automatically free up the slots because the info will be no longer existent for the game to be reading; instead would read a blank set of 0-11 saves allowing user to save new content and not overwrite previous existing. Some kind of check how many file/size for each "page" or click of the button. That would probably be the most challenge. But it would mostly be custom code, not much hacking other than to get the button functional.

A "back" or "last page" button can rename all the files over again, bringing back the old saves. :D

To make it easier, maybe we can use the space of the game11.sav for the new forward and back buttons. This way, no wdf table editing required. Only renaming the buttons and switching its function. One textbox turn into page button fwd, the other into page back. Last sav can have a single entry to the side, and saves 1-10 can be standard slots used. Each page realistically having 11 saves (one is the last/auto sav) and 10 game saves per "page". As I expect I think the hardest part of this process would be switching the button wdf from toggle button to page next functional.
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: 7965
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: more savegames

Post by thunderchero »

Tethys wrote: Wed Oct 04, 2023 12:07 pm Hmm.. ok so I was wondering since it is hard to extend the saves.. maybe it would not be as hard to do the following (since we have this nice call @ 438655 called rename_file)

Add button to loadsave.wdf that when pressed will clear all the saves from the current list. In reality though, these saves are not deleted but are only renamed and either left in the BotF directory or shoved into a subfolder by code. Now all slots are blank, and you can save another game0-11.save list. The button would not be next page. It would only seemingly function that way. It will actually rename all the saves in the directory to something like game12-24.sav which will automatically free up the slots because the info will be no longer existent for the game to be reading; instead would read a blank set of 0-11 saves allowing user to save new content and not overwrite previous existing. Some kind of check how many file/size for each "page" or click of the button. That would probably be the most challenge. But it would mostly be custom code, not much hacking other than to get the button functional.

A "back" or "last page" button can rename all the files over again, bringing back the old saves. :D

To make it easier, maybe we can use the space of the game11.sav for the new forward and back buttons. This way, no wdf table editing required. Only renaming the buttons and switching its function. One textbox turn into page button fwd, the other into page back. Last sav can have a single entry to the side, and saves 1-10 can be standard slots used. Each page realistically having 11 saves (one is the last/auto sav) and 10 game saves per "page". As I expect I think the hardest part of this process would be switching the button wdf from toggle button to page next functional.
As far as I know no one has added a "new" function to any button or scroll bar, we have only extended current functions. :wink:
User avatar
Tethys
Past Administrator
Past Administrator
Posts: 2404
Joined: Fri Jul 18, 2008 2:00 am
Location: Your mom's bed ;)
Contact:

Re: more savegames

Post by Tethys »

No, no scrollbar. A simple button on the UI which will basically rename all the saves in situ. Clear the memory so the old text labels disappear and presto... sounds easier than it probably is, but I know someone who would know if it's a better idea than extending the code or not ;)

And a "new" button might not even need to be added, just one of the preexisting save buttons repurposed to function as one. That preexisting button would become the rename-saves button (next page button) and would also clear the memory after renaming the files so the text labels are blank. One of the saves would become non functional, but can increase the saves amount by (as much drive space as you have)

The best part is that the save entries are already buttons themselves (toggle, but buttons nonetheless). Location of and understanding the save button functions will be critical. One will need to be disabled and repurposed ( > relocation). From there new function for rename routine based on previously seen rename auto save subroutine: > game0 = last.sav slot > game11.sav button = "Next Page" aka "rename all save" button > rename all saves from game1-10 to game12-21 > clear memory/refresh > create blank save files game1-10.sav

Code: Select all

00438655         call    rename_file_EAX_into_name_EDX     ; auto.sav -> last.sav
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: 7965
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: more savegames

Post by thunderchero »

Hi Everyone,

Here is a little patch for changing default saved game description when saved.

game0 slot was old way, game1 slot is after patch
saved_name.jpg
saved_name.jpg (209.78 KiB) Viewed 632 times
saved game galaxy name.patch
(558 Bytes) Downloaded 16 times

Code: Select all

NAME: Changes saved game name %1 %d2 %3 %4 %5 -> %1 Turn %d2
AUTHOR: thunderchero
DESC: This patch omits galaxy, type, size from saved game galaxy description
DESC: patch file name: saved game galaxy name.patch
URL: https://www.armadafleetcommand.com/onscreen/botf/viewtopic.php?p=60384#p60384
TAG: 

# >>  = vanilla/original value

# <<  = new value



>> 0x000ef109 0f 84 f1
>> 0x000ef10e 00
>> 0x0017ff63 25 64 32 20 25 33 20 25 34 20 25 35

<< 0x000ef109 e9 40 01
<< 0x000ef10e 90
<< 0x0017ff63 54 75 72 6e 20 25 64 32 00 00 00 00
note; this patch skips MP text
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7965
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

slot 12 to last.sav

Post by thunderchero »

here is next one Changes saved slot 12 to last.sav
Changes saved slot 12.patch
(474 Bytes) Downloaded 16 times
Changes_saved_slot_12_files.zip
(32.83 KiB) Downloaded 16 times
last.jpg
last.jpg (210.72 KiB) Viewed 584 times

Code: Select all

NAME: Changes saved slot 12 to last.sav
AUTHOR: thunderchero
DESC: This patch Changes saved slot 12 to last.sav
DESC: Notice!! additional files are needed to be added to stbof.res
DESC: patch file name: Changes saved slot 12.patch
URL: https://www.armadafleetcommand.com/onscreen/botf/viewtopic.php?p=60390#p60390
TAG: 

# >>  = vanilla/original value

# <<  = new value

>> 0x0176100 6C 61 73 74 2E 73 61 76 00 00

<< 0x0176100 67 61 6D 65 31 31 2E 73 61 76
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1961
Joined: Sun Apr 27, 2008 2:00 am

Re: Adding save folder

Post by Spocks-cuddly-tribble »

thunderchero wrote: Thu Oct 05, 2023 4:30 pm
Spocks-cuddly-tribble wrote: Tue Oct 03, 2023 10:48 pm But loading such custom name sav files might be tricky in ASM (size limit 0xC). Albeit MPR++ code should be able to do it?
That's not what I meant. You still have to move and re-name the files manually to "game[0-11].sav" to use/load them in BotF?
Untested point is that the file name is also stored in the gameInfo file of the saved game, so there can be deviations when manually re-naming the files.
So you might name it game6.sav but the gameInfo still says game0.sav. Will this cause issues with certain loop codes for slots or is the data unused?

And will your patch overwrite older games without issues when starting new games?
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: 7965
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: Adding save folder

Post by thunderchero »

Spocks-cuddly-tribble wrote: Thu Oct 05, 2023 9:11 pm
thunderchero wrote: Thu Oct 05, 2023 4:30 pm
Spocks-cuddly-tribble wrote: Tue Oct 03, 2023 10:48 pm But loading such custom name sav files might be tricky in ASM (size limit 0xC). Albeit MPR++ code should be able to do it?
That's not what I meant. You still have to move and re-name the files manually to "game[0-11].sav" to use/load them in BotF?
Untested point is that the file name is also stored in the gameInfo file of the saved game, so there can be deviations when manually re-naming the files.
So you might name it game6.sav but the gameInfo still says game0.sav. Will this cause issues with certain loop codes for slots or is this info unused?

And will your patch overwrite older games no issues when starting new games with the same empire?
Like I told Tethys, changing function of widget in this GUI has not been done before (in assembly). And I don't think I could do it myself.

I look at this patch more for AI diag, So if you want to see how AI progress you can see where and why they might be getting stuck.
And yes each save would have to be renamed and moved to install path to load.

as to "Untested point is that the file name is also stored in the gameInfo file of the saved game"
after looking at current files compared I have removed patch from previous post.
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1961
Joined: Sun Apr 27, 2008 2:00 am

Re: Adding save folder

Post by Spocks-cuddly-tribble »

thunderchero wrote: Thu Oct 05, 2023 9:54 pmas to "Untested point is that the file name is also stored in the gameInfo file of the saved game"
after looking at current files compared I have removed patch from previous post.
Don't let this discourage you, its a great patch :up: and there is a good chance the filename in gameInfo is not even read when loading games (BotF... :mad: ).
In this case we have no issue. :wink: Should be easy to test by just switching names of random sav files and looking for issues.

EDIT: And even if, UE save game editor can just correct the deviation. :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: 7965
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: Adding save folder

Post by thunderchero »

Spocks-cuddly-tribble wrote: Thu Oct 05, 2023 10:10 pm and there is a good chance the filename in gameInfo is not even read when loading games (BotF... :mad: ).
yes file name (written in file, not the actual file name) is loaded when game is loaded at unk_5A28D8
load.jpg
load.jpg (71.03 KiB) Viewed 525 times
Problem is, when I compared files I noticed the folder path was also written to file name. :shock: :dwn:

there is 2 other bytes that do not match, but would need to extract all files from saved files to figure out what the offset is of changed file. But from text in area I expect it is part of game info maybe time saved?
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1961
Joined: Sun Apr 27, 2008 2:00 am

Re: Adding save folder

Post by Spocks-cuddly-tribble »

thunderchero wrote: Fri Oct 06, 2023 11:03 amfile name (written in file, not the actual file name) is loaded when game is loaded at unk_5A28D8
Yes, 5A28D8 is start of the loaded gameInfo file and first 0xC bytes is supposed file name, but BotF might never use this data?
When handling the actual files it might just compose the file names via dynamic strings for slot loops?

Just rename that sav file, load it ingame and save again (now without patch).
Then you see possible issues and/or what happens with the filename entry in start of gameInfo.

thunderchero wrote: Fri Oct 06, 2023 11:03 amthere is 2 other bytes that do not match, but would need to extract all files from saved files to figure out what the offset is of changed file. But from text in area I expect it is part of game info maybe time saved?
If your file names are longer than 0xC your code might also overwrite the start of the ingame save description @ 5A28E5 gameInfo_C_savename ?
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”