-1 save fix, go fix
This commit is contained in:
parent
65fd023bc0
commit
86b6b5b73d
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 )
|
||||
|
|
|
@ -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 !!!
|
||||
|
@ -1136,6 +1147,7 @@ function go(self, where, back)
|
|||
|
||||
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)
|
||||
|
|
Reference in a new issue