From 630b3a9fcf0d5e567fd97d15080381d880445330 Mon Sep 17 00:00:00 2001 From: fgsfds Date: Sun, 7 Jun 2020 23:54:39 +0300 Subject: [PATCH] restore --savepath and replace --datapath with --gamedir --- src/pc/cliopts.c | 4 ++-- src/pc/cliopts.h | 2 +- src/pc/gfx/gfx_pc.c | 18 +++++++++--------- src/pc/gfx/gfx_pc.h | 1 + src/pc/pc_main.c | 17 +++++++++++++++-- 5 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/pc/cliopts.c b/src/pc/cliopts.c index bff335a2..fd07eb31 100644 --- a/src/pc/cliopts.c +++ b/src/pc/cliopts.c @@ -54,8 +54,8 @@ void parse_cli_opts(int argc, char* argv[]) { else if (strcmp(argv[i], "--configfile") == 0 && (i + 1) < argc) arg_string("--configfile", argv[++i], gCLIOpts.ConfigFile); - else if (strcmp(argv[i], "--datapath") == 0 && (i + 1) < argc) - arg_string("--datapath", argv[++i], gCLIOpts.DataPath); + else if (strcmp(argv[i], "--gamedir") == 0 && (i + 1) < argc) + arg_string("--gamedir", argv[++i], gCLIOpts.GameDir); else if (strcmp(argv[i], "--savepath") == 0 && (i + 1) < argc) arg_string("--savepath", argv[++i], gCLIOpts.SavePath); diff --git a/src/pc/cliopts.h b/src/pc/cliopts.h index 2d084eda..f9a45e18 100644 --- a/src/pc/cliopts.h +++ b/src/pc/cliopts.h @@ -8,7 +8,7 @@ struct PCCLIOptions { unsigned int FullScreen; char ConfigFile[SYS_MAX_PATH]; char SavePath[SYS_MAX_PATH]; - char DataPath[SYS_MAX_PATH]; + char GameDir[SYS_MAX_PATH]; }; extern struct PCCLIOptions gCLIOpts; diff --git a/src/pc/gfx/gfx_pc.c b/src/pc/gfx/gfx_pc.c index 8e8a7e51..8dd91e08 100644 --- a/src/pc/gfx/gfx_pc.c +++ b/src/pc/gfx/gfx_pc.c @@ -1748,18 +1748,18 @@ void gfx_init(struct GfxWindowManagerAPI *wapi, struct GfxRenderingAPI *rapi) { 0x05200200, 0x03200200 }; - for (size_t i = 0; i < sizeof(precomp_shaders) / sizeof(uint32_t); i++) { + + for (size_t i = 0; i < sizeof(precomp_shaders) / sizeof(uint32_t); i++) gfx_lookup_or_create_shader_program(precomp_shaders[i]); - } - #ifdef EXTERNAL_DATA - // preload all textures if needed - if (configPrecacheRes) { - printf("Precaching textures\n"); - fs_walk(FS_TEXTUREDIR, preload_texture, NULL, true); - } - #endif } +#ifdef EXTERNAL_DATA +void gfx_precache_textures(void) { + // preload all textures + fs_walk(FS_TEXTUREDIR, preload_texture, NULL, true); +} +#endif + void gfx_start_frame(void) { gfx_wapi->handle_events(); gfx_wapi->get_dimensions(&gfx_current_dimensions.width, &gfx_current_dimensions.height); diff --git a/src/pc/gfx/gfx_pc.h b/src/pc/gfx/gfx_pc.h index 8d62e2b7..53a1677b 100644 --- a/src/pc/gfx/gfx_pc.h +++ b/src/pc/gfx/gfx_pc.h @@ -15,6 +15,7 @@ void gfx_init(struct GfxWindowManagerAPI *wapi, struct GfxRenderingAPI *rapi); void gfx_start_frame(void); void gfx_run(Gfx *commands); void gfx_end_frame(void); +void gfx_precache_textures(void); void gfx_shutdown(void); #endif diff --git a/src/pc/pc_main.c b/src/pc/pc_main.c index 3a2d6613..ea322305 100644 --- a/src/pc/pc_main.c +++ b/src/pc/pc_main.c @@ -1,4 +1,5 @@ #include +#include #ifdef TARGET_WEB #include @@ -24,6 +25,7 @@ #include "controller/controller_api.h" #include "fs/fs.h" +#include "game/game_init.h" #include "game/main.h" #include "game/thread6.h" @@ -154,7 +156,9 @@ void main_func(void) { main_pool_init(pool, pool + sizeof(pool) / sizeof(pool[0])); gEffectsMemoryPool = mem_pool_init(0x4000, MEMORY_POOL_LEFT); - fs_init(sys_ropaths, FS_BASEDIR, sys_user_path()); + const char *gamedir = gCLIOpts.GameDir[0] ? gCLIOpts.GameDir : FS_BASEDIR; + const char *userpath = gCLIOpts.SavePath[0] ? gCLIOpts.SavePath : sys_user_path(); + fs_init(sys_ropaths, gamedir, userpath); configfile_load(configfile_name()); @@ -173,9 +177,18 @@ void main_func(void) { sound_init(); thread5_game_loop(NULL); - + inited = true; +#ifdef EXTERNAL_DATA + // precache data if needed + if (configPrecacheRes) { + printf("precaching data\n"); + fflush(stdout); + gfx_precache_textures(); + } +#endif + #ifdef TARGET_WEB emscripten_set_main_loop(em_main_loop, 0, 0); request_anim_frame(on_anim_frame);