Author Topic: [SOLVED] SCI0 - Autosave  (Read 8913 times)

0 Members and 1 Guest are viewing this topic.

Offline Doan Sephim

[SOLVED] SCI0 - Autosave
« on: December 27, 2020, 10:42:15 AM »
How difficult would it be to create an autosave function that runs whenever the player enters a new room?

Ideally, it would always replace the previous autosave file and be located at the top of the restore window with the name "autosave"

I'm looking in the Game script and found the Save method, but I'm not sure how to call this method without producing a window. I'd like this to go on "behind the scenes," as it were.

Code: [Select]
(method (save &tmp [strDescBuf 20] gameNum oldCursor hSound)
(Load rsFONT gSaveRestoreFont)
(Load rsCURSOR gLoadingCursor)
(= oldCursor (self setCursor: gNormalCursor))
(= hSound (Sound pause: 1))
(if (GetSaveDisk TRUE)
(if gPrintDlg (gPrintDlg dispose:))
(= gameNum (Save doit: @strDescBuf))
(if (!= gameNum -1)
(= oldCursor (self setCursor: gLoadingCursor 1))
(if
(not (SaveGame objectName gameNum @strDescBuf gVersion))
(Print
{Your save game disk is full. You must either use another disk or save over an existing saved game.}
#font
0
#button
{OK}
1
)
)
(self setCursor: oldCursor (HaveMouse))
)
(GetSaveDisk FALSE)
)
(Sound pause: hSound)
)

Not having a feature like this isn't a big deal and I place a low priority on implementing it, but it certainly would be nice!

I'm going to experiement with this bit of code here, but if anyone has better ideas or guiding thoughts, let me know.

Code: [Select]
(SaveGame objectName gameNum @strDescBuf gVersion))
« Last Edit: December 27, 2020, 10:03:06 PM by Doan Sephim »


Artificial Intelligence Competition

Offline Kawa

Re: SCI0 - Autosave
« Reply #1 on: December 27, 2020, 04:00:12 PM »
You actually have most of the answer right there already: (SaveGame (gGame name?) 0 "Autosave" gVersion), in perhaps Main::newRoom.

Offline Collector

Re: SCI0 - Autosave
« Reply #2 on: December 27, 2020, 04:27:53 PM »
Has anyone tried decompiling QfG4 yet? It has an autosave.
KQII Remake Pic

Offline Collector

Re: SCI0 - Autosave
« Reply #3 on: December 27, 2020, 04:31:20 PM »
You actually have most of the answer right there already: (SaveGame (gGame name?) 0 "Autosave" gVersion), in perhaps Main::newRoom.

Wouldn't that save on every new room? I would think you would want it to only auto save on entry to a dangerous room. Perhaps have a flag for new room that can be set if there is any danger.
KQII Remake Pic

Offline Kawa

Re: SCI0 - Autosave
« Reply #4 on: December 27, 2020, 04:39:06 PM »
Or just put that line in the init for those specific rooms lol.

How difficult would it be to create an autosave function that runs whenever the player enters a new room?
It wasn't specified that it should only autosave in dangerous rooms~




Has anyone tried decompiling QfG4 yet? It has an autosave.
Picking a random room, 600, I found this at the bottom of its init:
Code: [Select]
(if (and (proc0_4 380) (!= gPrevRoomNum 810))
  (gGame save: true)
)
Notice the extra parameter. Normally, Main::save just calls Game::save. QFG's Glory::save only does that if false or nothing is given. If it's true, it does a lot of stuff but ultimately saves "Automatic Save".
« Last Edit: December 27, 2020, 04:52:13 PM by Kawa »

Offline Collector

Re: SCI0 - Autosave
« Reply #5 on: December 27, 2020, 05:43:16 PM »
Remember that it names the autosave "Automatic Save" and overwrites any previous autosave, so there is more to the save method than previous SCI versions, as I would assume you would realize. Also, the game control has an autosave option for the player to be able to turn it on and off.
KQII Remake Pic

Offline Doan Sephim

Re: SCI0 - Autosave [Solved]
« Reply #6 on: December 27, 2020, 10:02:48 PM »
You actually have most of the answer right there already: (SaveGame (gGame name?) 0 "Autosave" gVersion), in perhaps Main::newRoom.

Yup, this does it very cleanly! Simple and effective. And I suppose I could make a toggle if someone wants to turn off the autosave and have a more *authentic* Sierra game experience :P

Thanks again Kawa!

Here's the code in the Main script if any one needs it:
Code: [Select]
(method (newRoom roomNum picAni)
(DisposePrintDlg)
(Load rsFONT gDeadFont)
(Load rsFONT gDefaultFont)
(Load rsFONT gSaveRestoreFont)
(Load rsCURSOR gNormalCursor)
(Load rsCURSOR gLoadingCursor)
;(SaveGame (gGame name?) 0 "Autosave" gVersion)
(super newRoom: roomNum)
(if (< argc 2)
(= gDefaultPicAni (Random 0 5))
else
(= gDefaultPicAni picAni)
)
(SaveGame (gGame name?) 0 "Autosave" gVersion)

)

Offline Collector

Re: [SOLVED] SCI0 - Autosave
« Reply #7 on: January 03, 2021, 01:04:15 PM »
Can you call it a "more *authentic* Sierra game experience" when QfG4 had it?
KQII Remake Pic

Offline Doan Sephim

Re: [SOLVED] SCI0 - Autosave
« Reply #8 on: January 04, 2021, 12:29:01 AM »
Can you call it a "more *authentic* Sierra game experience" when QfG4 had it?
Showing my ignorance here. I never played QfG4! Watched my bro play it a million times, but never got familiar with it's save features.

My guess would be that "auto-save" and "Sierra adventure" are two terms not generally thought of together, outliers notwithstanding.

Offline Charles

Re: [SOLVED] SCI0 - Autosave
« Reply #9 on: January 05, 2021, 09:10:08 AM »
QfG3 had autosave, too... although they only used it like 2 or 3 times, if I recall right.

Offline Kawa

Re: [SOLVED] SCI0 - Autosave
« Reply #10 on: January 05, 2021, 11:12:32 AM »
QfG3 had autosave, too... although they only used it like 2 or 3 times, if I recall right.
Confirmed, looks about the same as in QfG4. Twelve hits for (gGame save: 1).

Offline Doan Sephim

Re: [SOLVED] SCI0 - Autosave
« Reply #11 on: July 11, 2023, 11:26:03 PM »
While the autosave feature does work as intended, it does have a side effect that I'm not sure how to best handle.

With the autosave code in, it has led to the "change directory" button in the "save game" window to cause a "oops! You tried something" error and crashes. Not sure how to fix that. If worse comes to worst, I could just delete the "change directory" button from the game. I think that would bother less than 1% of people.

Any ideas?

Offline Kawa

Re: [SOLVED] SCI0 - Autosave
« Reply #12 on: July 12, 2023, 02:54:10 AM »
Does it also happen in ScummVM? That might give more information.

Online lskovlun

Re: [SOLVED] SCI0 - Autosave
« Reply #13 on: July 12, 2023, 08:41:25 AM »
I wouldn't recommend testing against ScummVM in this case (is that a first?), at least not at first. ScummVM does weird things in order to cope with unusual saving schemes in various games (think Phantas, Shivers, Mother Goose...).  Also replaces the save UI.

Offline Kawa

Re: [SOLVED] SCI0 - Autosave
« Reply #14 on: July 12, 2023, 09:28:03 AM »
Well, unless you can find a debug build of the correct SCI so you can see the whole error message instead of only a number...

Also, you can turn off the new save UI.


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.028 seconds with 23 queries.