@@ -778,7 +778,7 @@ int Osiris_FindLoadedModule(const std::filesystem::path &module_name) {
778778 for (int i = 0 ; i < MAX_LOADED_MODULES; i++) {
779779 if (OSIRIS_loaded_modules[i].flags & OSIMF_INUSE) {
780780 if (OSIRIS_loaded_modules[i].module_name &&
781- ( stricmp (OSIRIS_loaded_modules[i].module_name , ( const char *) real_name. u8string (). c_str ()) == 0 ) ) {
781+ stricmp (OSIRIS_loaded_modules[i].module_name , PATH_TO_CSTR ( real_name)) == 0 ) {
782782 // we found a match
783783 return i;
784784 }
@@ -890,7 +890,7 @@ int get_full_path_to_module(const std::filesystem::path &module_name, std::files
890890 adjusted_fname = module_name.filename ();
891891
892892 // make sure filename/ext is all lowercase, requirement for Linux, doesn't hurt Windows
893- std::string p = ( const char *) adjusted_fname. u8string (). c_str ( );
893+ std::string p = PATH_TO_CSTR ( adjusted_fname);
894894 std::transform (p.begin (), p.end (), p.begin (), [](unsigned char c) { return std::tolower (c); });
895895 adjusted_fname = p;
896896
@@ -958,7 +958,7 @@ int Osiris_LoadLevelModule(const std::filesystem::path &module_name) {
958958 // the module is already loaded
959959 OSIRIS_loaded_modules[loaded_id].reference_count ++;
960960 LOG_DEBUG_IF (Show_osiris_debug)
961- .printf (" OSIRIS: Level Module (%s) reference count increased to %d" , module_name. u8string (). c_str ( ),
961+ .printf (" OSIRIS: Level Module (%s) reference count increased to %d" , PATH_TO_CSTR (module_name ),
962962 OSIRIS_loaded_modules[loaded_id].reference_count );
963963 return loaded_id;
964964 }
@@ -973,7 +973,7 @@ int Osiris_LoadLevelModule(const std::filesystem::path &module_name) {
973973
974974 if (loaded_id >= MAX_LOADED_MODULES) {
975975 // no slots available
976- LOG_FATAL.printf (" OSIRIS: Osiris_LoadLevelModule(%s): No available slots\n " , module_name. u8string (). c_str ( ));
976+ LOG_FATAL.printf (" OSIRIS: Osiris_LoadLevelModule(%s): No available slots\n " , PATH_TO_CSTR (module_name ));
977977 Int3 ();
978978 return -4 ;
979979 }
@@ -985,16 +985,16 @@ int Osiris_LoadLevelModule(const std::filesystem::path &module_name) {
985985 switch (ret_val) {
986986 case -2 :
987987 // the module does not exist
988- LOG_ERROR.printf (" OSIRIS: Osiris_LoadLevelModule(%s): Module doesn't exist" , module_name. u8string (). c_str ( ));
988+ LOG_ERROR.printf (" OSIRIS: Osiris_LoadLevelModule(%s): Module doesn't exist" , PATH_TO_CSTR (module_name ));
989989 return -1 ;
990990 break ;
991991 case -1 :
992992 // the module is in data\scripts
993993 break ;
994994 default :
995995 // the module was an extracted file
996- LOG_DEBUG.printf (" OSIRIS: Found module (%s) in a temp file (%s)" , basename. u8string (). c_str ( ),
997- fullpath. u8string (). c_str ( ));
996+ LOG_DEBUG.printf (" OSIRIS: Found module (%s) in a temp file (%s)" , PATH_TO_CSTR (basename ),
997+ PATH_TO_CSTR (fullpath ));
998998 OSIRIS_loaded_modules[loaded_id].flags |= OSIMF_INTEMPDIR;
999999 OSIRIS_loaded_modules[loaded_id].extracted_id = ret_val;
10001000 break ;
@@ -1003,7 +1003,7 @@ int Osiris_LoadLevelModule(const std::filesystem::path &module_name) {
10031003 // the module exists, now attempt to load it
10041004 if (!mod_LoadModule (&OSIRIS_loaded_modules[loaded_id].mod , fullpath)) {
10051005 // there was an error trying to load the module
1006- LOG_FATAL.printf (" OSIRIS: Osiris_LoadLevelModule(%s): Unable to load module" , module_name. u8string (). c_str ( ));
1006+ LOG_FATAL.printf (" OSIRIS: Osiris_LoadLevelModule(%s): Unable to load module" , PATH_TO_CSTR (module_name ));
10071007 Int3 ();
10081008 return -3 ;
10091009 }
@@ -1034,7 +1034,7 @@ int Osiris_LoadLevelModule(const std::filesystem::path &module_name) {
10341034 osm->SaveRestoreState = (SaveRestoreState_fp)mod_GetSymbol (mod, " SaveRestoreState" , 8 );
10351035
10361036 osm->flags |= OSIMF_INUSE | OSIMF_LEVEL;
1037- osm->module_name = mem_strdup (( const char *) basename. u8string (). c_str ( ));
1037+ osm->module_name = mem_strdup (PATH_TO_CSTR ( basename));
10381038 osm->reference_count = 1 ;
10391039
10401040#ifdef OSIRISDEBUG
@@ -1047,7 +1047,7 @@ int Osiris_LoadLevelModule(const std::filesystem::path &module_name) {
10471047 !osm->GetCOScriptList || !osm->CreateInstance || !osm->DestroyInstance || !osm->SaveRestoreState ||
10481048 !osm->CallInstanceEvent ) {
10491049 // there was an error importing a function
1050- LOG_ERROR.printf (" OSIRIS: Osiris_LoadLevelModule(%s) couldn't import function." , ( const char *) module_name. u8string (). c_str ( ));
1050+ LOG_ERROR.printf (" OSIRIS: Osiris_LoadLevelModule(%s) couldn't import function." , PATH_TO_CSTR ( module_name));
10511051 Int3 ();
10521052 osm->flags = 0 ;
10531053 if (osm->module_name )
@@ -1059,15 +1059,15 @@ int Osiris_LoadLevelModule(const std::filesystem::path &module_name) {
10591059
10601060 // check to see if there is a corresponding string table to load
10611061 char stringtablename[_MAX_PATH];
1062- strcpy (stringtablename, ( const char *) basename. u8string (). c_str ( ));
1062+ strcpy (stringtablename, PATH_TO_CSTR ( basename));
10631063 strcat (stringtablename, " .str" );
10641064
10651065 if (cfexist (stringtablename)) {
10661066 // there is a string table, load it up
10671067 bool ret = CreateStringTable (stringtablename, &osm->string_table , &osm->strings_loaded );
10681068 if (!ret) {
10691069 LOG_ERROR.printf (" OSIRIS: Unable to load string table (%s) for (%s)" , stringtablename,
1070- basename. u8string (). c_str ( ));
1070+ PATH_TO_CSTR (basename ));
10711071 Int3 ();
10721072 osm->string_table = NULL ;
10731073 osm->strings_loaded = 0 ;
@@ -1086,7 +1086,7 @@ int Osiris_LoadLevelModule(const std::filesystem::path &module_name) {
10861086 // when we get to this point we nearly have a loaded module, we just need to initialize it
10871087 if (!osm->InitializeDLL (&Osiris_module_init)) {
10881088 // there was an error initializing the module
1089- LOG_ERROR.printf (" OSIRIS: Osiris_LoadLevelModule(%s) error initializing module." , basename. u8string (). c_str ( ));
1089+ LOG_ERROR.printf (" OSIRIS: Osiris_LoadLevelModule(%s) error initializing module." , PATH_TO_CSTR (basename ));
10901090 if (osm->string_table ) {
10911091 DestroyStringTable (osm->string_table , osm->strings_loaded );
10921092 }
@@ -1129,7 +1129,7 @@ int Osiris_LoadLevelModule(const std::filesystem::path &module_name) {
11291129 tOSIRISCurrentLevel.instance =
11301130 OSIRIS_loaded_modules[loaded_id].CreateInstance (0 ); // level scripts always have id of 0 in a level dll
11311131
1132- LOG_INFO.printf (" OSIRIS: Level Module (%s) loaded successfully (%d custom handles)" , basename. u8string (). c_str ( ),
1132+ LOG_INFO.printf (" OSIRIS: Level Module (%s) loaded successfully (%d custom handles)" , PATH_TO_CSTR (basename ),
11331133 tOSIRISCurrentLevel.num_customs );
11341134 Osiris_level_script_loaded = true ;
11351135 return loaded_id;
@@ -1153,7 +1153,7 @@ int Osiris_LoadGameModule(const std::filesystem::path &module_name) {
11531153 // the module is already loaded
11541154 OSIRIS_loaded_modules[loaded_id].reference_count ++;
11551155 if (Show_osiris_debug) {
1156- LOG_DEBUG.printf (" OSIRIS: Game Module (%s) reference count increased to %d" , module_name. u8string (). c_str ( ),
1156+ LOG_DEBUG.printf (" OSIRIS: Game Module (%s) reference count increased to %d" , PATH_TO_CSTR (module_name ),
11571157 OSIRIS_loaded_modules[loaded_id].reference_count );
11581158 }
11591159 return loaded_id;
@@ -1169,7 +1169,7 @@ int Osiris_LoadGameModule(const std::filesystem::path &module_name) {
11691169
11701170 if (loaded_id >= MAX_LOADED_MODULES) {
11711171 // no slots available
1172- LOG_FATAL.printf (" OSIRIS: Osiris_LoadGameModule(%s): No available slots" , module_name. u8string (). c_str ( ));
1172+ LOG_FATAL.printf (" OSIRIS: Osiris_LoadGameModule(%s): No available slots" , PATH_TO_CSTR (module_name ));
11731173 Int3 ();
11741174 return -4 ;
11751175 }
@@ -1181,15 +1181,15 @@ int Osiris_LoadGameModule(const std::filesystem::path &module_name) {
11811181 switch (ret_val) {
11821182 case -2 :
11831183 // the module does not exist
1184- LOG_WARNING.printf (" OSIRIS: Osiris_LoadLevelModule(%s): Module doesn't exist" , module_name. u8string (). c_str ( ));
1184+ LOG_WARNING.printf (" OSIRIS: Osiris_LoadLevelModule(%s): Module doesn't exist" , PATH_TO_CSTR (module_name ));
11851185 return -1 ;
11861186 break ;
11871187 case -1 :
11881188 // the module is in data\scripts
11891189 break ;
11901190 default :
11911191 // the module was an extracted file
1192- LOG_INFO.printf (" OSIRIS: Found module (%s) in a temp file" , basename. u8string (). c_str ( ));
1192+ LOG_INFO.printf (" OSIRIS: Found module (%s) in a temp file" , PATH_TO_CSTR (basename ));
11931193 OSIRIS_loaded_modules[loaded_id].flags |= OSIMF_INTEMPDIR;
11941194 OSIRIS_loaded_modules[loaded_id].extracted_id = ret_val;
11951195 break ;
@@ -1198,7 +1198,7 @@ int Osiris_LoadGameModule(const std::filesystem::path &module_name) {
11981198 // the module exists, now attempt to load it
11991199 if (!mod_LoadModule (&OSIRIS_loaded_modules[loaded_id].mod , fullpath)) {
12001200 // there was an error trying to load the module
1201- LOG_FATAL.printf (" OSIRIS: Osiris_LoadGameModule(%s): Unable to load module" , module_name. u8string (). c_str ( ));
1201+ LOG_FATAL.printf (" OSIRIS: Osiris_LoadGameModule(%s): Unable to load module" , PATH_TO_CSTR (module_name ));
12021202 Int3 ();
12031203 return -3 ;
12041204 }
@@ -1227,7 +1227,7 @@ int Osiris_LoadGameModule(const std::filesystem::path &module_name) {
12271227 osm->SaveRestoreState = (SaveRestoreState_fp)mod_GetSymbol (mod, " SaveRestoreState" , 8 );
12281228
12291229 osm->flags |= OSIMF_INUSE;
1230- osm->module_name = mem_strdup (( const char *) basename. u8string (). c_str ( ));
1230+ osm->module_name = mem_strdup (PATH_TO_CSTR ( basename));
12311231 osm->reference_count = 1 ;
12321232
12331233#ifdef OSIRISDEBUG
@@ -1239,7 +1239,7 @@ int Osiris_LoadGameModule(const std::filesystem::path &module_name) {
12391239 if (!osm->InitializeDLL || !osm->ShutdownDLL || !osm->GetGOScriptID || !osm->CreateInstance ||
12401240 !osm->DestroyInstance || !osm->SaveRestoreState || !osm->CallInstanceEvent ) {
12411241 // there was an error importing a function
1242- LOG_WARNING.printf (" OSIRIS: Osiris_LoadGameModule(%s) couldn't import function." , basename. u8string (). c_str ( ));
1242+ LOG_WARNING.printf (" OSIRIS: Osiris_LoadGameModule(%s) couldn't import function." , PATH_TO_CSTR (basename ));
12431243 Int3 ();
12441244 osm->flags = 0 ;
12451245 if (osm->module_name )
@@ -1251,15 +1251,15 @@ int Osiris_LoadGameModule(const std::filesystem::path &module_name) {
12511251
12521252 // check to see if there is a corresponding string table to load
12531253 char stringtablename[_MAX_PATH];
1254- strcpy (stringtablename, ( const char *) basename. u8string (). c_str ( ));
1254+ strcpy (stringtablename, PATH_TO_CSTR ( basename));
12551255 strcat (stringtablename, " .str" );
12561256
12571257 if (cfexist (stringtablename)) {
12581258 // there is a string table, load it up
12591259 bool ret = CreateStringTable (stringtablename, &osm->string_table , &osm->strings_loaded );
12601260 if (!ret) {
12611261 LOG_FATAL.printf (" OSIRIS: Unable to load string table (%s) for (%s)" , stringtablename,
1262- ( const char *) basename. u8string (). c_str ( ));
1262+ PATH_TO_CSTR ( basename));
12631263 Int3 ();
12641264 osm->string_table = nullptr ;
12651265 osm->strings_loaded = 0 ;
@@ -1277,7 +1277,7 @@ int Osiris_LoadGameModule(const std::filesystem::path &module_name) {
12771277 // when we get to this point we nearly have a loaded module, we just need to initialize it
12781278 if (!osm->InitializeDLL (&Osiris_module_init)) {
12791279 // there was an error initializing the module
1280- LOG_ERROR.printf (" OSIRIS: Osiris_LoadGameModule(%s) error initializing module." , ( const char *) basename. u8string (). c_str ( ));
1280+ LOG_ERROR.printf (" OSIRIS: Osiris_LoadGameModule(%s) error initializing module." , PATH_TO_CSTR ( basename));
12811281 if (osm->string_table ) {
12821282 DestroyStringTable (osm->string_table , osm->strings_loaded );
12831283 }
@@ -1298,7 +1298,7 @@ int Osiris_LoadGameModule(const std::filesystem::path &module_name) {
12981298 }
12991299
13001300 // we have a successful module load
1301- LOG_INFO.printf (" OSIRIS: Game Module (%s) loaded successfully" , basename. u8string (). c_str ( ));
1301+ LOG_INFO.printf (" OSIRIS: Game Module (%s) loaded successfully" , PATH_TO_CSTR (basename ));
13021302 return loaded_id;
13031303}
13041304
@@ -3120,7 +3120,7 @@ int Osiris_ExtractScriptsFromHog(int library_handle, bool is_mission_hog) {
31203120 if (temp_filename.empty ()) {
31213121 Int3 ();
31223122 } else {
3123- std::string temp_realname = ( const char *) std::filesystem::path (filename).stem (). u8string (). c_str ( );
3123+ std::string temp_realname = PATH_TO_CSTR ( std::filesystem::path (filename).stem ());
31243124 // Lowercase for optimized search
31253125 std::transform (temp_realname.begin (), temp_realname.end (), temp_realname.begin (),
31263126 [](unsigned char c) { return std::tolower (c); });
@@ -3135,7 +3135,7 @@ int Osiris_ExtractScriptsFromHog(int library_handle, bool is_mission_hog) {
31353135 t.temp_filename = temp_filename.filename ();
31363136 OSIRIS_Extracted_scripts.insert_or_assign (temp_realname, t);
31373137
3138- LOG_DEBUG.printf (" Extracted %s as %s" , temp_realname.c_str (), temp_filename. u8string (). c_str ( ));
3138+ LOG_DEBUG.printf (" Extracted %s as %s" , temp_realname.c_str (), PATH_TO_CSTR (temp_filename ));
31393139 } else {
31403140 LOG_DEBUG.printf (" Skipped %s (already extracted)" , temp_realname.c_str ());
31413141 }
0 commit comments