adventuregamestudio / ags

AGS editor and engine source code
Other
699 stars 160 forks source link

[Q] how is determined whether savegames can be used #1168

Closed rofl0r closed 3 years ago

rofl0r commented 3 years ago

i noticed that after recompiling some source files and repacking a game with agsutils, the savegames were no longer picked up. why is that, and what determines whether savegames are "compatible", and is it possible to workaround those checks somehow ?

ivan-mogilko commented 3 years ago

Could you clarify what exactly happened, was there an error message, or ags stopped seeing the save files and their list was empty?

rofl0r commented 3 years ago

with master branch, the list was empty, with SDL2 branch i see "INVALID SLOT 1" for my old savegame.

ivan-mogilko commented 3 years ago

I think this supposed to happen only if save has unsupported format, although I cannot explain difference between master and sdl2 branch. It's also possible that master branch has got a new regression. Which branch (or tag etc) did you use to create these saves?

EDIT: Could you attach one of those saves?

rofl0r commented 3 years ago

i used master from like 2 days ago, with about 5 custom patches backported, however they're all related to debug info only when --fps switch is added, and SDL2 branch from yesterday respectively.

attaching my repacked larry2 game with saves (recompiled all room sources with ascc to remove the string corruption). larry2_repack.zip

rofl0r commented 3 years ago

It currently finds two saves: one of them is indicated as "INVALID SLOT".

right, i didn't know which one was the good and which one the bad save.

Pushed a fix into master

cool, thanks!

btw regarding the issue with CTRL-E not being picked up with --fps in the intro of 10 minutes - should i open a new issue for that ?

rofl0r commented 3 years ago

mentioned commit is https://github.com/adventuregamestudio/ags/commit/7a8aa7077d084266295802dc1805d56abccacbc1 btw

ivan-mogilko commented 3 years ago

Sorry, there seem to be more problems. I think what is happening is that game sees "agssave.001_" when scanning for save files, but when trying to load or preload one it uses wrong assumption (default name pattern) and forms "agssave.001" name instead, which fails to open ofcourse.

I need to take a break and look into this again, because there is inconsistent logic in two or more places in the engine where it searches for save files. EDIT: eh, and also there seem to be a big chunk of code duplicated twice with minor differences.

ivan-mogilko commented 3 years ago

btw regarding the issue with CTRL-E not being picked up with --fps in the intro of 10 minutes - should i open a new issue for that ?

Yes, I think this may be fixed.

ivan-mogilko commented 3 years ago

Pushed few more fixes, this commit fe1617c7bae242a0ee90723f41c1e3cfb7a8ae47 in particular corrects search pattern to avoid including files with similar but not exact match. Now files like "agssave.001_" will be simply ignored. I believe this should be an intended behavior, unless someone has another opinion?

rofl0r commented 3 years ago

i wonder how agssave.001_ came to exist in the first place ?

ivan-mogilko commented 3 years ago

I don't know, it was in the archive you sent me, and I assumed you just made a backup of older save?

If you did not, then something strange happened.

ivan-mogilko commented 3 years ago

By the way, I must mention, this game seem to have the old script bug from default game template, where it would incorrectly overwrite existing slot instead of creating a new one if one of the early slot numbers is missing.

Because earlier engine was adding "agssave.001_" into the list this problem was averted, but now when it does not the game practically stops creating new saves. To fix this you have to add missing "agssave.001" file into saves dir.

rofl0r commented 3 years ago

If you did not, then something strange happened.

indeed, i didn't, so the engine must be to blame.

old script bug from default game template

do you have some reference for this? is this an issue with the example game shipped with old ags versions ?

To fix this you have to add missing "agssave.001" file into saves dir.

can i just create an empty file of that name ?

ivan-mogilko commented 3 years ago

Well, I could not figure out a reason why an underscore may be added to the file name, so unless there's a way to reproduce this I would not know how to address it.

do you have some reference for this? is this an issue with the example game shipped with old ags versions ?

Not example game, but the template, used as a starting set of files for a game project. We actually have an old commit that fixed it in template called "Default Game": https://github.com/adventuregamestudio/ags-template-source/commit/b0928130201d4f81d8c61b2421179916ba8e787a

can i just create an empty file of that name ?

Yes, I think, except it will be displayed as "invalid slot".

rofl0r commented 3 years ago

We actually have an old commit that fixed it in template called "Default Game": adventuregamestudio/ags-template-source@b092813

oh wow, i didn't know of this repo. this is super-helpful for reversing old games

rofl0r commented 3 years ago

this is super-helpful for reversing old games

on this topic... i noticed old studio versions ship these as .agt files. are you aware of any tool to extract them, or some code in ags repo (current or past) that can open them ?

// edit: oh nice, agstract can already extract them. editor.dat contains the sourcecode for globalscript etc

ivan-mogilko commented 3 years ago

We still do use these, and these are same format as game package iirc (CLIB), only include project source rather than compiled game.

We also have a repository with agt, this is where our build system picks them up for packaging the editor release: https://github.com/adventuregamestudio/ags-templates/tree/master/Templates

rofl0r commented 3 years ago

on this topic, i created a github org and website https://ags-archives.github.io/ currently it has all old AGS (not AC) engine versions (extracted) and extracted ags-help.chm for each version. the latter proofed really useful for patching agsdefns.sh to support compiling older source code with agscc, the former contains also all versions of demo/empty game templates shipped. next project on the list is to make a repo that has ags-template-source for each version (with each commit being a diff over the last version). if you're interested you will get immediate r/w access.

ivan-mogilko commented 3 years ago

I'll keep that in mind, but that seem to be mostly useful for analyzing and reverse engineering older games, which is not my priority at the moment. Perhaps it will be more of use to scummvm developers. A while ago someone told me there are people interested in finding much older engine sources (I managed to pass this request to Chris Jones, but he said even if there's anything left - it's on his old computer to which he currently does not have an access).

In regards to this ticket, is the problem with saves resolved?

rofl0r commented 3 years ago

A while ago someone told me there are people interested in finding much older engine sources

indeed, yesterday i had the same idea and wanted to decompile ags 2.7.2, but retdec has removed their online decompiler since they went open-source. the main interest of the older versions is that they run without .net framework, and the ancient wine version i got working can only run plain win32 binaries. having source for such a version would allow to link it against microwindows, libwine, or bgui2 which all emulate win32 api for gui and so have a native editor that could be used cross-platform. 2.6.2 is also interesting because it's the last version before OOP-bloat was introduced, it would allow one to create slim and fast-running games. if CJ could dig out the sources for those that would be great.

In regards to this ticket, is the problem with saves resolved?

i didn't test yet because i'm currently on sdl2 branch due to midi support. one thing that strikes me as a bit awkward is that i have to manually create the 000 file to make it work. wouldn't it easy to deal with this in the engine code ?

ivan-mogilko commented 3 years ago

one thing that strikes me as a bit awkward is that i have to manually create the 000 file to make it work. wouldn't it easy to deal with this in the engine code ?

I don't think save slot 000 is used by ags, are you refering to the problem I mentioned above? If so, it's not engine's issue, it's a bug in the script where it always writes new save in the slot index = number of existing saves + 1, disregarding actual existing slot indexes.

rofl0r commented 3 years ago

are you refering to the problem I mentioned above?

yes, ok - i see now. is it possible you merge the improvements into SDL2 branch ?

actually i noticed that it's custom in AGS development to merge one branch into another, i don't know whether that's the best approach as it probably results in lots of merge errors that need to be fixed manually each time (and ugly merge commits making the history non-linear). i used to use another approach for similar undertakings: git cherry-pick with specific commits or extracting them to patches by running git format-patch on the branch having the improvements, and then applying them with git am. if a patch produces a merge error the am process can be aborted with git am --abort and the patch manually edited (e.g. by removing hunks that don't apply) or if that's too much work just applying the patch contents manually.

ivan-mogilko commented 3 years ago

is it possible you merge the improvements into SDL2 branch

Yes I could do that.

actually i noticed that it's custom in AGS development to merge one branch into another, i don't know whether that's the best approach as it probably results in lots of merge errors that need to be fixed manually each time (and ugly merge commits making the history non-linear).

I see what you mean, guess it was mostly thing of habit, but there seemed to be at least one advantage in such approach: it's that you are merging only final state which means you have to solve both code and logical conflicts only once. There was a situation in the past when we had to merge a branch segment by segment though... but they were developed apart for too long. Though I hope at some point there will be only ags3 and ags4, and eventually they will just be too separate to merge them into each other, so we'll be forced to use cherry picks and patches anyway to port fixes and whatnot.

ivan-mogilko commented 3 years ago

@rofl0r is this question resolved?

Speaking of the save file getting '_' added to the name, the only thing I know when anything is appended to the save file name is when game has a custom save suffix set up in data. But such suffix is always preceded by '.', so it does not match the case either. Unless there was a bug with a twist of some sort.

rofl0r commented 3 years ago

yes, i guess so. i still didnt get around yet to test larry 2 again, but if there are still issues with savegames i'll open a new ticket.