mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 05:25:14 +00:00
Rework new user folder system, make it just read sm64ex-coop if sm64coopdx isn't present, no more copying
This commit is contained in:
parent
3b13b06b00
commit
f2a6891a08
25 changed files with 97 additions and 105 deletions
|
@ -30,7 +30,7 @@ extern "C" {
|
||||||
|
|
||||||
#define DYNOS_VERSION "1.0"
|
#define DYNOS_VERSION "1.0"
|
||||||
#define DYNOS_EXE_FOLDER sys_exe_path()
|
#define DYNOS_EXE_FOLDER sys_exe_path()
|
||||||
#define DYNOS_USER_FOLDER sys_user_path()
|
#define DYNOS_USER_FOLDER fs_get_write_path("")
|
||||||
#define DYNOS_RES_FOLDER "dynos"
|
#define DYNOS_RES_FOLDER "dynos"
|
||||||
#define DYNOS_PACKS_FOLDER DYNOS_RES_FOLDER "/packs"
|
#define DYNOS_PACKS_FOLDER DYNOS_RES_FOLDER "/packs"
|
||||||
#define DYNOS_CONFIG_FILENAME "DynOS." DYNOS_VERSION ".config.txt"
|
#define DYNOS_CONFIG_FILENAME "DynOS." DYNOS_VERSION ".config.txt"
|
||||||
|
|
|
@ -75,6 +75,6 @@ void DynOS_Gfx_Init() {
|
||||||
ScanPacksFolder(_DynosPacksFolder);
|
ScanPacksFolder(_DynosPacksFolder);
|
||||||
|
|
||||||
// Scan the user path folder
|
// Scan the user path folder
|
||||||
SysPath _DynosPacksUserFolder = fstring("%s/%s", DYNOS_USER_FOLDER, DYNOS_PACKS_FOLDER);
|
SysPath _DynosPacksUserFolder = fstring("%s%s", DYNOS_USER_FOLDER, DYNOS_PACKS_FOLDER);
|
||||||
ScanPacksFolder(_DynosPacksUserFolder);
|
ScanPacksFolder(_DynosPacksUserFolder);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,6 @@ LOBBY_HOST = "host lobby"
|
||||||
UPDATE_AVAILABLE = "Nová aktualizace!"
|
UPDATE_AVAILABLE = "Nová aktualizace!"
|
||||||
LATEST_VERSION = "Nejnovější verze"
|
LATEST_VERSION = "Nejnovější verze"
|
||||||
YOUR_VERSION = "Vaše verze"
|
YOUR_VERSION = "Vaše verze"
|
||||||
USER_FOLDER_COPIED = "\\#a0ffa0\\Úspěch!\n\\#dcdcdc\\Složka uživatele sm64ex-coop byla zkopírována do nové složky sm64coopdx."
|
|
||||||
|
|
||||||
[CHAT]
|
[CHAT]
|
||||||
KICKING = "Vyhazování '@'!"
|
KICKING = "Vyhazování '@'!"
|
||||||
|
|
|
@ -31,7 +31,6 @@ LOBBY_HOST = "De Lobby's organisator."
|
||||||
UPDATE_AVAILABLE = "Nieuwe update!"
|
UPDATE_AVAILABLE = "Nieuwe update!"
|
||||||
LATEST_VERSION = "Laatste versie"
|
LATEST_VERSION = "Laatste versie"
|
||||||
YOUR_VERSION = "Uw versie"
|
YOUR_VERSION = "Uw versie"
|
||||||
USER_FOLDER_COPIED = "\\#a0ffa0\\Succes!\n\\#dcdcdc\\De gebruikersmap van sm64ex-coop is gekopieerd naar de nieuwe sm64coopdx."
|
|
||||||
|
|
||||||
[CHAT]
|
[CHAT]
|
||||||
KICKING = "'@' eruit schoppen!"
|
KICKING = "'@' eruit schoppen!"
|
||||||
|
|
|
@ -31,7 +31,7 @@ LOBBY_HOST = "the lobby's host"
|
||||||
UPDATE_AVAILABLE = "A new update is available!"
|
UPDATE_AVAILABLE = "A new update is available!"
|
||||||
LATEST_VERSION = "Latest version"
|
LATEST_VERSION = "Latest version"
|
||||||
YOUR_VERSION = "Your version"
|
YOUR_VERSION = "Your version"
|
||||||
USER_FOLDER_COPIED = "\\#a0ffa0\\Success!\n\\#dcdcdc\\The sm64ex-coop user folder has been copied over to the new sm64coopdx one."
|
USER_FOLDER_RENAMED = "\\#a0ffa0\\Success!\n\\#dcdcdc\\The sm64ex-coop user folder has renamed to sm64coopdx."
|
||||||
|
|
||||||
[CHAT]
|
[CHAT]
|
||||||
KICKING = "Kicking '@'!"
|
KICKING = "Kicking '@'!"
|
||||||
|
|
|
@ -31,7 +31,6 @@ LOBBY_HOST = "l'hôte de la partie"
|
||||||
UPDATE_AVAILABLE = "Nouvelle mise à jour !"
|
UPDATE_AVAILABLE = "Nouvelle mise à jour !"
|
||||||
LATEST_VERSION = "Dernière version"
|
LATEST_VERSION = "Dernière version"
|
||||||
YOUR_VERSION = "Votre version"
|
YOUR_VERSION = "Votre version"
|
||||||
USER_FOLDER_COPIED = "\\#a0ffa0\\Succès !\n\\#dcdcdc\\Le dossier utilisateur sm64ex-coop a été copié dans le nouveau sm64coopdx."
|
|
||||||
|
|
||||||
[CHAT]
|
[CHAT]
|
||||||
KICKING = "Vous avez expulsé '@' !"
|
KICKING = "Vous avez expulsé '@' !"
|
||||||
|
|
|
@ -31,7 +31,6 @@ LOBBY_HOST = "Lobby-Hoster"
|
||||||
UPDATE_AVAILABLE = "Neues Update!"
|
UPDATE_AVAILABLE = "Neues Update!"
|
||||||
LATEST_VERSION = "Aktuellste Version"
|
LATEST_VERSION = "Aktuellste Version"
|
||||||
YOUR_VERSION = "Ihre Version"
|
YOUR_VERSION = "Ihre Version"
|
||||||
USER_FOLDER_COPIED = "\\#a0ffa0\\Erfolg!\n\\#dcdcdc\\Der Benutzerordner sm64ex-coop wurde in den neuen sm64coopdx kopiert."
|
|
||||||
|
|
||||||
[CHAT]
|
[CHAT]
|
||||||
KICKING = "'@' wird hinausgeworfen!"
|
KICKING = "'@' wird hinausgeworfen!"
|
||||||
|
|
|
@ -31,7 +31,6 @@ LOBBY_HOST = "the lobby's host"
|
||||||
UPDATE_AVAILABLE = "Nuovo aggiornamento!"
|
UPDATE_AVAILABLE = "Nuovo aggiornamento!"
|
||||||
LATEST_VERSION = "Ultima versione"
|
LATEST_VERSION = "Ultima versione"
|
||||||
YOUR_VERSION = "La tua versione"
|
YOUR_VERSION = "La tua versione"
|
||||||
USER_FOLDER_COPIED = "\\#a0ffa0\\Successo!\n\\#dcdcdc\\La cartella utente sm64ex-coop è stata copiata nella nuova sm64coopdx."
|
|
||||||
|
|
||||||
[CHAT]
|
[CHAT]
|
||||||
KICKING = "Espulso '@'!"
|
KICKING = "Espulso '@'!"
|
||||||
|
|
|
@ -31,7 +31,6 @@ LOBBY_HOST = "Host lobby"
|
||||||
UPDATE_AVAILABLE = "Nowa aktualizacja!"
|
UPDATE_AVAILABLE = "Nowa aktualizacja!"
|
||||||
LATEST_VERSION = "Najnowsza wersja"
|
LATEST_VERSION = "Najnowsza wersja"
|
||||||
YOUR_VERSION = "Twoja wersja"
|
YOUR_VERSION = "Twoja wersja"
|
||||||
USER_FOLDER_COPIED = "\\#a0ffa0\\Sukces!\n\\#dcdcdc\\Folder użytkownika sm64ex-coop został skopiowany do nowego sm64coopdx."
|
|
||||||
|
|
||||||
[CHAT]
|
[CHAT]
|
||||||
KICKING = "Wyrzucanie gracza '@'!"
|
KICKING = "Wyrzucanie gracza '@'!"
|
||||||
|
|
|
@ -31,7 +31,6 @@ LOBBY_HOST = "o criador da partida"
|
||||||
UPDATE_AVAILABLE = "Nova atualização!"
|
UPDATE_AVAILABLE = "Nova atualização!"
|
||||||
LATEST_VERSION = "Versão mais recente"
|
LATEST_VERSION = "Versão mais recente"
|
||||||
YOUR_VERSION = "Sua versão"
|
YOUR_VERSION = "Sua versão"
|
||||||
USER_FOLDER_COPIED = "\\#a0ffa0\\Sucesso!\n\\#dcdcdc\\A pasta de usuário sm64ex-coop foi copiada para a nova sm64coopdx."
|
|
||||||
|
|
||||||
[CHAT]
|
[CHAT]
|
||||||
KICKING = "'@' foi expulso!"
|
KICKING = "'@' foi expulso!"
|
||||||
|
|
|
@ -31,7 +31,6 @@ LOBBY_HOST = "Создать группу"
|
||||||
UPDATE_AVAILABLE = "Новое обновление!"
|
UPDATE_AVAILABLE = "Новое обновление!"
|
||||||
LATEST_VERSION = "Последняя версия"
|
LATEST_VERSION = "Последняя версия"
|
||||||
YOUR_VERSION = "Ваша версия"
|
YOUR_VERSION = "Ваша версия"
|
||||||
USER_FOLDER_COPIED = "\\#a0ffa0\\Успех!\n\\#dcdcdc\\Папка пользователя sm64ex-coop была скопирована в новую sm64coopdx."
|
|
||||||
|
|
||||||
[CHAT]
|
[CHAT]
|
||||||
KICKING = "'@' выгнан!"
|
KICKING = "'@' выгнан!"
|
||||||
|
|
|
@ -31,7 +31,6 @@ LOBBY_HOST = "la partida del anfitrión"
|
||||||
UPDATE_AVAILABLE = "¡Nueva actualización!"
|
UPDATE_AVAILABLE = "¡Nueva actualización!"
|
||||||
LATEST_VERSION = "Última versión"
|
LATEST_VERSION = "Última versión"
|
||||||
YOUR_VERSION = "Su versión"
|
YOUR_VERSION = "Su versión"
|
||||||
USER_FOLDER_COPIED = "\\#a0ffa0\\¡Éxito!\n\\#dcdcdc\\La carpeta de usuario sm64ex-coop ha sido copiada a la nueva sm64coopdx."
|
|
||||||
|
|
||||||
[CHAT]
|
[CHAT]
|
||||||
KICKING = "¡'@' ha sido expulsado!"
|
KICKING = "¡'@' ha sido expulsado!"
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#include "djui_hud_utils.h"
|
#include "djui_hud_utils.h"
|
||||||
#include "engine/math_util.h"
|
#include "engine/math_util.h"
|
||||||
#include "pc/utils/misc.h"
|
#include "pc/utils/misc.h"
|
||||||
#include "pc/startup.h"
|
|
||||||
|
|
||||||
static Gfx* sSavedDisplayListHead = NULL;
|
static Gfx* sSavedDisplayListHead = NULL;
|
||||||
|
|
||||||
|
@ -110,10 +109,6 @@ void djui_init_late(void) {
|
||||||
|
|
||||||
// djui_panel_debug_create();
|
// djui_panel_debug_create();
|
||||||
djui_cursor_create();
|
djui_cursor_create();
|
||||||
|
|
||||||
if (gUserFolderCopied) {
|
|
||||||
djui_popup_create(DLANG(NOTIF, USER_FOLDER_COPIED), 4);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void djui_connect_menu_open(void) {
|
void djui_connect_menu_open(void) {
|
||||||
|
|
|
@ -44,16 +44,16 @@ void djui_panel_options_debug_create(struct DjuiBase* caller) {
|
||||||
static void djui_panel_options_open_user_folder(UNUSED struct DjuiBase* caller) {
|
static void djui_panel_options_open_user_folder(UNUSED struct DjuiBase* caller) {
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
// Windows
|
// Windows
|
||||||
ShellExecuteA(NULL, "open", sys_user_path(), NULL, NULL, SW_SHOWNORMAL);
|
ShellExecuteA(NULL, "open", fs_get_write_path(""), NULL, NULL, SW_SHOWNORMAL);
|
||||||
#elif __linux__
|
#elif __linux__
|
||||||
// Linux
|
// Linux
|
||||||
char command[512];
|
char command[512];
|
||||||
snprintf(command, sizeof(command), "xdg-open %s", sys_user_path());
|
snprintf(command, sizeof(command), "xdg-open \"%s\"", fs_get_write_path(""));
|
||||||
system(command);
|
system(command);
|
||||||
#elif __APPLE__
|
#elif __APPLE__
|
||||||
// macOS
|
// macOS
|
||||||
char command[512];
|
char command[512];
|
||||||
snprintf(command, sizeof(command), "open %s", sys_user_path());
|
snprintf(command, sizeof(command), "open \"%s\"", fs_get_write_path(""));
|
||||||
system(command);
|
system(command);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ bool fs_init(const char *writepath) {
|
||||||
strncpy(fs_writepath, fs_convert_path(buf, sizeof(buf), writepath), sizeof(fs_writepath));
|
strncpy(fs_writepath, fs_convert_path(buf, sizeof(buf), writepath), sizeof(fs_writepath));
|
||||||
fs_writepath[sizeof(fs_writepath)-1] = 0;
|
fs_writepath[sizeof(fs_writepath)-1] = 0;
|
||||||
#ifdef DEVELOPMENT
|
#ifdef DEVELOPMENT
|
||||||
printf("fs: writepath set to `%s`\n", fs_writepath);
|
printf("FS: writepath set to `%s`\n", fs_writepath);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fs_mount(fs_writepath);
|
fs_mount(fs_writepath);
|
||||||
|
@ -77,7 +77,7 @@ bool fs_mount(const char *realpath) {
|
||||||
|
|
||||||
if (!pack || !packer) {
|
if (!pack || !packer) {
|
||||||
if (tried)
|
if (tried)
|
||||||
fprintf(stderr, "fs: could not mount '%s'\n", realpath);
|
fprintf(stderr, "FS: could not mount '%s'\n", realpath);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ bool fs_mount(const char *realpath) {
|
||||||
fs_searchpaths = dir;
|
fs_searchpaths = dir;
|
||||||
|
|
||||||
#ifdef DEVELOPMENT
|
#ifdef DEVELOPMENT
|
||||||
printf("fs: mounting '%s'\n", realpath);
|
printf("FS: mounting '%s'\n", realpath);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -274,6 +274,31 @@ bool fs_sys_dir_exists(const char *name) {
|
||||||
return (stat(name, &st) == 0 && S_ISDIR(st.st_mode));
|
return (stat(name, &st) == 0 && S_ISDIR(st.st_mode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool fs_sys_dir_is_empty(const char *name) {
|
||||||
|
DIR *dir;
|
||||||
|
struct dirent *ent;
|
||||||
|
|
||||||
|
if (!(dir = opendir(name))) {
|
||||||
|
fprintf(stderr, "fs_sys_dir_is_empty(): could not open `%s`\n", name);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ret = true;
|
||||||
|
while ((ent = readdir(dir)) != NULL) {
|
||||||
|
// skip "." and ".."
|
||||||
|
if (ent->d_name[0] == '.' && (ent->d_name[1] == '\0' ||
|
||||||
|
(ent->d_name[1] == '.' && ent->d_name[2] == '\0'))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
closedir(dir);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
bool fs_sys_walk(const char *base, walk_fn_t walk, void *user, const bool recur) {
|
bool fs_sys_walk(const char *base, walk_fn_t walk, void *user, const bool recur) {
|
||||||
#ifdef DOCKERBUILD
|
#ifdef DOCKERBUILD
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -65,11 +65,8 @@ typedef struct {
|
||||||
void (*close)(void *pack, fs_file_t *file); // closes a virtual file previously opened with ->open()
|
void (*close)(void *pack, fs_file_t *file); // closes a virtual file previously opened with ->open()
|
||||||
} fs_packtype_t;
|
} fs_packtype_t;
|
||||||
|
|
||||||
// takes the supplied NULL-terminated list of read-only directories and mounts all the packs in them,
|
// mounts `writepath`
|
||||||
// then mounts the directories themselves, then mounts all the packs in `gamedir`, then mounts `gamedir` itself,
|
bool fs_init(const char *writepath);
|
||||||
// then does the same with `userdir`
|
|
||||||
// initializes the `fs_userdir` variable
|
|
||||||
bool fs_init(const char *userdir);
|
|
||||||
// mounts the pack at physical path `realpath` to the root of the filesystem
|
// mounts the pack at physical path `realpath` to the root of the filesystem
|
||||||
// packs mounted later take priority over packs mounted earlier
|
// packs mounted later take priority over packs mounted earlier
|
||||||
bool fs_mount(const char *realpath);
|
bool fs_mount(const char *realpath);
|
||||||
|
@ -105,6 +102,7 @@ const char *fs_convert_path(char *buf, const size_t bufsiz, const char *path);
|
||||||
bool fs_sys_walk(const char *base, walk_fn_t walk, void *user, const bool recur);
|
bool fs_sys_walk(const char *base, walk_fn_t walk, void *user, const bool recur);
|
||||||
bool fs_sys_file_exists(const char *name);
|
bool fs_sys_file_exists(const char *name);
|
||||||
bool fs_sys_dir_exists(const char *name);
|
bool fs_sys_dir_exists(const char *name);
|
||||||
|
bool fs_sys_dir_is_empty(const char *name);
|
||||||
bool fs_sys_mkdir(const char *name); // creates with 0777 by default
|
bool fs_sys_mkdir(const char *name); // creates with 0777 by default
|
||||||
bool fs_sys_copy_file(const char *oldname, const char *newname);
|
bool fs_sys_copy_file(const char *oldname, const char *newname);
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
#include "pc/controller/controller_bind_mapping.h"
|
#include "pc/controller/controller_bind_mapping.h"
|
||||||
#include "pc/utils/misc.h"
|
#include "pc/utils/misc.h"
|
||||||
#include "pc/mods/mod_import.h"
|
#include "pc/mods/mod_import.h"
|
||||||
#include "pc/startup.h"
|
#include "pc/rom_checker.h"
|
||||||
|
|
||||||
#ifndef GL_MAX_SAMPLES
|
#ifndef GL_MAX_SAMPLES
|
||||||
#define GL_MAX_SAMPLES 0x8D57
|
#define GL_MAX_SAMPLES 0x8D57
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "loading.h"
|
#include "loading.h"
|
||||||
#include "pc/utils/misc.h"
|
#include "pc/utils/misc.h"
|
||||||
#include "pc/cliopts.h"
|
#include "pc/cliopts.h"
|
||||||
#include "startup.h"
|
#include "rom_checker.h"
|
||||||
|
|
||||||
extern ALIGNED8 u8 texture_coopdx_logo[];
|
extern ALIGNED8 u8 texture_coopdx_logo[];
|
||||||
|
|
||||||
|
|
|
@ -56,8 +56,8 @@ bool char_valid(char* buffer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void mod_storage_get_filename(char* dest) {
|
void mod_storage_get_filename(char* dest) {
|
||||||
const char* path = sys_user_path(); // get user path
|
const char* path = fs_get_write_path(""); // get user path
|
||||||
snprintf(dest, SYS_MAX_PATH - 1, "%s/sav/%s", path, gLuaActiveMod->relativePath); // append sav folder
|
snprintf(dest, SYS_MAX_PATH - 1, "%ssav/%s", path, gLuaActiveMod->relativePath); // append sav folder
|
||||||
strdelete(dest, (char *)".lua"); // delete ".lua" from sav name
|
strdelete(dest, (char *)".lua"); // delete ".lua" from sav name
|
||||||
strcat(dest, SAVE_EXTENSION); // append SAVE_EXTENSION
|
strcat(dest, SAVE_EXTENSION); // append SAVE_EXTENSION
|
||||||
normalize_path(dest); // fix any out of place slashes
|
normalize_path(dest); // fix any out of place slashes
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include "audio/audio_null.h"
|
#include "audio/audio_null.h"
|
||||||
|
|
||||||
#include "rom_assets.h"
|
#include "rom_assets.h"
|
||||||
#include "startup.h"
|
#include "rom_checker.h"
|
||||||
#include "pc_main.h"
|
#include "pc_main.h"
|
||||||
#include "loading.h"
|
#include "loading.h"
|
||||||
#include "cliopts.h"
|
#include "cliopts.h"
|
||||||
|
@ -360,12 +360,11 @@ void* main_game_init(void* isThreaded) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
// handle terminal arguments
|
||||||
// Handle terminal arguments
|
|
||||||
if (!parse_cli_opts(argc, argv)) { return 0; }
|
if (!parse_cli_opts(argc, argv)) { return 0; }
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
// Handle Windows console
|
// handle Windows console
|
||||||
if (!gCLIOpts.console) {
|
if (!gCLIOpts.console) {
|
||||||
FreeConsole();
|
FreeConsole();
|
||||||
freopen("NUL", "w", stdout);
|
freopen("NUL", "w", stdout);
|
||||||
|
@ -373,23 +372,23 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
legacy_folder_handler();
|
const char* userPath = gCLIOpts.savePath[0] ? gCLIOpts.savePath : sys_user_path();
|
||||||
|
fs_init(userPath);
|
||||||
const char *userpath = gCLIOpts.savePath[0] ? gCLIOpts.savePath : sys_user_path();
|
|
||||||
fs_init(userpath);
|
|
||||||
configfile_load();
|
configfile_load();
|
||||||
|
|
||||||
// Create the window straight away
|
legacy_folder_handler();
|
||||||
|
|
||||||
|
// create the window almost straight away
|
||||||
if (!gGfxInited) {
|
if (!gGfxInited) {
|
||||||
gfx_init(&WAPI, &RAPI, TITLE);
|
gfx_init(&WAPI, &RAPI, TITLE);
|
||||||
WAPI.set_keyboard_callbacks(keyboard_on_key_down, keyboard_on_key_up, keyboard_on_all_keys_up, keyboard_on_text_input);
|
WAPI.set_keyboard_callbacks(keyboard_on_key_down, keyboard_on_key_up, keyboard_on_all_keys_up, keyboard_on_text_input);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render the rom setup screen
|
// render the rom setup screen
|
||||||
if (!main_rom_handler()) {
|
if (!main_rom_handler()) {
|
||||||
#ifdef LOADING_SCREEN_SUPPORTED
|
#ifdef LOADING_SCREEN_SUPPORTED
|
||||||
if (!gCLIOpts.hideLoadingScreen) {
|
if (!gCLIOpts.hideLoadingScreen) {
|
||||||
render_rom_setup_screen(); // Holds the game load until a valid rom is provided
|
render_rom_setup_screen(); // holds the game load until a valid rom is provided
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
@ -398,12 +397,12 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start the thread for setting up the game
|
// start the thread for setting up the game
|
||||||
#ifdef LOADING_SCREEN_SUPPORTED
|
#ifdef LOADING_SCREEN_SUPPORTED
|
||||||
bool threadSuccess = false;
|
bool threadSuccess = false;
|
||||||
if (!gCLIOpts.hideLoadingScreen && pthread_mutex_init(&gLoadingThreadMutex, NULL) == 0) {
|
if (!gCLIOpts.hideLoadingScreen && pthread_mutex_init(&gLoadingThreadMutex, NULL) == 0) {
|
||||||
if (pthread_create(&gLoadingThreadId, NULL, main_game_init, (void*) 1) == 0) {
|
if (pthread_create(&gLoadingThreadId, NULL, main_game_init, (void*) 1) == 0) {
|
||||||
render_loading_screen(); // Render the loading screen while the game is setup
|
render_loading_screen(); // render the loading screen while the game is setup
|
||||||
threadSuccess = true;
|
threadSuccess = true;
|
||||||
}
|
}
|
||||||
pthread_mutex_destroy(&gLoadingThreadMutex);
|
pthread_mutex_destroy(&gLoadingThreadMutex);
|
||||||
|
@ -411,19 +410,19 @@ int main(int argc, char *argv[]) {
|
||||||
if (!threadSuccess)
|
if (!threadSuccess)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
main_game_init(NULL); // Failsafe incase threading doesn't work
|
main_game_init(NULL); // failsafe incase threading doesn't work
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize sm64 data and controllers
|
// initialize sm64 data and controllers
|
||||||
thread5_game_loop(NULL);
|
thread5_game_loop(NULL);
|
||||||
|
|
||||||
// Initialize sound outside threads
|
// initialize sound outside threads
|
||||||
#if defined(AAPI_SDL1) || defined(AAPI_SDL2)
|
#if defined(AAPI_SDL1) || defined(AAPI_SDL2)
|
||||||
if (!audio_api && audio_sdl.init()) { audio_api = &audio_sdl; }
|
if (!audio_api && audio_sdl.init()) { audio_api = &audio_sdl; }
|
||||||
#endif
|
#endif
|
||||||
if (!audio_api) { audio_api = &audio_null; }
|
if (!audio_api) { audio_api = &audio_null; }
|
||||||
|
|
||||||
// Initialize djui
|
// initialize djui
|
||||||
djui_init();
|
djui_init();
|
||||||
djui_unicode_init();
|
djui_unicode_init();
|
||||||
djui_init_late();
|
djui_init_late();
|
||||||
|
@ -431,7 +430,7 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
show_update_popup();
|
show_update_popup();
|
||||||
|
|
||||||
// Init network
|
// initialize network
|
||||||
if (gCLIOpts.network == NT_CLIENT) {
|
if (gCLIOpts.network == NT_CLIENT) {
|
||||||
network_set_system(NS_SOCKET);
|
network_set_system(NS_SOCKET);
|
||||||
snprintf(gGetHostName, MAX_CONFIG_STRING, "%s", gCLIOpts.joinIp);
|
snprintf(gGetHostName, MAX_CONFIG_STRING, "%s", gCLIOpts.joinIp);
|
||||||
|
@ -442,7 +441,7 @@ int main(int argc, char *argv[]) {
|
||||||
configNetworkSystem = NS_SOCKET;
|
configNetworkSystem = NS_SOCKET;
|
||||||
configHostPort = gCLIOpts.networkPort;
|
configHostPort = gCLIOpts.networkPort;
|
||||||
|
|
||||||
// Horrible, hacky fix for mods that access marioObj straight away
|
// horrible, hacky fix for mods that access marioObj straight away
|
||||||
// best fix: host with the standard main menu method
|
// best fix: host with the standard main menu method
|
||||||
static struct Object sHackyObject = { 0 };
|
static struct Object sHackyObject = { 0 };
|
||||||
gMarioStates[0].marioObj = &sHackyObject;
|
gMarioStates[0].marioObj = &sHackyObject;
|
||||||
|
@ -453,7 +452,7 @@ int main(int argc, char *argv[]) {
|
||||||
network_init(NT_NONE, false);
|
network_init(NT_NONE, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main loop
|
// main loop
|
||||||
while (true) {
|
while (true) {
|
||||||
debug_context_reset();
|
debug_context_reset();
|
||||||
CTX_BEGIN(CTX_FRAME);
|
CTX_BEGIN(CTX_FRAME);
|
||||||
|
|
|
@ -81,45 +81,45 @@ void sys_fatal(const char *fmt, ...) {
|
||||||
// we can just ask SDL for most of this shit if we have it
|
// we can just ask SDL for most of this shit if we have it
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
|
|
||||||
const char *sys_user_path(void) {
|
static const char *sys_old_user_path(void) {
|
||||||
static char path[SYS_MAX_PATH] = { 0 };
|
static char path[SYS_MAX_PATH] = { 0 };
|
||||||
|
|
||||||
// get the new pref path from SDL
|
// get the new pref path from SDL
|
||||||
char *sdlpath = SDL_GetPrefPath("", "sm64coopdx");
|
char *sdlPath = SDL_GetPrefPath("", "sm64ex-coop");
|
||||||
if (sdlpath) {
|
if (sdlPath) {
|
||||||
const unsigned int len = strlen(sdlpath);
|
const unsigned int len = strlen(sdlPath);
|
||||||
strncpy(path, sdlpath, sizeof(path));
|
strncpy(path, sdlPath, sizeof(path));
|
||||||
path[sizeof(path)-1] = 0;
|
path[sizeof(path)-1] = 0;
|
||||||
|
|
||||||
SDL_free(sdlpath);
|
SDL_free(sdlPath);
|
||||||
|
|
||||||
if (path[len-1] == '/' || path[len-1] == '\\')
|
// strip the trailing separator
|
||||||
path[len-1] = 0; // strip the trailing separator
|
if (path[len-1] == '/' || path[len-1] == '\\') { path[len-1] = 0; }
|
||||||
|
|
||||||
if (!fs_sys_dir_exists(path) && !fs_sys_mkdir(path))
|
|
||||||
path[0] = 0; // somehow failed, we got no user path
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *sys_old_user_path(void) {
|
const char *sys_user_path(void) {
|
||||||
static char path[SYS_MAX_PATH] = { 0 };
|
static char path[SYS_MAX_PATH] = { 0 };
|
||||||
|
|
||||||
// get the new pref path from SDL
|
// get the new pref path from SDL
|
||||||
char *sdlpath = SDL_GetPrefPath("", "sm64ex-coop");
|
char *sdlPath = SDL_GetPrefPath("", "sm64coopdx");
|
||||||
if (sdlpath) {
|
if (sdlPath) {
|
||||||
const unsigned int len = strlen(sdlpath);
|
// redirect to the old user path if the current one is empty (likely just created from SDL_GetPrefPath)
|
||||||
strncpy(path, sdlpath, sizeof(path));
|
if (fs_sys_dir_is_empty(sdlPath)) {
|
||||||
|
SDL_free(sdlPath);
|
||||||
|
return sys_old_user_path();
|
||||||
|
}
|
||||||
|
|
||||||
|
const unsigned int len = strlen(sdlPath);
|
||||||
|
strncpy(path, sdlPath, sizeof(path));
|
||||||
path[sizeof(path)-1] = 0;
|
path[sizeof(path)-1] = 0;
|
||||||
|
|
||||||
SDL_free(sdlpath);
|
SDL_free(sdlPath);
|
||||||
|
|
||||||
if (path[len-1] == '/' || path[len-1] == '\\')
|
// strip the trailing separator
|
||||||
path[len-1] = 0; // strip the trailing separator
|
if (path[len-1] == '/' || path[len-1] == '\\') { path[len-1] = 0; }
|
||||||
|
|
||||||
if (!fs_sys_dir_exists(path) && !fs_sys_mkdir(path))
|
|
||||||
path[0] = 0; // somehow failed, we got no user path
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
|
@ -127,13 +127,13 @@ const char *sys_old_user_path(void) {
|
||||||
|
|
||||||
const char *sys_exe_path(void) {
|
const char *sys_exe_path(void) {
|
||||||
static char path[SYS_MAX_PATH] = { 0 };
|
static char path[SYS_MAX_PATH] = { 0 };
|
||||||
char *sdlpath = SDL_GetBasePath();
|
char *sdlPath = SDL_GetBasePath();
|
||||||
if (sdlpath && sdlpath[0]) {
|
if (sdlPath && sdlPath[0]) {
|
||||||
// use the SDL path if it exists
|
// use the SDL path if it exists
|
||||||
const unsigned int len = strlen(sdlpath);
|
const unsigned int len = strlen(sdlPath);
|
||||||
strncpy(path, sdlpath, sizeof(path));
|
strncpy(path, sdlPath, sizeof(path));
|
||||||
path[sizeof(path)-1] = 0;
|
path[sizeof(path)-1] = 0;
|
||||||
SDL_free(sdlpath);
|
SDL_free(sdlPath);
|
||||||
if (path[len-1] == '/' || path[len-1] == '\\')
|
if (path[len-1] == '/' || path[len-1] == '\\')
|
||||||
path[len-1] = 0; // strip the trailing separator
|
path[len-1] = 0; // strip the trailing separator
|
||||||
}
|
}
|
||||||
|
@ -157,10 +157,6 @@ const char *sys_user_path(void) {
|
||||||
return ".";
|
return ".";
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *sys_old_user_path(void) {
|
|
||||||
return ".";
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *sys_exe_path(void) {
|
const char *sys_exe_path(void) {
|
||||||
return ".";
|
return ".";
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ int sys_strcasecmp(const char *s1, const char *s2);
|
||||||
|
|
||||||
// path stuff
|
// path stuff
|
||||||
const char *sys_user_path(void);
|
const char *sys_user_path(void);
|
||||||
const char *sys_old_user_path(void);
|
|
||||||
const char *sys_exe_path(void);
|
const char *sys_exe_path(void);
|
||||||
const char *sys_file_extension(const char *fpath);
|
const char *sys_file_extension(const char *fpath);
|
||||||
const char *sys_file_name(const char *fpath);
|
const char *sys_file_name(const char *fpath);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include <PR/ultratypes.h>
|
#include <PR/ultratypes.h>
|
||||||
#include "rom_assets.h"
|
#include "rom_assets.h"
|
||||||
#include "pc/debuglog.h"
|
#include "pc/debuglog.h"
|
||||||
#include "startup.h"
|
#include "rom_checker.h"
|
||||||
|
|
||||||
struct RomAsset {
|
struct RomAsset {
|
||||||
void* ptr;
|
void* ptr;
|
||||||
|
|
|
@ -13,13 +13,13 @@ extern "C" {
|
||||||
#include "mods/mod_cache.h" // for md5 hashing
|
#include "mods/mod_cache.h" // for md5 hashing
|
||||||
#include "mods/mods.h"
|
#include "mods/mods.h"
|
||||||
#include "loading.h"
|
#include "loading.h"
|
||||||
|
#include "fs/fs.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
bool gUserFolderCopied = false;
|
|
||||||
bool gRomIsValid = false;
|
bool gRomIsValid = false;
|
||||||
char gRomFilename[255] = "";
|
char gRomFilename[SYS_MAX_PATH] = "";
|
||||||
|
|
||||||
struct VanillaMD5 {
|
struct VanillaMD5 {
|
||||||
const char *localizationName;
|
const char *localizationName;
|
||||||
|
@ -35,23 +35,14 @@ static struct VanillaMD5 sVanillaMD5[] = {
|
||||||
{ NULL, NULL },
|
{ NULL, NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
inline static void copy_old_user_folder() {
|
|
||||||
std::string userPath = sys_user_path();
|
|
||||||
std::string oldPath = sys_old_user_path();
|
|
||||||
if (fs::exists(oldPath) && (fs::is_empty(userPath) || !fs::exists(userPath))) {
|
|
||||||
fs::copy(oldPath, userPath, fs::copy_options::recursive);
|
|
||||||
gUserFolderCopied = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline static void rename_tmp_folder() {
|
inline static void rename_tmp_folder() {
|
||||||
std::string userPath = sys_user_path();
|
std::string userPath = fs_get_write_path("");
|
||||||
std::string oldPath = userPath + "/tmp";
|
std::string oldPath = userPath + "tmp";
|
||||||
if (fs::exists(oldPath)) {
|
if (fs::exists(oldPath)) {
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
SetFileAttributesA(oldPath.c_str(), FILE_ATTRIBUTE_HIDDEN);
|
SetFileAttributesA(oldPath.c_str(), FILE_ATTRIBUTE_HIDDEN);
|
||||||
#endif
|
#endif
|
||||||
fs::rename(oldPath, userPath + "/" + TMP_DIRECTORY);
|
fs::rename(oldPath, userPath + TMP_DIRECTORY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,9 +56,9 @@ static bool is_rom_valid(const std::string romPath) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool foundHash = false;
|
bool foundHash = false;
|
||||||
for (struct VanillaMD5 *md5 = sVanillaMD5; md5->localizationName != NULL; md5++) {
|
for (VanillaMD5 *md5 = sVanillaMD5; md5->localizationName != NULL; md5++) {
|
||||||
if (md5->md5 == ss.str()) {
|
if (md5->md5 == ss.str()) {
|
||||||
std::string destPath = sys_user_path() + std::string("/baserom.") + md5->localizationName + ".z64";
|
std::string destPath = fs_get_write_path("") + std::string("baserom.") + md5->localizationName + ".z64";
|
||||||
|
|
||||||
// Copy the rom to the user path
|
// Copy the rom to the user path
|
||||||
if (romPath != destPath && !std::filesystem::exists(std::filesystem::path(destPath))) {
|
if (romPath != destPath && !std::filesystem::exists(std::filesystem::path(destPath))) {
|
||||||
|
@ -77,7 +68,7 @@ static bool is_rom_valid(const std::string romPath) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(gRomFilename, 255, "%s", destPath.c_str()); // Load the copied rom
|
snprintf(gRomFilename, SYS_MAX_PATH, "%s", destPath.c_str()); // Load the copied rom
|
||||||
gRomIsValid = true;
|
gRomIsValid = true;
|
||||||
foundHash = true;
|
foundHash = true;
|
||||||
break;
|
break;
|
||||||
|
@ -99,12 +90,11 @@ inline static bool scan_path_for_rom(const char *dir) {
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
void legacy_folder_handler(void) {
|
void legacy_folder_handler(void) {
|
||||||
copy_old_user_folder();
|
rename_tmp_folder();
|
||||||
if (gUserFolderCopied) { rename_tmp_folder(); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool main_rom_handler(void) {
|
bool main_rom_handler(void) {
|
||||||
if (scan_path_for_rom(sys_user_path())) { return true; }
|
if (scan_path_for_rom(fs_get_write_path(""))) { return true; }
|
||||||
scan_path_for_rom(sys_exe_path());
|
scan_path_for_rom(sys_exe_path());
|
||||||
return gRomIsValid;
|
return gRomIsValid;
|
||||||
}
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
extern bool gUserFolderCopied;
|
|
||||||
extern bool gRomIsValid;
|
extern bool gRomIsValid;
|
||||||
extern char gRomFilename[];
|
extern char gRomFilename[];
|
||||||
|
|
Loading…
Reference in a new issue