autosave from game
This commit is contained in:
parent
2ade66d7d3
commit
1f8801a9f0
1
debian/changelog
vendored
1
debian/changelog
vendored
|
@ -15,6 +15,7 @@ instead (1.0.0) unstable; urgency=low
|
||||||
* f8/f9 - quicksave/quickload
|
* f8/f9 - quicksave/quickload
|
||||||
* game.enable_save
|
* game.enable_save
|
||||||
* lua stack overflow???
|
* lua stack overflow???
|
||||||
|
* autosave function
|
||||||
|
|
||||||
-- Peter Kosyh <p.kosyh@gmail.com> Tue, 3 Nov 2009 19:43:00 +0400
|
-- Peter Kosyh <p.kosyh@gmail.com> Tue, 3 Nov 2009 19:43:00 +0400
|
||||||
|
|
||||||
|
|
|
@ -998,6 +998,21 @@ void scene_scrollbar(void)
|
||||||
el_draw(el_sup);
|
el_draw(el_sup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void game_autosave(void)
|
||||||
|
{
|
||||||
|
int b,r;
|
||||||
|
if (!curgame_dir)
|
||||||
|
return;
|
||||||
|
instead_eval("return get_autosave();");
|
||||||
|
b = instead_bretval(0);
|
||||||
|
r = instead_iretval(1);
|
||||||
|
instead_clear();
|
||||||
|
if (b) {
|
||||||
|
r = r % MAX_SAVE_SLOTS;
|
||||||
|
game_save(r);
|
||||||
|
/* instead_eval("game.autosave = false;"); instead_clear(); */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void dec_music(void *data)
|
static void dec_music(void *data)
|
||||||
{
|
{
|
||||||
|
@ -1209,8 +1224,10 @@ int game_cmd(char *cmd)
|
||||||
|
|
||||||
cmdstr = instead_cmd(cmd); instead_clear();
|
cmdstr = instead_cmd(cmd); instead_clear();
|
||||||
// goto err;
|
// goto err;
|
||||||
|
|
||||||
game_music_player();
|
game_music_player();
|
||||||
game_sound_player();
|
game_sound_player();
|
||||||
|
game_autosave();
|
||||||
|
|
||||||
if (!cmdstr)
|
if (!cmdstr)
|
||||||
goto inv; /* hackish? ok, yes it is... */
|
goto inv; /* hackish? ok, yes it is... */
|
||||||
|
|
|
@ -136,6 +136,17 @@ int instead_bretval(int n)
|
||||||
return lua_toboolean(L, n - N);
|
return lua_toboolean(L, n - N);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int instead_iretval(int n)
|
||||||
|
{
|
||||||
|
int N;
|
||||||
|
if (!L)
|
||||||
|
return 0;
|
||||||
|
N = lua_gettop(L); /* number of arguments */
|
||||||
|
if (n - N >= 0)
|
||||||
|
return 0;
|
||||||
|
return lua_tonumber(L, n - N);
|
||||||
|
}
|
||||||
|
|
||||||
char *instead_cmd(char *s)
|
char *instead_cmd(char *s)
|
||||||
{
|
{
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
|
|
@ -9,6 +9,7 @@ extern int instead_eval(char *s);
|
||||||
extern int instead_clear(void);
|
extern int instead_clear(void);
|
||||||
extern char *instead_retval(int n);
|
extern char *instead_retval(int n);
|
||||||
extern int instead_bretval(int n);
|
extern int instead_bretval(int n);
|
||||||
|
extern int instead_iretval(int n);
|
||||||
char *fromgame(const char *s);
|
char *fromgame(const char *s);
|
||||||
extern int instead_encode(const char *s, const char *d);
|
extern int instead_encode(const char *s, const char *d);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1290,7 +1290,8 @@ function game(v)
|
||||||
end
|
end
|
||||||
|
|
||||||
function isEnableSave()
|
function isEnableSave()
|
||||||
if game.enable_save == nil then
|
if game.enable_save == nil or get_autosave() then
|
||||||
|
game.autosave = false -- we have only one try for autosave ;)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return call_bool(game, 'enable_save');
|
return call_bool(game, 'enable_save');
|
||||||
|
@ -2077,6 +2078,15 @@ if is_sound == nil then
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function autosave(slot)
|
||||||
|
game.autosave = true;
|
||||||
|
game.autosave_slot = slot;
|
||||||
|
end
|
||||||
|
|
||||||
|
function get_autosave()
|
||||||
|
return game.autosave, game.autosave_slot
|
||||||
|
end
|
||||||
|
|
||||||
function get_sound()
|
function get_sound()
|
||||||
return game._sound, game._sound_channel, game._sound_loop;
|
return game._sound, game._sound_channel, game._sound_loop;
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue