-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);
|
s = game_save_path(0, nr);
|
||||||
if (s && !access(s, R_OK)) {
|
if (s && !access(s, R_OK)) {
|
||||||
char cmd[PATH_MAX];
|
char cmd[PATH_MAX];
|
||||||
|
char sav[PATH_MAX];
|
||||||
|
strcpy(sav, s);
|
||||||
snprintf(cmd, sizeof(cmd) - 1, "load %s", s);
|
snprintf(cmd, sizeof(cmd) - 1, "load %s", s);
|
||||||
game_cmd(cmd);
|
game_cmd(cmd);
|
||||||
if (nr == -1)
|
if (nr == -1)
|
||||||
unlink(s);
|
unlink(sav);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static char save_path[PATH_MAX];
|
static char save_path[PATH_MAX];
|
||||||
|
static char cfg_path[PATH_MAX];
|
||||||
static char local_games_path[PATH_MAX];
|
static char local_games_path[PATH_MAX];
|
||||||
static char local_themes_path[PATH_MAX];
|
static char local_themes_path[PATH_MAX];
|
||||||
|
|
||||||
|
@ -196,17 +197,17 @@ char *game_cfg_path(void)
|
||||||
pw = getpwuid(getuid());
|
pw = getpwuid(getuid());
|
||||||
if (!pw)
|
if (!pw)
|
||||||
return NULL;
|
return NULL;
|
||||||
snprintf(save_path, sizeof(save_path) - 1 , "%s/.insteadrc", pw->pw_dir); /* at home */
|
snprintf(cfg_path, sizeof(cfg_path) - 1 , "%s/.insteadrc", pw->pw_dir); /* at home */
|
||||||
if (!access(save_path, R_OK))
|
if (!access(cfg_path, R_OK))
|
||||||
return save_path;
|
return cfg_path;
|
||||||
/* no at home? Try in dir */
|
/* no at home? Try in dir */
|
||||||
if (app)
|
if (app)
|
||||||
snprintf(save_path, sizeof(save_path) - 1 , "%s/", app);
|
snprintf(cfg_path, sizeof(cfg_path) - 1 , "%s/", app);
|
||||||
if (!app || (mkdir(save_path, S_IRWXU) && errno != EEXIST))
|
if (!app || (mkdir(cfg_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/.insteadrc", pw->pw_dir); /* fallback to home */
|
||||||
else
|
else
|
||||||
snprintf(save_path, sizeof(save_path) - 1 , "%s/insteadrc", app);
|
snprintf(cfg_path, sizeof(cfg_path) - 1 , "%s/insteadrc", app);
|
||||||
return save_path;
|
return cfg_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *game_save_path(int cr, int nr)
|
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 local_themes_path[PATH_MAX];
|
||||||
|
|
||||||
static char save_path[PATH_MAX];
|
static char save_path[PATH_MAX];
|
||||||
|
static char cfg_path[PATH_MAX];
|
||||||
|
|
||||||
void nsleep(int u)
|
void nsleep(int u)
|
||||||
{
|
{
|
||||||
|
@ -170,17 +171,17 @@ char *game_cfg_path( void )
|
||||||
if (!p)
|
if (!p)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
snprintf(save_path, sizeof(save_path) - 1 , "%src", p); /* appdir/insteadrc ;) */
|
snprintf(cfg_path, sizeof(cfg_path) - 1 , "%src", p); /* appdir/insteadrc ;) */
|
||||||
if (!access(save_path, R_OK))
|
if (!access(cfg_path, R_OK))
|
||||||
return save_path;
|
return cfg_path;
|
||||||
/* no at home? Try in dir */
|
/* no at home? Try in dir */
|
||||||
snprintf(save_path, sizeof(save_path) - 1 , "%s", p);
|
snprintf(cfg_path, sizeof(cfg_path) - 1 , "%s", p);
|
||||||
if (mkdir(save_path) && errno != EEXIST) {
|
if (mkdir(cfg_path) && errno != EEXIST) {
|
||||||
snprintf(save_path, sizeof(save_path) - 1 , "%src", p); /* appdir/insteadrc ;) */
|
snprintf(cfg_path, sizeof(cfg_path) - 1 , "%src", p); /* appdir/insteadrc ;) */
|
||||||
return save_path;
|
return cfg_path;
|
||||||
}
|
}
|
||||||
snprintf(save_path, sizeof(save_path) - 1 , "%s/insteadrc", p);
|
snprintf(cfg_path, sizeof(cfg_path) - 1 , "%s/insteadrc", p);
|
||||||
return save_path;
|
return cfg_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *game_save_path( int cr, int nr )
|
char *game_save_path( int cr, int nr )
|
||||||
|
|
|
@ -1082,8 +1082,19 @@ end
|
||||||
function go(self, where, back)
|
function go(self, where, back)
|
||||||
local was = self.where;
|
local was = self.where;
|
||||||
local need_scene = false;
|
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
|
if where == nil then
|
||||||
return nil,false
|
return nil,ret(false)
|
||||||
end
|
end
|
||||||
if not isRoom(ref(where)) then
|
if not isRoom(ref(where)) then
|
||||||
error ("Trying to go nowhere: "..where);
|
error ("Trying to go nowhere: "..where);
|
||||||
|
@ -1102,7 +1113,7 @@ function go(self, where, back)
|
||||||
v,r = call(ref(self.where), 'exit', where);
|
v,r = call(ref(self.where), 'exit', where);
|
||||||
stead.in_exit_call = nil
|
stead.in_exit_call = nil
|
||||||
if r == false then
|
if r == false then
|
||||||
return v, r
|
return v, ret(r)
|
||||||
end
|
end
|
||||||
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
|
if not back or not isDialog(ref(self.where)) or isDialog(ref(where)) then
|
||||||
v, r = call(ref(where), 'enter', self.where);
|
v, r = call(ref(where), 'enter', self.where);
|
||||||
if r == false then
|
if r == false then
|
||||||
return v, r
|
return v, ret(r)
|
||||||
end
|
end
|
||||||
need_scene = true;
|
need_scene = true;
|
||||||
if ref(was) ~= ref(self.where) then -- jump !!!
|
if ref(was) ~= ref(self.where) then -- jump !!!
|
||||||
|
@ -1135,7 +1146,8 @@ function go(self, where, back)
|
||||||
stead.in_entered_call = false
|
stead.in_entered_call = false
|
||||||
|
|
||||||
res = par('^^',res,v);
|
res = par('^^',res,v);
|
||||||
|
|
||||||
|
ret();
|
||||||
if need_scene then -- or isForcedsc(ref(where)) then -- i'am not sure...
|
if need_scene then -- or isForcedsc(ref(where)) then -- i'am not sure...
|
||||||
return par('^^',res,ref(where):scene());
|
return par('^^',res,ref(where):scene());
|
||||||
end
|
end
|
||||||
|
@ -1144,16 +1156,16 @@ end
|
||||||
|
|
||||||
|
|
||||||
function player_goto(self, where)
|
function player_goto(self, where)
|
||||||
local v = go(self, where, false);
|
local v, r = go(self, where, false);
|
||||||
return v;
|
return v, r;
|
||||||
end
|
end
|
||||||
function player_go(self, where)
|
function player_go(self, where)
|
||||||
local w = ref(self.where).way:srch(where);
|
local w = ref(self.where).way:srch(where);
|
||||||
if not w then
|
if not w then
|
||||||
return nil,false
|
return nil,false
|
||||||
end
|
end
|
||||||
local v = go(self, w, false);
|
local v, r = go(self, w, false);
|
||||||
return v;
|
return v, r;
|
||||||
end
|
end
|
||||||
|
|
||||||
function player_save(self, name, h)
|
function player_save(self, name, h)
|
||||||
|
|
Reference in a new issue