From 6950deeccbaff4af3ccf84ee3bb52e3fc866571f Mon Sep 17 00:00:00 2001 From: CrazyRedMachine Date: Sun, 30 Jul 2023 18:17:59 +0200 Subject: [PATCH] exit on xml parsing fail, xml rewrite --- dist/popnhax/popnhax.xml | 13 +++++++++---- popnhax/dllmain.cc | 6 +++++- util/xmlprop.hpp | 7 +++++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/dist/popnhax/popnhax.xml b/dist/popnhax/popnhax.xml index 63921fd..95f3bed 100644 --- a/dist/popnhax/popnhax.xml +++ b/dist/popnhax/popnhax.xml @@ -26,7 +26,7 @@ 0 - + 0 @@ -59,17 +59,22 @@ 0 - + 0 - + 0 - + + diff --git a/popnhax/dllmain.cc b/popnhax/dllmain.cc index da2011d..3730d7b 100644 --- a/popnhax/dllmain.cc +++ b/popnhax/dllmain.cc @@ -3897,7 +3897,11 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv LOG("popnhax: game dll: %s\n",g_game_dll_fn); LOG("popnhax: config file: %s\n",g_config_fn); - _load_config(g_config_fn, &config, config_psmap); + if (!_load_config(g_config_fn, &config, config_psmap)) + { + LOG("FATAL ERROR: Could not parse %s\n", g_config_fn); + return FALSE; + } if (force_trans_debug) config.translation_debug = true; diff --git a/util/xmlprop.hpp b/util/xmlprop.hpp index f988089..081b081 100644 --- a/util/xmlprop.hpp +++ b/util/xmlprop.hpp @@ -84,17 +84,20 @@ struct property *load_prop_file(const char *filename) { return config_data; } -void _load_config(const char *filename, void *dest, const struct property_psmap *psmap) { +bool _load_config(const char *filename, void *dest, const struct property_psmap *psmap) { struct property *config_xml = load_prop_file(filename); if (!config_xml) { printf("Couldn't load xml file: %s\n", filename); - return; + return false; } if (!(property_psmap_import(config_xml, nullptr, dest, psmap))) { printf("Couldn't parse psmap\n"); + return false; } + + return true; } #endif \ No newline at end of file