diff --git a/thcrap_configure/src/configure.c b/thcrap_configure/src/configure.c index 802c65c4..07d9c375 100644 --- a/thcrap_configure/src/configure.c +++ b/thcrap_configure/src/configure.c @@ -341,7 +341,9 @@ int __cdecl wmain(int argc, wchar_t *wargv[]) "The configuration process has two steps:\n" "\n" "\t\t1. Selecting patches\n" - "\t\t2. Locating game installations\n" + "\t\t2. Download game-independent data\n" + "\t\t3. Locating game installations\n" + "\t\t4. Download game-specific data\n" "\n" "\n" "\n" @@ -373,8 +375,8 @@ int __cdecl wmain(int argc, wchar_t *wargv[]) size_t i; json_t *sel; - log_printf("Bootstrapping selected patches...\n"); - stack_update(NULL, NULL); + log_printf("Downloading game-independent data...\n"); + stack_update(update_filter_global, NULL); /// Build the new run configuration json_array_foreach(sel_stack, i, sel) { @@ -404,6 +406,10 @@ int __cdecl wmain(int argc, wchar_t *wargv[]) games = ConfigureLocateGames(cur_dir); if(json_object_size(games) > 0 && !CreateShortcuts(run_cfg_fn, games)) { + json_t *filter = json_object_get_keys_sorted(games); + log_printf("\nDownloading data specific to the located games...\n"); + stack_update(update_filter_games, filter); + filter = json_decref_safe(filter); log_printf( "\n" "\n" diff --git a/thcrap_configure/src/configure_search.c b/thcrap_configure/src/configure_search.c index dbb18b1e..fe2a4243 100644 --- a/thcrap_configure/src/configure_search.c +++ b/thcrap_configure/src/configure_search.c @@ -77,7 +77,7 @@ json_t* ConfigureLocateGames(const char *games_js_path) if(json_object_size(games) != 0) { log_printf("You already have a %s with the following contents:\n\n", games_js_fn); json_dump_log(games, JSON_INDENT(2) | JSON_SORT_KEYS); - log_printf("\n\n"); + log_printf("\n\nPatch data will be downloaded or updated for all the games listed.\n\n"); if(Ask("Should the paths of these games be re-scanned?")) { json_object_clear(games); } else if(!Ask("Should new games be added to this list?")) { @@ -88,13 +88,13 @@ json_t* ConfigureLocateGames(const char *games_js_path) log_printf( "You don't have a %s yet.\n" "\n" - "Thus, I now need to search for all Touhou games installed on your system.\n" + "Thus, I now need to search for patchable games installed on your system.\n" "This only has to be done once - unless, of course, you later move the games to\n" "different directories.\n" "\n" "Depending on the number of drives and your directory structure,\n" - "this may take a while. You can speed up this process by giving me the\n" - "_common_ root path all of your Touhou games share.\n" + "this may take a while. You can speed up this process by giving me a\n" + "common root path shared by all games you want to patch.\n" "\n" "For example, if you have 'Double Dealing Character' in \n" "\n" diff --git a/thcrap_update/src/thcrap_update.c b/thcrap_update/src/thcrap_update.c index 908c027c..f2b05d16 100644 --- a/thcrap_update/src/thcrap_update.c +++ b/thcrap_update/src/thcrap_update.c @@ -18,7 +18,7 @@ DWORD WINAPI UpdateThread(void *param) if(!TryEnterCriticalSection(&cs_update)) { return 1; } - stack_update(NULL, NULL); + stack_update(update_filter_games, json_object_get(runconfig_get(), "game")); LeaveCriticalSection(&cs_update); return 0; } diff --git a/thcrap_update/src/update.c b/thcrap_update/src/update.c index a1f9f208..2ce62318 100644 --- a/thcrap_update/src/update.c +++ b/thcrap_update/src/update.c @@ -322,6 +322,30 @@ int PatchFileRequiresUpdate(const json_t *patch_info, const char *fn, json_t *lo return 0; } +int update_filter_global(const char *fn, json_t *null) +{ + return strchr(fn, '/') == NULL; +} + +int update_filter_games(const char *fn, json_t *games) +{ + STRLEN_DEC(fn); + size_t i = 0; + json_t *val; + json_flex_array_foreach(games, i, val) { + // We will need to match "th14", but not "th143". + size_t val_len = json_string_length(val); + if( + fn_len > val_len + && !strnicmp(fn, json_string_value(val), val_len) + && fn[val_len] == '/' + ) { + return 1; + } + } + return update_filter_global(fn, NULL); +} + int patch_update(json_t *patch_info, update_filter_func_t filter_func, json_t *filter_data) { const char *files_fn = "files.js"; diff --git a/thcrap_update/src/update.h b/thcrap_update/src/update.h index 10d9c73e..e1aa8296 100644 --- a/thcrap_update/src/update.h +++ b/thcrap_update/src/update.h @@ -53,6 +53,12 @@ void* ServerDownloadFile( // downloaded. typedef int (*update_filter_func_t)(const char *fn, json_t *filter_data); +// Returns 1 for all global file names, i.e. those without a slash. +int update_filter_global(const char *fn, json_t *null); +// Returns 1 for all global file names and those that are specific to a game +// in the flexible JSON array [games]. +int update_filter_games(const char *fn, json_t *games); + int patch_update( json_t *patch_info, update_filter_func_t filter_func, json_t *filter_data ); diff --git a/thcrap_update/thcrap_update.def b/thcrap_update/thcrap_update.def index fd88dd3a..ceb09fd9 100644 --- a/thcrap_update/thcrap_update.def +++ b/thcrap_update/thcrap_update.def @@ -15,6 +15,8 @@ EXPORTS ServerDownloadFile + update_filter_global + update_filter_games patch_update stack_update