From 86b6b5b73d779d82f0384abf30200a3415a5ed20 Mon Sep 17 00:00:00 2001
From: "p.kosyh"
Date: Mon, 7 Jun 2010 06:42:01 +0000
Subject: [PATCH] -1 save fix, go fix
---
src/sdl-instead/game.c | 4 +++-
src/sdl-instead/unix.c | 17 +++++++++--------
src/sdl-instead/windows.c | 19 ++++++++++---------
stead/stead.lua | 28 ++++++++++++++++++++--------
4 files changed, 42 insertions(+), 26 deletions(-)
diff --git a/src/sdl-instead/game.c b/src/sdl-instead/game.c
index bc41546..9b0eb82 100644
--- a/src/sdl-instead/game.c
+++ b/src/sdl-instead/game.c
@@ -356,10 +356,12 @@ int game_load(int nr)
s = game_save_path(0, nr);
if (s && !access(s, R_OK)) {
char cmd[PATH_MAX];
+ char sav[PATH_MAX];
+ strcpy(sav, s);
snprintf(cmd, sizeof(cmd) - 1, "load %s", s);
game_cmd(cmd);
if (nr == -1)
- unlink(s);
+ unlink(sav);
return 0;
}
return -1;
diff --git a/src/sdl-instead/unix.c b/src/sdl-instead/unix.c
index b56f91c..f64496f 100644
--- a/src/sdl-instead/unix.c
+++ b/src/sdl-instead/unix.c
@@ -24,6 +24,7 @@
#endif
static char save_path[PATH_MAX];
+static char cfg_path[PATH_MAX];
static char local_games_path[PATH_MAX];
static char local_themes_path[PATH_MAX];
@@ -196,17 +197,17 @@ char *game_cfg_path(void)
pw = getpwuid(getuid());
if (!pw)
return NULL;
- snprintf(save_path, sizeof(save_path) - 1 , "%s/.insteadrc", pw->pw_dir); /* at home */
- if (!access(save_path, R_OK))
- return save_path;
+ snprintf(cfg_path, sizeof(cfg_path) - 1 , "%s/.insteadrc", pw->pw_dir); /* at home */
+ if (!access(cfg_path, R_OK))
+ return cfg_path;
/* no at home? Try in dir */
if (app)
- snprintf(save_path, sizeof(save_path) - 1 , "%s/", app);
- if (!app || (mkdir(save_path, S_IRWXU) && errno != EEXIST))
- snprintf(save_path, sizeof(save_path) - 1 , "%s/.insteadrc", pw->pw_dir); /* fallback to home */
+ snprintf(cfg_path, sizeof(cfg_path) - 1 , "%s/", app);
+ if (!app || (mkdir(cfg_path, S_IRWXU) && errno != EEXIST))
+ snprintf(cfg_path, sizeof(cfg_path) - 1 , "%s/.insteadrc", pw->pw_dir); /* fallback to home */
else
- snprintf(save_path, sizeof(save_path) - 1 , "%s/insteadrc", app);
- return save_path;
+ snprintf(cfg_path, sizeof(cfg_path) - 1 , "%s/insteadrc", app);
+ return cfg_path;
}
char *game_save_path(int cr, int nr)
diff --git a/src/sdl-instead/windows.c b/src/sdl-instead/windows.c
index 2d189d2..688bd6a 100644
--- a/src/sdl-instead/windows.c
+++ b/src/sdl-instead/windows.c
@@ -18,6 +18,7 @@ static char local_games_path[PATH_MAX];
static char local_themes_path[PATH_MAX];
static char save_path[PATH_MAX];
+static char cfg_path[PATH_MAX];
void nsleep(int u)
{
@@ -170,17 +171,17 @@ char *game_cfg_path( void )
if (!p)
return NULL;
- snprintf(save_path, sizeof(save_path) - 1 , "%src", p); /* appdir/insteadrc ;) */
- if (!access(save_path, R_OK))
- return save_path;
+ snprintf(cfg_path, sizeof(cfg_path) - 1 , "%src", p); /* appdir/insteadrc ;) */
+ if (!access(cfg_path, R_OK))
+ return cfg_path;
/* no at home? Try in dir */
- snprintf(save_path, sizeof(save_path) - 1 , "%s", p);
- if (mkdir(save_path) && errno != EEXIST) {
- snprintf(save_path, sizeof(save_path) - 1 , "%src", p); /* appdir/insteadrc ;) */
- return save_path;
+ snprintf(cfg_path, sizeof(cfg_path) - 1 , "%s", p);
+ if (mkdir(cfg_path) && errno != EEXIST) {
+ snprintf(cfg_path, sizeof(cfg_path) - 1 , "%src", p); /* appdir/insteadrc ;) */
+ return cfg_path;
}
- snprintf(save_path, sizeof(save_path) - 1 , "%s/insteadrc", p);
- return save_path;
+ snprintf(cfg_path, sizeof(cfg_path) - 1 , "%s/insteadrc", p);
+ return cfg_path;
}
char *game_save_path( int cr, int nr )
diff --git a/stead/stead.lua b/stead/stead.lua
index ee0bf19..0d3a0e4 100644
--- a/stead/stead.lua
+++ b/stead/stead.lua
@@ -1082,8 +1082,19 @@ end
function go(self, where, back)
local was = self.where;
local need_scene = false;
+
+ local ret
+
+ if not stead.in_goto_call then
+ ret = function(rc) stead.in_goto_call = false return nil end
+ else
+ ret = function(rc) return rc end
+ end
+
+ stead.in_goto_call = true
+
if where == nil then
- return nil,false
+ return nil,ret(false)
end
if not isRoom(ref(where)) then
error ("Trying to go nowhere: "..where);
@@ -1102,7 +1113,7 @@ function go(self, where, back)
v,r = call(ref(self.where), 'exit', where);
stead.in_exit_call = nil
if r == false then
- return v, r
+ return v, ret(r)
end
end
@@ -1111,7 +1122,7 @@ function go(self, where, back)
if not back or not isDialog(ref(self.where)) or isDialog(ref(where)) then
v, r = call(ref(where), 'enter', self.where);
if r == false then
- return v, r
+ return v, ret(r)
end
need_scene = true;
if ref(was) ~= ref(self.where) then -- jump !!!
@@ -1135,7 +1146,8 @@ function go(self, where, back)
stead.in_entered_call = false
res = par('^^',res,v);
-
+
+ ret();
if need_scene then -- or isForcedsc(ref(where)) then -- i'am not sure...
return par('^^',res,ref(where):scene());
end
@@ -1144,16 +1156,16 @@ end
function player_goto(self, where)
- local v = go(self, where, false);
- return v;
+ local v, r = go(self, where, false);
+ return v, r;
end
function player_go(self, where)
local w = ref(self.where).way:srch(where);
if not w then
return nil,false
end
- local v = go(self, w, false);
- return v;
+ local v, r = go(self, w, false);
+ return v, r;
end
function player_save(self, name, h)