wince initial support
This commit is contained in:
parent
164d701ab3
commit
8f16637598
|
@ -1,4 +1,4 @@
|
||||||
VERSION := 1.2.1
|
VERSION := 1.2.2
|
||||||
|
|
||||||
PREFIX=./
|
PREFIX=./
|
||||||
DESTDIR=
|
DESTDIR=
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Contributor: Peter Kosyh <p.kosyhgmail.com>
|
# Contributor: Peter Kosyh <p.kosyhgmail.com>
|
||||||
pkgname=instead
|
pkgname=instead
|
||||||
pkgver=1.2.1
|
pkgver=1.2.2
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc="instead quest interpreter"
|
pkgdesc="instead quest interpreter"
|
||||||
arch=('i686' 'x86_64')
|
arch=('i686' 'x86_64')
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
VERSION := 1.2.1
|
VERSION := 1.2.2
|
||||||
|
|
||||||
DESTDIR=
|
DESTDIR=
|
||||||
BIN=
|
BIN=
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
VERSION := 1.2.1
|
VERSION := 1.2.2
|
||||||
|
|
||||||
DESTDIR=
|
DESTDIR=
|
||||||
BIN=
|
BIN=
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
VERSION := 1.2.1
|
VERSION := 1.2.2
|
||||||
|
|
||||||
PREFIX=/usr/local
|
PREFIX=/usr/local
|
||||||
DESTDIR=
|
DESTDIR=
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
VERSION := 1.2.1
|
VERSION := 1.2.2
|
||||||
|
|
||||||
PREFIX=./
|
PREFIX=./
|
||||||
DESTDIR=
|
DESTDIR=
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
VERSION := 1.2.1
|
VERSION := 1.2.2
|
||||||
|
|
||||||
PREFIX=
|
PREFIX=
|
||||||
DESTDIR=
|
DESTDIR=
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Encoding=UTF-8
|
Encoding=UTF-8
|
||||||
Version=1.2.1
|
Version=1.2.2
|
||||||
Type=Application
|
Type=Application
|
||||||
Name=INSTEAD
|
Name=INSTEAD
|
||||||
Name[ru]=INSTEAD
|
Name[ru]=INSTEAD
|
||||||
|
|
|
@ -13,7 +13,7 @@ body { font-family: Verdana, Arial, Helvetica, sans-serif;
|
||||||
</style>
|
</style>
|
||||||
<title>INSTEAD -- interpreter of simple text adventures for Unix and Windows</title>
|
<title>INSTEAD -- interpreter of simple text adventures for Unix and Windows</title>
|
||||||
</head><body bgcolor="#f0f0f0">
|
</head><body bgcolor="#f0f0f0">
|
||||||
<h2>INSTEAD 1.2.1</h2>
|
<h2>INSTEAD 1.2.2</h2>
|
||||||
<p>INSTEAD -- interpreter of simple text adventures for Unix and Windows.<br>
|
<p>INSTEAD -- interpreter of simple text adventures for Unix and Windows.<br>
|
||||||
INSTEAD was designed to interpret the games that are the mix of visual novels, text quests and classical 90'ss quests.</p>
|
INSTEAD was designed to interpret the games that are the mix of visual novels, text quests and classical 90'ss quests.</p>
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.TH INSTEAD 6 "Version 1.2.1" Instead GAMES
|
.TH INSTEAD 6 "Version 1.2.2" Instead GAMES
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
INSTEAD 1.2.1
|
INSTEAD 1.2.2
|
||||||
=============
|
=============
|
||||||
|
|
||||||
WARNING! For successfull building you must install these development packages (names may vary in your distribution):
|
WARNING! For successfull building you must install these development packages (names may vary in your distribution):
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
[Setup]
|
[Setup]
|
||||||
AppName=INSTEAD-KIT
|
AppName=INSTEAD-KIT
|
||||||
AppVerName=INSTEAD 1.2.1
|
AppVerName=INSTEAD 1.2.2
|
||||||
DefaultDirName={pf}\Pinebrush games\INSTEAD
|
DefaultDirName={pf}\Pinebrush games\INSTEAD
|
||||||
DefaultGroupName=Pinebrush games
|
DefaultGroupName=Pinebrush games
|
||||||
UninstallDisplayIcon={app}\sdl-instead.exe
|
UninstallDisplayIcon={app}\sdl-instead.exe
|
||||||
OutputDir=.
|
OutputDir=.
|
||||||
OutputBaseFilename=instead-kit-1.2.1
|
OutputBaseFilename=instead-kit-1.2.2
|
||||||
AllowNoIcons=true
|
AllowNoIcons=true
|
||||||
|
|
||||||
[Languages]
|
[Languages]
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
[Setup]
|
[Setup]
|
||||||
AppName=INSTEAD
|
AppName=INSTEAD
|
||||||
AppVerName=INSTEAD 1.2.1
|
AppVerName=INSTEAD 1.2.2
|
||||||
DefaultDirName={pf}\Pinebrush games\INSTEAD
|
DefaultDirName={pf}\Pinebrush games\INSTEAD
|
||||||
DefaultGroupName=Pinebrush games
|
DefaultGroupName=Pinebrush games
|
||||||
UninstallDisplayIcon={app}\sdl-instead.exe
|
UninstallDisplayIcon={app}\sdl-instead.exe
|
||||||
OutputDir=.
|
OutputDir=.
|
||||||
OutputBaseFilename=instead-1.2.1
|
OutputBaseFilename=instead-1.2.2
|
||||||
AllowNoIcons=true
|
AllowNoIcons=true
|
||||||
|
|
||||||
[Languages]
|
[Languages]
|
||||||
|
|
|
@ -86,7 +86,7 @@ int game_select(const char *name)
|
||||||
g = game_lookup(name);
|
g = game_lookup(name);
|
||||||
if ((!name || !*name) && !g)
|
if ((!name || !*name) && !g)
|
||||||
return 0;
|
return 0;
|
||||||
if (chdir(game_cwd))
|
if (setdir(game_cwd))
|
||||||
return -1;
|
return -1;
|
||||||
if (g) {
|
if (g) {
|
||||||
char *oldgame = curgame_dir;
|
char *oldgame = curgame_dir;
|
||||||
|
@ -96,11 +96,11 @@ int game_select(const char *name)
|
||||||
curgame_dir = oldgame;
|
curgame_dir = oldgame;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (chdir(g->path)) {
|
if (setdir(g->path)) {
|
||||||
curgame_dir = oldgame;
|
curgame_dir = oldgame;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (instead_load(MAIN_FILE)) {
|
if (instead_load(dirpath(MAIN_FILE))) {
|
||||||
curgame_dir = oldgame;
|
curgame_dir = oldgame;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -128,13 +128,13 @@ int games_rename(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char cwd[PATH_MAX];
|
char cwd[PATH_MAX];
|
||||||
getcwd(cwd, sizeof(cwd));
|
getdir(cwd, sizeof(cwd));
|
||||||
chdir(game_cwd);
|
setdir(game_cwd);
|
||||||
for (i = 0; i < games_nr; i++) {
|
for (i = 0; i < games_nr; i++) {
|
||||||
FREE(games[i].name);
|
FREE(games[i].name);
|
||||||
games[i].name = game_name(games[i].path, games[i].dir);
|
games[i].name = game_name(dirpath(games[i].path), games[i].dir);
|
||||||
}
|
}
|
||||||
chdir(cwd);
|
setdir(cwd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -670,7 +670,7 @@ int counter_fn(int interval, void *p)
|
||||||
|
|
||||||
int game_init(const char *name)
|
int game_init(const char *name)
|
||||||
{
|
{
|
||||||
getcwd(game_cwd, sizeof(game_cwd));
|
getdir(game_cwd, sizeof(game_cwd));
|
||||||
unix_path(game_cwd);
|
unix_path(game_cwd);
|
||||||
|
|
||||||
if (name)
|
if (name)
|
||||||
|
@ -690,12 +690,12 @@ int game_init(const char *name)
|
||||||
if (game_select(name))
|
if (game_select(name))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (curgame_dir && !access(THEME_FILE, R_OK)) {
|
if (curgame_dir && !access(dirpath(THEME_FILE), R_OK)) {
|
||||||
game_own_theme = 1;
|
game_own_theme = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (game_own_theme && opt_owntheme) {
|
if (game_own_theme && opt_owntheme) {
|
||||||
if (theme_load(THEME_FILE))
|
if (theme_load(dirpath(THEME_FILE)))
|
||||||
return -1;
|
return -1;
|
||||||
} else if (curtheme_dir && strcmp(DEFAULT_THEME, curtheme_dir)) {
|
} else if (curtheme_dir && strcmp(DEFAULT_THEME, curtheme_dir)) {
|
||||||
game_theme_load(curtheme_dir);
|
game_theme_load(curtheme_dir);
|
||||||
|
@ -753,7 +753,7 @@ void game_done(int err)
|
||||||
|
|
||||||
if (opt_autosave && curgame_dir && !err)
|
if (opt_autosave && curgame_dir && !err)
|
||||||
game_save(0);
|
game_save(0);
|
||||||
chdir(game_cwd);
|
setdir(game_cwd);
|
||||||
// cfg_save();
|
// cfg_save();
|
||||||
|
|
||||||
if (menu_shown)
|
if (menu_shown)
|
||||||
|
@ -1238,11 +1238,11 @@ void game_music_player(void)
|
||||||
} else if (!last_music && mus) {
|
} else if (!last_music && mus) {
|
||||||
game_stop_mus(500);
|
game_stop_mus(500);
|
||||||
last_music = mus;
|
last_music = mus;
|
||||||
snd_play_mus(mus, 0, loop - 1);
|
snd_play_mus(dirpath(mus), 0, loop - 1);
|
||||||
} else if (strcmp(last_music, mus)) {
|
} else if (strcmp(last_music, mus)) {
|
||||||
game_stop_mus(500);
|
game_stop_mus(500);
|
||||||
last_music = mus;
|
last_music = mus;
|
||||||
snd_play_mus(mus, 0, loop - 1);
|
snd_play_mus(dirpath(mus), 0, loop - 1);
|
||||||
} else
|
} else
|
||||||
free(mus);
|
free(mus);
|
||||||
}
|
}
|
||||||
|
@ -1264,7 +1264,7 @@ static int wavs_pos = 0;
|
||||||
static wav_t sound_add(const char *fname)
|
static wav_t sound_add(const char *fname)
|
||||||
{
|
{
|
||||||
wav_t w;
|
wav_t w;
|
||||||
w = snd_load_wav(fname);
|
w = snd_load_wav(dirpath(fname));
|
||||||
if (!w)
|
if (!w)
|
||||||
return NULL;
|
return NULL;
|
||||||
snd_free_wav(wavs[wavs_pos].wav);
|
snd_free_wav(wavs[wavs_pos].wav);
|
||||||
|
@ -1486,7 +1486,7 @@ int game_cmd(char *cmd)
|
||||||
img_t img;
|
img_t img;
|
||||||
|
|
||||||
if (new_pict) {
|
if (new_pict) {
|
||||||
img = gfx_load_image(pict);
|
img = gfx_load_image(dirpath(pict));
|
||||||
if (el_img(el_spic))
|
if (el_img(el_spic))
|
||||||
gfx_free_image(el_img(el_spic));
|
gfx_free_image(el_img(el_spic));
|
||||||
el(el_spic)->p.p = NULL;
|
el(el_spic)->p.p = NULL;
|
||||||
|
|
|
@ -708,7 +708,7 @@ static img_t _gfx_load_combined_image(char *filename)
|
||||||
} else if (*ep) {
|
} else if (*ep) {
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
img = _gfx_load_image(strip(p));
|
img = _gfx_load_image(dirpath(strip(p)));
|
||||||
if (img)
|
if (img)
|
||||||
img = gfx_display_alpha(img);
|
img = gfx_display_alpha(img);
|
||||||
if (img) {
|
if (img) {
|
||||||
|
@ -1032,8 +1032,11 @@ int gfx_set_mode(int w, int h, int fs)
|
||||||
screen = SDL_SetVideoMode(gfx_width, gfx_height, 16, SDL_DOUBLEBUF | SDL_HWSURFACE | ( ( fs ) ? SDL_FULLSCREEN : 0 ) );
|
screen = SDL_SetVideoMode(gfx_width, gfx_height, 16, SDL_DOUBLEBUF | SDL_HWSURFACE | ( ( fs ) ? SDL_FULLSCREEN : 0 ) );
|
||||||
#endif
|
#endif
|
||||||
if (screen == NULL) {
|
if (screen == NULL) {
|
||||||
fprintf(stderr, "Unable to set %dx%d video: %s\n", w, h, SDL_GetError());
|
screen = SDL_SetVideoMode(0, 0, 0, SDL_ANYFORMAT | SDL_HWSURFACE | ( ( fs ) ? SDL_FULLSCREEN : 0 ) );
|
||||||
return -1;
|
if (!screen) {
|
||||||
|
fprintf(stderr, "Unable to set %dx%d video: %s\n", w, h, SDL_GetError());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
gfx_clear(0, 0, gfx_width, gfx_height);
|
gfx_clear(0, 0, gfx_width, gfx_height);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2550,7 +2553,7 @@ img_t get_img(struct layout *layout, char *p)
|
||||||
img = cache_get(layout->img_cache, p);
|
img = cache_get(layout->img_cache, p);
|
||||||
if (!img) {
|
if (!img) {
|
||||||
unix_path(p);
|
unix_path(p);
|
||||||
if (!(img = gfx_load_image(p)))
|
if (!(img = gfx_load_image(dirpath(p))))
|
||||||
goto out;
|
goto out;
|
||||||
theme_img_scale(&img); /* bad style, no gfx layer :( */
|
theme_img_scale(&img); /* bad style, no gfx layer :( */
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,6 +257,7 @@ typedef struct LoadF {
|
||||||
int extraline;
|
int extraline;
|
||||||
unsigned char byte;
|
unsigned char byte;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
int enc;
|
||||||
unsigned char buff[4096];
|
unsigned char buff[4096];
|
||||||
} LoadF;
|
} LoadF;
|
||||||
|
|
||||||
|
@ -271,11 +272,13 @@ static const char *getF (lua_State *L, void *ud, size_t *size) {
|
||||||
}
|
}
|
||||||
if (feof(lf->f)) return NULL;
|
if (feof(lf->f)) return NULL;
|
||||||
*size = fread(lf->buff, 1, sizeof(lf->buff), lf->f);
|
*size = fread(lf->buff, 1, sizeof(lf->buff), lf->f);
|
||||||
for (i = 0; i < *size; i ++) {
|
if (lf->enc) {
|
||||||
unsigned char b = lf->buff[i];
|
for (i = 0; i < *size; i ++) {
|
||||||
lf->buff[i] ^= lf->byte;
|
unsigned char b = lf->buff[i];
|
||||||
lf->buff[i] = (lf->buff[i] >> 3) | (lf->buff[i] << 5);
|
lf->buff[i] ^= lf->byte;
|
||||||
lf->byte = b;
|
lf->buff[i] = (lf->buff[i] >> 3) | (lf->buff[i] << 5);
|
||||||
|
lf->byte = b;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return (*size > 0) ? (char*)lf->buff : NULL;
|
return (*size > 0) ? (char*)lf->buff : NULL;
|
||||||
}
|
}
|
||||||
|
@ -288,7 +291,7 @@ static int errfile (lua_State *L, const char *what, int fnameindex) {
|
||||||
return LUA_ERRFILE;
|
return LUA_ERRFILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int loadfile (lua_State *L, const char *filename) {
|
static int loadfile (lua_State *L, const char *filename, int enc) {
|
||||||
LoadF lf;
|
LoadF lf;
|
||||||
int status, readstatus;
|
int status, readstatus;
|
||||||
int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */
|
int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */
|
||||||
|
@ -296,6 +299,7 @@ static int loadfile (lua_State *L, const char *filename) {
|
||||||
lua_pushfstring(L, "@%s", filename);
|
lua_pushfstring(L, "@%s", filename);
|
||||||
lf.f = fopen(filename, "rb");
|
lf.f = fopen(filename, "rb");
|
||||||
lf.byte = 0xcc;
|
lf.byte = 0xcc;
|
||||||
|
lf.enc = enc;
|
||||||
if (lf.f == NULL) return errfile(L, "open", fnameindex);
|
if (lf.f == NULL) return errfile(L, "open", fnameindex);
|
||||||
status = lua_load(L, getF, &lf, lua_tostring(L, -1));
|
status = lua_load(L, getF, &lf, lua_tostring(L, -1));
|
||||||
readstatus = ferror(lf.f);
|
readstatus = ferror(lf.f);
|
||||||
|
@ -312,7 +316,15 @@ static int loadfile (lua_State *L, const char *filename) {
|
||||||
static int luaB_doencfile (lua_State *L) {
|
static int luaB_doencfile (lua_State *L) {
|
||||||
const char *fname = luaL_optstring(L, 1, NULL);
|
const char *fname = luaL_optstring(L, 1, NULL);
|
||||||
int n = lua_gettop(L);
|
int n = lua_gettop(L);
|
||||||
if (loadfile(L, fname) != 0) lua_error(L);
|
if (loadfile(L, dirpath(fname), 1) != 0) lua_error(L);
|
||||||
|
lua_call(L, 0, LUA_MULTRET);
|
||||||
|
return lua_gettop(L) - n;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int luaB_dofile (lua_State *L) {
|
||||||
|
const char *fname = luaL_optstring(L, 1, NULL);
|
||||||
|
int n = lua_gettop(L);
|
||||||
|
if (loadfile(L, dirpath(fname), 0) != 0) lua_error(L);
|
||||||
lua_call(L, 0, LUA_MULTRET);
|
lua_call(L, 0, LUA_MULTRET);
|
||||||
return lua_gettop(L) - n;
|
return lua_gettop(L) - n;
|
||||||
}
|
}
|
||||||
|
@ -404,6 +416,7 @@ static int luaB_set_timer(lua_State *L) {
|
||||||
|
|
||||||
static const luaL_Reg base_funcs[] = {
|
static const luaL_Reg base_funcs[] = {
|
||||||
{"doencfile", luaB_doencfile},
|
{"doencfile", luaB_doencfile},
|
||||||
|
{"dofile", luaB_dofile},
|
||||||
{"print", luaB_print}, /* for some mystic, it is needed in win version (with -debug) */
|
{"print", luaB_print}, /* for some mystic, it is needed in win version (with -debug) */
|
||||||
{"is_sound", luaB_is_sound},
|
{"is_sound", luaB_is_sound},
|
||||||
{"get_savepath", luaB_get_savepath},
|
{"get_savepath", luaB_get_savepath},
|
||||||
|
@ -467,11 +480,11 @@ int instead_init(void)
|
||||||
instead_package();
|
instead_package();
|
||||||
instead_lang();
|
instead_lang();
|
||||||
|
|
||||||
if (dofile(L,STEAD_PATH"/stead.lua")) {
|
if (dofile(L, dirpath(STEAD_PATH"/stead.lua"))) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dofile(L,STEAD_PATH"/gui.lua")) {
|
if (dofile(L, dirpath(STEAD_PATH"/gui.lua"))) {
|
||||||
instead_clear();
|
instead_clear();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,3 +194,18 @@ char *open_file_dialog(void)
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int setdir(const char *path)
|
||||||
|
{
|
||||||
|
return chdir(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *getdir(char *path, size_t size)
|
||||||
|
{
|
||||||
|
return getcwd(path, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *dirpath(const char *path)
|
||||||
|
{
|
||||||
|
return (char*)path;
|
||||||
|
}
|
||||||
|
|
|
@ -69,6 +69,29 @@ void macosx_init(void) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32_WCE
|
||||||
|
char *getcurdir(char *path)
|
||||||
|
{
|
||||||
|
char *p;
|
||||||
|
if (path == NULL || *path == '\0')
|
||||||
|
return ".";
|
||||||
|
p = path + strlen(path) - 1;
|
||||||
|
while (*p == '/') {
|
||||||
|
if (p == path)
|
||||||
|
return path;
|
||||||
|
*p-- = '\0';
|
||||||
|
}
|
||||||
|
while (p >= path && *p != '/')
|
||||||
|
p--;
|
||||||
|
return p < path ? "." : p == path ? "/" : (*p = '\0', path);
|
||||||
|
}
|
||||||
|
void wince_init(char *path)
|
||||||
|
{
|
||||||
|
unix_path(path);
|
||||||
|
strcpy(game_cwd, getcurdir(path));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int clean_tmp = 0;
|
int clean_tmp = 0;
|
||||||
|
@ -81,8 +104,13 @@ int main(int argc, char *argv[])
|
||||||
gtk_init(&argc, &argv);
|
gtk_init(&argc, &argv);
|
||||||
#endif
|
#endif
|
||||||
putenv("SDL_MOUSE_RELATIVE=0"); /* test this! */
|
putenv("SDL_MOUSE_RELATIVE=0"); /* test this! */
|
||||||
|
#ifdef _WIN32_WCE
|
||||||
|
wince_init(argv[0]);
|
||||||
|
#else
|
||||||
getcwd(game_cwd, sizeof(game_cwd));
|
getcwd(game_cwd, sizeof(game_cwd));
|
||||||
|
#endif
|
||||||
unix_path(game_cwd);
|
unix_path(game_cwd);
|
||||||
|
setdir(game_cwd);
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
if (!strcmp(argv[i],"-alsa"))
|
if (!strcmp(argv[i],"-alsa"))
|
||||||
alsa_sw = 1;
|
alsa_sw = 1;
|
||||||
|
@ -100,7 +128,7 @@ int main(int argc, char *argv[])
|
||||||
else if (!strcmp(argv[i], "-debug"))
|
else if (!strcmp(argv[i], "-debug"))
|
||||||
debug_sw = 1;
|
debug_sw = 1;
|
||||||
else if (!strcmp(argv[i], "-noautosave"))
|
else if (!strcmp(argv[i], "-noautosave"))
|
||||||
noauto_sw = 1;
|
noauto_sw = 1;
|
||||||
else if (!strcmp(argv[i], "-game")) {
|
else if (!strcmp(argv[i], "-game")) {
|
||||||
if ((i + 1) < argc)
|
if ((i + 1) < argc)
|
||||||
game_sw = argv[++i];
|
game_sw = argv[++i];
|
||||||
|
@ -187,7 +215,7 @@ int main(int argc, char *argv[])
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
menu_langs_lookup(LANG_PATH);
|
menu_langs_lookup(dirpath(LANG_PATH));
|
||||||
|
|
||||||
if (!langs_nr) {
|
if (!langs_nr) {
|
||||||
fprintf(stderr, "No languages found in: %s.\n", LANG_PATH);
|
fprintf(stderr, "No languages found in: %s.\n", LANG_PATH);
|
||||||
|
@ -207,14 +235,14 @@ int main(int argc, char *argv[])
|
||||||
if (games_sw)
|
if (games_sw)
|
||||||
games_lookup(games_sw);
|
games_lookup(games_sw);
|
||||||
|
|
||||||
if (!nostdgames_sw && games_lookup(GAMES_PATH))
|
if (!nostdgames_sw && games_lookup(dirpath(GAMES_PATH)))
|
||||||
fprintf(stderr, "No games found in: %s.\n", GAMES_PATH);
|
fprintf(stderr, "No games found in: %s.\n", GAMES_PATH);
|
||||||
|
|
||||||
if (themes_sw)
|
if (themes_sw)
|
||||||
themes_lookup(themes_sw);
|
themes_lookup(themes_sw);
|
||||||
|
|
||||||
if (!nostdthemes_sw) {
|
if (!nostdthemes_sw) {
|
||||||
themes_lookup(THEMES_PATH);
|
themes_lookup(dirpath(THEMES_PATH));
|
||||||
themes_lookup(game_local_themes_path());
|
themes_lookup(game_local_themes_path());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -819,22 +819,22 @@ int menu_lang_select(const char *name)
|
||||||
char cwd[PATH_MAX];
|
char cwd[PATH_MAX];
|
||||||
if (!name)
|
if (!name)
|
||||||
return -1;
|
return -1;
|
||||||
getcwd(cwd, sizeof(cwd));
|
getdir(cwd, sizeof(cwd));
|
||||||
chdir(game_cwd);
|
setdir(game_cwd);
|
||||||
for (i = 0; i<langs_nr; i ++) {
|
for (i = 0; i<langs_nr; i ++) {
|
||||||
if (!strcmp(langs[i].file, name)) {
|
if (!strcmp(langs[i].file, name)) {
|
||||||
lang_free();
|
lang_free();
|
||||||
if (lang_parse(langs[i].path) || lang_ok()) {
|
if (lang_parse(langs[i].path) || lang_ok()) {
|
||||||
fprintf(stderr,"Error while loading language: %s\n", langs[i].file);
|
fprintf(stderr,"Error while loading language: %s\n", langs[i].file);
|
||||||
chdir(cwd);
|
setdir(cwd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
cur_lang = i;
|
cur_lang = i;
|
||||||
FREE(opt_lang); opt_lang = strdup(langs[i].file);
|
FREE(opt_lang); opt_lang = strdup(langs[i].file);
|
||||||
chdir(cwd);
|
setdir(cwd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
chdir(cwd);
|
setdir(cwd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,12 +51,12 @@ static int parse_include(const char *v, void *data)
|
||||||
char cwd[PATH_MAX];
|
char cwd[PATH_MAX];
|
||||||
if (!strcmp(v, DEFAULT_THEME))
|
if (!strcmp(v, DEFAULT_THEME))
|
||||||
return 0;
|
return 0;
|
||||||
getcwd(cwd, sizeof(cwd));
|
getdir(cwd, sizeof(cwd));
|
||||||
chdir(game_cwd);
|
setdir(game_cwd);
|
||||||
rc = game_theme_load(v);
|
rc = game_theme_load(v);
|
||||||
// if (!rc)
|
// if (!rc)
|
||||||
// game_theme_select(v);
|
// game_theme_select(v);
|
||||||
chdir(cwd);
|
setdir(cwd);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,13 +552,13 @@ int themes_rename(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char cwd[PATH_MAX];
|
char cwd[PATH_MAX];
|
||||||
getcwd(cwd, sizeof(cwd));
|
getdir(cwd, sizeof(cwd));
|
||||||
chdir(game_cwd);
|
setdir(game_cwd);
|
||||||
for (i = 0; i < themes_nr; i++) {
|
for (i = 0; i < themes_nr; i++) {
|
||||||
FREE(themes[i].name);
|
FREE(themes[i].name);
|
||||||
themes[i].name = theme_name(themes[i].path, themes[i].dir);
|
themes[i].name = theme_name(dirpath(themes[i].path), themes[i].dir);
|
||||||
}
|
}
|
||||||
chdir(cwd);
|
setdir(cwd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -582,14 +582,14 @@ int game_theme_load(const char *name)
|
||||||
{
|
{
|
||||||
struct theme *theme;
|
struct theme *theme;
|
||||||
char cwd[PATH_MAX];
|
char cwd[PATH_MAX];
|
||||||
getcwd(cwd, sizeof(cwd));
|
getdir(cwd, sizeof(cwd));
|
||||||
chdir(game_cwd);
|
setdir(game_cwd);
|
||||||
theme = theme_lookup(name);
|
theme = theme_lookup(name);
|
||||||
if (!theme || chdir(theme->path) || theme_load(THEME_FILE)) {
|
if (!theme || setdir(theme->path) || theme_load(dirpath(THEME_FILE))) {
|
||||||
chdir(cwd);
|
setdir(cwd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
chdir(cwd);
|
setdir(cwd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -302,3 +302,18 @@ char *sdl_path(char *p)
|
||||||
unix_path(p);
|
unix_path(p);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int setdir(const char *path)
|
||||||
|
{
|
||||||
|
return chdir(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *getdir(char *path, size_t size)
|
||||||
|
{
|
||||||
|
return getcwd(path, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *dirpath(const char *path)
|
||||||
|
{
|
||||||
|
return (char*)path;
|
||||||
|
}
|
||||||
|
|
|
@ -266,7 +266,7 @@ int parse_full_path(const char *v, void *data)
|
||||||
char **p = ((char **)data);
|
char **p = ((char **)data);
|
||||||
if (*p)
|
if (*p)
|
||||||
free(*p);
|
free(*p);
|
||||||
getcwd(cwd, sizeof(cwd));
|
getdir(cwd, sizeof(cwd));
|
||||||
*p = malloc(strlen(v) + strlen(cwd) + 2);
|
*p = malloc(strlen(v) + strlen(cwd) + 2);
|
||||||
if (!*p)
|
if (!*p)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -31,6 +31,9 @@ extern char *decode(iconv_t hiconv, const char *s);
|
||||||
|
|
||||||
extern void unix_path(char *path);
|
extern void unix_path(char *path);
|
||||||
extern char *sdl_path(char *path);
|
extern char *sdl_path(char *path);
|
||||||
|
extern int setdir(const char *path);
|
||||||
|
extern char *getdir(char *path, size_t size);
|
||||||
|
extern char *dirpath(const char *path);
|
||||||
|
|
||||||
extern char *parse_tag(char *line, const char *tag, const char *comm, int *brk);
|
extern char *parse_tag(char *line, const char *tag, const char *comm, int *brk);
|
||||||
extern int remove_dir(const char *path);
|
extern int remove_dir(const char *path);
|
||||||
|
|
|
@ -102,7 +102,7 @@ char *game_tmp_path(void)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
strcat((char*)lpTempPathBuffer, "/instead-games");
|
strcat((char*)lpTempPathBuffer, "/instead-games");
|
||||||
if (mkdir((char*)lpTempPathBuffer) && errno != EEXIST)
|
if (mkdir((char*)lpTempPathBuffer) && access((char*)lpTempPathBuffer, W_OK))
|
||||||
return NULL;
|
return NULL;
|
||||||
unix_path((char*)lpTempPathBuffer);
|
unix_path((char*)lpTempPathBuffer);
|
||||||
return (char*)lpTempPathBuffer;
|
return (char*)lpTempPathBuffer;
|
||||||
|
@ -115,12 +115,12 @@ char *game_local_games_path(int cr)
|
||||||
return NULL;
|
return NULL;
|
||||||
snprintf(local_games_path, sizeof(local_games_path) - 1 , "%s/", app);
|
snprintf(local_games_path, sizeof(local_games_path) - 1 , "%s/", app);
|
||||||
if (cr) {
|
if (cr) {
|
||||||
if (mkdir(local_games_path) && errno != EEXIST)
|
if (mkdir(local_games_path) && access(local_games_path, W_OK))
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
strcat(local_games_path,"/games");
|
strcat(local_games_path,"/games");
|
||||||
if (cr) {
|
if (cr) {
|
||||||
if (mkdir(local_games_path) && errno != EEXIST)
|
if (mkdir(local_games_path) && access(local_games_path, W_OK))
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return local_games_path;
|
return local_games_path;
|
||||||
|
@ -182,7 +182,7 @@ char *game_cfg_path( void )
|
||||||
return cfg_path;
|
return cfg_path;
|
||||||
/* no at home? Try in dir */
|
/* no at home? Try in dir */
|
||||||
snprintf(cfg_path, sizeof(cfg_path) - 1 , "%s", p);
|
snprintf(cfg_path, sizeof(cfg_path) - 1 , "%s", p);
|
||||||
if (mkdir(cfg_path) && errno != EEXIST) {
|
if (mkdir(cfg_path) && access(cfg_path, W_OK)) {
|
||||||
snprintf(cfg_path, sizeof(cfg_path) - 1 , "%src", p); /* appdir/insteadrc ;) */
|
snprintf(cfg_path, sizeof(cfg_path) - 1 , "%src", p); /* appdir/insteadrc ;) */
|
||||||
return cfg_path;
|
return cfg_path;
|
||||||
}
|
}
|
||||||
|
@ -205,21 +205,21 @@ char *game_save_path( int cr, int nr )
|
||||||
snprintf(save_path, sizeof(save_path) - 1, "saves/autosave");
|
snprintf(save_path, sizeof(save_path) - 1, "saves/autosave");
|
||||||
return save_path;
|
return save_path;
|
||||||
}
|
}
|
||||||
if (!p)
|
if (!p)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
strcpy( appdir, p );
|
strcpy( appdir, p );
|
||||||
|
|
||||||
if (cr && mkdir(appdir) && errno != EEXIST)
|
if (cr && mkdir(appdir) && access(appdir, W_OK))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
snprintf(save_path, sizeof(save_path) - 1 , "%s/saves", appdir);
|
snprintf(save_path, sizeof(save_path) - 1 , "%s/saves", appdir);
|
||||||
|
|
||||||
if (cr && mkdir(save_path) && errno != EEXIST)
|
if (cr && mkdir(save_path) && access(save_path, W_OK))
|
||||||
return NULL;
|
return NULL;
|
||||||
snprintf(save_path, sizeof(save_path) - 1, "%s/saves/%s", appdir, curgame_dir);
|
snprintf(save_path, sizeof(save_path) - 1, "%s/saves/%s", appdir, curgame_dir);
|
||||||
|
|
||||||
if (cr && mkdir(save_path) && errno != EEXIST)
|
if (cr && mkdir(save_path) && access(save_path, W_OK))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (nr)
|
if (nr)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
stead = {
|
stead = {
|
||||||
version = "1.2.1",
|
version = "1.2.2",
|
||||||
api_version = "1.1.6", -- last version before 1.2.0
|
api_version = "1.1.6", -- last version before 1.2.0
|
||||||
table = table,
|
table = table,
|
||||||
delim = ',',
|
delim = ',',
|
||||||
|
|
Loading…
Reference in a new issue