mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-03-04 09:11:27 +01:00
try to search for gamestates in directory with binary before resorting to LD_LIBRARY_PATHs
This commit is contained in:
parent
c34c13739d
commit
a3cda7ba50
2 changed files with 20 additions and 1 deletions
|
@ -200,7 +200,7 @@ SYMBOL_INTERNAL bool OpenGamestate(struct Game* game, struct Gamestate* gamestat
|
||||||
PrintConsole(game, "Opening gamestate \"%s\"...", gamestate->name);
|
PrintConsole(game, "Opening gamestate \"%s\"...", gamestate->name);
|
||||||
char libname[1024];
|
char libname[1024];
|
||||||
snprintf(libname, 1024, "libsuperderpy-%s-%s" LIBRARY_EXTENSION, game->name, gamestate->name);
|
snprintf(libname, 1024, "libsuperderpy-%s-%s" LIBRARY_EXTENSION, game->name, gamestate->name);
|
||||||
gamestate->handle = dlopen(libname, RTLD_NOW);
|
gamestate->handle = dlopen(AddGarbage(game, GetLibraryPath(game, libname)), RTLD_NOW);
|
||||||
if (!gamestate->handle) {
|
if (!gamestate->handle) {
|
||||||
FatalError(game, false, "Error while opening gamestate \"%s\": %s", gamestate->name, dlerror()); // TODO: move out
|
FatalError(game, false, "Error while opening gamestate \"%s\": %s", gamestate->name, dlerror()); // TODO: move out
|
||||||
return false;
|
return false;
|
||||||
|
@ -407,3 +407,21 @@ SYMBOL_INTERNAL void DrawTimelines(struct Game* game) {
|
||||||
tmp = tmp->next;
|
tmp = tmp->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SYMBOL_INTERNAL char* GetLibraryPath(struct Game* game, char* filename) {
|
||||||
|
char* result = NULL;
|
||||||
|
ALLEGRO_PATH* path = al_get_standard_path(ALLEGRO_EXENAME_PATH);
|
||||||
|
al_set_path_filename(path, filename);
|
||||||
|
if (al_filename_exists(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP))) {
|
||||||
|
result = strdup(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP));
|
||||||
|
} else {
|
||||||
|
al_append_path_component(path, "gamestates");
|
||||||
|
if (al_filename_exists(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP))) {
|
||||||
|
result = strdup(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP));
|
||||||
|
} else {
|
||||||
|
result = strdup(filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
al_destroy_path(path);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
|
@ -86,5 +86,6 @@ bool OpenGamestate(struct Game* game, struct Gamestate* gamestate);
|
||||||
bool LinkGamestate(struct Game* game, struct Gamestate* gamestate);
|
bool LinkGamestate(struct Game* game, struct Gamestate* gamestate);
|
||||||
void CloseGamestate(struct Game* game, struct Gamestate* gamestate);
|
void CloseGamestate(struct Game* game, struct Gamestate* gamestate);
|
||||||
struct Gamestate* AllocateGamestate(struct Game* game, const char* name);
|
struct Gamestate* AllocateGamestate(struct Game* game, const char* name);
|
||||||
|
char* GetLibraryPath(struct Game* game, char* filename);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue