diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c4eb7316..d6954c9d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,9 +97,9 @@ endif() # 64 bit machines have a different game checksum than 32 bit machines if (CMAKE_SIZEOF_VOID_P EQUAL 8) - add_definitions(-DCHECKSUM=2273889835UL) + add_definitions(-DCHECKSUM=2273864794UL) else() - add_definitions(-DCHECKSUM=2273873307UL) + add_definitions(-DCHECKSUM=2273860746UL) endif() if(BUILD_TESTING) diff --git a/Descent3/CtlCfgElem.cpp b/Descent3/CtlCfgElem.cpp index 1a69f607e..941cdef17 100644 --- a/Descent3/CtlCfgElem.cpp +++ b/Descent3/CtlCfgElem.cpp @@ -113,18 +113,20 @@ * $NoKeywords: $ */ +#include +#include +#include + #include "CtlCfgElem.h" #include "descent.h" #include "Macros.h" #include "ddio.h" -#include "application.h" #include "renderer.h" #include "stringtable.h" #include "gamefont.h" #include "localization.h" -#include #include "joystick.h" // all controller binding texts @@ -417,58 +419,58 @@ extern char Ctltext_MseBtnBindings[][32]; extern char Ctltext_MseAxisBindings[][32]; void Localize_ctl_bindings() { - char **strtable; - int n_strings, i; + std::vector strtable; + int i; // keyboard translations. // no need to do for english! if (Localization_GetLanguage() == LANGUAGE_ENGLISH) return; - if (CreateStringTable("bindkey.str", &strtable, &n_strings)) { + if (CreateStringTable("bindkey.str", strtable)) { i = 0; while (key_binding_indices[i] != 0xff) { - if (i >= n_strings) { + if (i >= strtable.size()) { break; } - strcpy(Ctltext_KeyBindings[key_binding_indices[i]], strtable[i]); + strcpy(Ctltext_KeyBindings[key_binding_indices[i]], strtable[i].c_str()); i++; } - DestroyStringTable(strtable, n_strings); + DestroyStringTable(strtable); } // mouse translations. - if (CreateStringTable("bindmse.str", &strtable, &n_strings)) { + if (CreateStringTable("bindmse.str", strtable)) { for (i = 0; i < 6; i++) { - if (i >= n_strings) { + if (i >= strtable.size()) { break; } - strcpy(Ctltext_MseBtnBindings[i], strtable[i]); + strcpy(Ctltext_MseBtnBindings[i], strtable[i].c_str()); } for (i = 0; i < 3; i++) { - if ((i + 6) >= n_strings) { + if ((i + 6) >= strtable.size()) { break; } - strcpy(Ctltext_MseAxisBindings[i], strtable[i + 6]); + strcpy(Ctltext_MseAxisBindings[i], strtable[i + 6].c_str()); } - DestroyStringTable(strtable, n_strings); + DestroyStringTable(strtable); } // joystick translations. - if (CreateStringTable("bindjoy.str", &strtable, &n_strings)) { + if (CreateStringTable("bindjoy.str", strtable)) { for (i = 0; i < 6; i++) { - if (i >= n_strings) { + if (i >= strtable.size()) { break; } - strcpy(Ctltext_AxisBindings[i + 1], strtable[i]); + strcpy(Ctltext_AxisBindings[i + 1], strtable[i].c_str()); } for (i = 0; i < 4; i++) { - if ((i + 6) >= n_strings) { + if ((i + 6) >= strtable.size()) { break; } - strcpy(Ctltext_PovBindings[i + 1], strtable[i + 6]); + strcpy(Ctltext_PovBindings[i + 1], strtable[i + 6].c_str()); } - DestroyStringTable(strtable, n_strings); + DestroyStringTable(strtable); } } diff --git a/Descent3/Game2DLL.cpp b/Descent3/Game2DLL.cpp index 3eafc2954..456cf8237 100644 --- a/Descent3/Game2DLL.cpp +++ b/Descent3/Game2DLL.cpp @@ -17,6 +17,8 @@ */ #include +#include +#include #include "pstypes.h" #include "pserror.h" @@ -62,6 +64,7 @@ #include "ObjScript.h" #include "args.h" + void SelectNextCameraView(int window); #define NUM_CAMERA_VIEWS 3 extern int Camera_view_mode[NUM_CAMERA_VIEWS]; @@ -539,7 +542,7 @@ void GetGameAPI(game_api *api) { api->osiris_functions = &Multi_d3m_osiris_funcs; Osiris_CreateModuleInitStruct(&Multi_d3m_osiris_funcs); - Multi_d3m_osiris_funcs.string_table = NULL; + Multi_d3m_osiris_funcs.string_table.clear(); Multi_d3m_osiris_funcs.string_count = 0; Multi_d3m_osiris_funcs.module_identifier = 0xEDF7; Multi_d3m_osiris_funcs.module_is_static = false; diff --git a/Descent3/LoadLevel.cpp b/Descent3/LoadLevel.cpp index 411e8ed2d..0d9cfcb57 100644 --- a/Descent3/LoadLevel.cpp +++ b/Descent3/LoadLevel.cpp @@ -1237,10 +1237,11 @@ * $NoKeywords: $ */ +#include #include #include -#include -#include +#include +#include #include "LoadLevel.h" @@ -5712,18 +5713,12 @@ int CountDataToPageIn() { #endif -void Localization_SetLanguage(int type); - -int Localization_GetLanguage(void); - char *LocalizeLevelName(char *level) { static char local_name[101]; - char **english_names; - int num_english_names; + std::vector english_names; - char **local_names; - int num_local_names; + std::vector local_names; local_name[0] = 0; @@ -5736,7 +5731,7 @@ char *LocalizeLevelName(char *level) { Localization_SetLanguage(LANGUAGE_ENGLISH); // Save the current language, then bash it to english - if (!CreateStringTable("level_names.str", &english_names, &num_english_names)) { + if (!CreateStringTable("level_names.str", english_names)) { LOG_WARNING << "Couldn't open level_names stringtable!"; Localization_SetLanguage(save_lang); strcpy(local_name, level); @@ -5746,22 +5741,22 @@ char *LocalizeLevelName(char *level) { // Restore the correct language Localization_SetLanguage(save_lang); - if (!CreateStringTable("level_names.str", &local_names, &num_local_names)) { + if (!CreateStringTable("level_names.str", local_names)) { LOG_WARNING << "Couldn't open level_names stringtable!"; // destroy the english stringtable... - DestroyStringTable(english_names, num_english_names); + DestroyStringTable(english_names); strcpy(local_name, level); return local_name; } // Now search for the correct level - for (int i = 0; i < num_english_names; i++) { - if (0 == stricmp(level, english_names[i])) { + for (int i = 0; i < english_names.size(); i++) { + if (0 == stricmp(level, english_names[i].c_str())) { // Ok, we found a match. So return the local text. - strcpy(local_name, local_names[i]); - DestroyStringTable(english_names, num_english_names); - DestroyStringTable(local_names, num_local_names); + strcpy(local_name, local_names[i].c_str()); + DestroyStringTable(english_names); + DestroyStringTable(local_names); return local_name; } } diff --git a/Descent3/Mission.cpp b/Descent3/Mission.cpp index dcde32a16..63dc2d947 100644 --- a/Descent3/Mission.cpp +++ b/Descent3/Mission.cpp @@ -640,6 +640,8 @@ #include #include #include +#include +#include #include "Mission.h" #include "3d.h" @@ -648,6 +650,8 @@ #include "cfile.h" #include "gamefont.h" #include "grdefs.h" +#include "levelgoal.h" +#include "localization.h" #include "descent.h" #include "ddio.h" #include "d3movie.h" @@ -672,6 +676,7 @@ #include "terrain.h" #include "multi.h" #include "hud.h" + // --------------------------------------------------------------------------- // Data // --------------------------------------------------------------------------- @@ -1245,25 +1250,20 @@ void FreeMission() { Current_mission.hog = NULL; Current_level = NULL; } -#include "localization.h" -#include "levelgoal.h" -// Load the text (goal strings) for a level -void LoadLevelText(const char *level_filename) { - char pathname[_MAX_FNAME], filename[_MAX_FNAME]; - int n_strings; - ddio_SplitPath(level_filename, pathname, filename, NULL); - strcat(pathname, filename); - strcat(pathname, ".str"); - char **goal_strings; - if (CreateStringTable(pathname, &goal_strings, &n_strings)) { + +void LoadLevelText(const std::filesystem::path &level_filename) { + std::filesystem::path pathname = level_filename; + pathname.replace_extension(".str"); + std::vector goal_strings; + if (CreateStringTable(pathname, goal_strings)) { int n_goals = Level_goals.GetNumGoals(); - ASSERT(n_strings == (n_goals * 3)); + ASSERT(goal_strings.size() == (n_goals * 3)); for (int i = 0; i < n_goals; i++) { - Level_goals.GoalSetName(i, goal_strings[i * 3]); - Level_goals.GoalSetItemName(i, goal_strings[i * 3 + 1]); - Level_goals.GoalSetDesc(i, goal_strings[i * 3 + 2]); + Level_goals.GoalSetName(i, (char *)goal_strings[i * 3].c_str()); + Level_goals.GoalSetItemName(i, (char *)goal_strings[i * 3 + 1].c_str()); + Level_goals.GoalSetDesc(i, (char *)goal_strings[i * 3 + 2].c_str()); } - DestroyStringTable(goal_strings, n_strings); + DestroyStringTable(goal_strings); } } diff --git a/Descent3/Mission.h b/Descent3/Mission.h index 6701ea9ec..ee392eac8 100644 --- a/Descent3/Mission.h +++ b/Descent3/Mission.h @@ -167,7 +167,6 @@ #ifndef MISSION_H #define MISSION_H -#include "pstypes.h" #include "descent.h" // *** CONSTANTS *** @@ -177,11 +176,14 @@ #define LOAD_PROGRESS_PREPARE 4 #define LOAD_PROGRESS_DONE 200 +// Load the text (goal strings) for a level +void LoadLevelText(const std::filesystem::path &level_filename); + // Load level progress worker void LoadLevelProgress(int step, float percent, const char *chunk = NULL); // array constants -const int MSN_FILENAMELEN = _MAX_PATH, MSN_URLLEN = 256; +const int MSN_URLLEN = 256; #define MAX_KEYWORDLEN 300 diff --git a/Descent3/OsirisLoadandBind.cpp b/Descent3/OsirisLoadandBind.cpp index b35872e9b..4eb96c69b 100644 --- a/Descent3/OsirisLoadandBind.cpp +++ b/Descent3/OsirisLoadandBind.cpp @@ -398,6 +398,10 @@ * * $NoKeywords: $ */ +#include +#include +#include + #include #include @@ -484,7 +488,7 @@ struct tOSIRISModule { SaveRestoreState_fp SaveRestoreState; module mod; char *module_name; - char **string_table; + std::vector string_table; int strings_loaded; #ifdef OSIRISDEBUG @@ -595,7 +599,7 @@ void Osiris_InitModuleLoader(void) { OSIRIS_loaded_modules[i].GetTriggerScriptID = NULL; OSIRIS_loaded_modules[i].InitializeDLL = NULL; OSIRIS_loaded_modules[i].SaveRestoreState = NULL; - OSIRIS_loaded_modules[i].string_table = NULL; + OSIRIS_loaded_modules[i].string_table = std::vector(0); OSIRIS_loaded_modules[i].strings_loaded = 0; #ifdef OSIRISDEBUG @@ -631,12 +635,13 @@ void Osiris_InitModuleLoader(void) { // Generates a checksum of the game's structures, to give to the modules // so they can use to compare to the time when they were compiled, to see // if they are compatible. -uint32_t Osiris_CreateGameChecksum(void) { +uint32_t Osiris_CreateGameChecksum() { uint32_t value = 0xe1e1b0b0; + tOSIRISModuleInit tmp; value += sizeof(object); value += sizeof(player) * 2; - value += sizeof(tOSIRISModuleInit) * 3; + value += tmp.serial_version * 3; value += sizeof(tOSIRISEventInfo) * 5; value += sizeof(tOSIRISTIMER) * 7; value += sizeof(tOSIRISSCRIPTID) * 11; @@ -690,8 +695,8 @@ void Osiris_FreeModule(int id) { OSIRIS_loaded_modules[id].ShutdownDLL(); } - if (OSIRIS_loaded_modules[id].string_table != NULL) { - DestroyStringTable(OSIRIS_loaded_modules[id].string_table, OSIRIS_loaded_modules[id].strings_loaded); + if (!OSIRIS_loaded_modules[id].string_table.empty()) { + DestroyStringTable(OSIRIS_loaded_modules[id].string_table); } mod_FreeModule(&OSIRIS_loaded_modules[id].mod); } @@ -710,7 +715,7 @@ void Osiris_FreeModule(int id) { OSIRIS_loaded_modules[id].GetTriggerScriptID = NULL; OSIRIS_loaded_modules[id].InitializeDLL = NULL; OSIRIS_loaded_modules[id].SaveRestoreState = NULL; - OSIRIS_loaded_modules[id].string_table = NULL; + OSIRIS_loaded_modules[id].string_table.clear(); OSIRIS_loaded_modules[id].strings_loaded = 0; OSIRIS_loaded_modules[id].flags = 0; OSIRIS_loaded_modules[id].reference_count = 0; @@ -1056,22 +1061,22 @@ int Osiris_LoadLevelModule(const std::filesystem::path &module_name) { } // check to see if there is a corresponding string table to load - char stringtablename[_MAX_PATH]; - strcpy(stringtablename, basename.u8string().c_str()); - strcat(stringtablename, ".str"); + std::filesystem::path stringtablename = basename; + stringtablename.replace_extension(".str"); if (cfexist(stringtablename)) { // there is a string table, load it up - bool ret = CreateStringTable(stringtablename, &osm->string_table, &osm->strings_loaded); + bool ret = CreateStringTable(stringtablename, osm->string_table); + osm->strings_loaded = osm->string_table.size(); if (!ret) { - LOG_ERROR.printf("OSIRIS: Unable to load string table (%s) for (%s)", stringtablename, + LOG_ERROR.printf("OSIRIS: Unable to load string table (%s) for (%s)", stringtablename.u8string().c_str(), basename.u8string().c_str()); Int3(); - osm->string_table = NULL; + osm->string_table.clear(); osm->strings_loaded = 0; } } else { - osm->string_table = NULL; + osm->string_table.clear(); osm->strings_loaded = 0; } @@ -1085,14 +1090,14 @@ int Osiris_LoadLevelModule(const std::filesystem::path &module_name) { if (!osm->InitializeDLL(&Osiris_module_init)) { // there was an error initializing the module LOG_ERROR.printf("OSIRIS: Osiris_LoadLevelModule(%s) error initializing module.", basename.u8string().c_str()); - if (osm->string_table) { - DestroyStringTable(osm->string_table, osm->strings_loaded); + if (!osm->string_table.empty()) { + DestroyStringTable(osm->string_table); } osm->flags = 0; if (osm->module_name) mem_free(osm->module_name); osm->module_name = NULL; - osm->string_table = NULL; + osm->string_table.clear(); osm->strings_loaded = 0; mod_FreeModule(mod); return -2; @@ -1248,22 +1253,22 @@ int Osiris_LoadGameModule(const std::filesystem::path &module_name) { } // check to see if there is a corresponding string table to load - char stringtablename[_MAX_PATH]; - strcpy(stringtablename, basename.u8string().c_str()); - strcat(stringtablename, ".str"); + std::filesystem::path stringtablename = basename; + stringtablename.replace_extension(".str"); if (cfexist(stringtablename)) { // there is a string table, load it up - bool ret = CreateStringTable(stringtablename, &osm->string_table, &osm->strings_loaded); + bool ret = CreateStringTable(stringtablename, osm->string_table); + osm->strings_loaded = osm->string_table.size(); if (!ret) { - LOG_FATAL.printf("OSIRIS: Unable to load string table (%s) for (%s)", stringtablename, + LOG_FATAL.printf("OSIRIS: Unable to load string table (%s) for (%s)", stringtablename.u8string().c_str(), basename.u8string().c_str()); Int3(); - osm->string_table = nullptr; + osm->string_table.clear(); osm->strings_loaded = 0; } } else { - osm->string_table = nullptr; + osm->string_table.clear(); osm->strings_loaded = 0; } Osiris_module_init.string_count = osm->strings_loaded; @@ -1276,10 +1281,10 @@ int Osiris_LoadGameModule(const std::filesystem::path &module_name) { if (!osm->InitializeDLL(&Osiris_module_init)) { // there was an error initializing the module LOG_ERROR.printf("OSIRIS: Osiris_LoadGameModule(%s) error initializing module.", basename.u8string().c_str()); - if (osm->string_table) { - DestroyStringTable(osm->string_table, osm->strings_loaded); + if (!osm->string_table.empty()) { + DestroyStringTable(osm->string_table); } - osm->string_table = NULL; + osm->string_table.clear(); osm->strings_loaded = 0; osm->flags = 0; if (osm->module_name) @@ -3841,136 +3846,137 @@ char Osiris_OMMS_GetInfo(OMMSHANDLE handle, uint32_t *mem_size, uint32_t *uid, u // This function initializes a Module Init Struct with all the needed data to get sent // to the module during initialization. void Osiris_CreateModuleInitStruct(tOSIRISModuleInit *mi) { - int i = 0; + // fill in with NULL + for (auto & i : mi->fp) { + i = nullptr; + } // fill in function pointers here - mi->fp[i++] = (int *)MonoPrintf; - mi->fp[i++] = (int *)msafe_CallFunction; - mi->fp[i++] = (int *)msafe_GetValue; - mi->fp[i++] = (int *)osipf_CallObjectEvent; - mi->fp[i++] = (int *)osipf_CallTriggerEvent; - mi->fp[i++] = (int *)osipf_SoundTouch; - mi->fp[i++] = (int *)osipf_ObjectFindID; - mi->fp[i++] = (int *)osipf_WeaponFindID; - mi->fp[i++] = (int *)osipf_ObjectGetTimeLived; - mi->fp[i++] = (int *)osipf_GetGunPos; - mi->fp[i++] = (int *)osipf_RoomValue; - mi->fp[i++] = (int *)osipf_IsRoomValid; - mi->fp[i++] = (int *)osipf_GetAttachParent; - mi->fp[i++] = (int *)osipf_GetNumAttachSlots; - mi->fp[i++] = (int *)osipf_GetAttachChildHandle; - mi->fp[i++] = (int *)osipf_AttachObjectAP; - mi->fp[i++] = (int *)osipf_AttachObjectRad; - mi->fp[i++] = (int *)osipf_UnattachFromParent; - mi->fp[i++] = (int *)osipf_UnattachChild; - mi->fp[i++] = (int *)osipf_UnattachChildren; - mi->fp[i++] = (int *)osipf_RayCast; - mi->fp[i++] = (int *)osipf_AIGetPathID; - mi->fp[i++] = (int *)osipf_AIGoalFollowPathSimple; - mi->fp[i++] = (int *)osipf_AIPowerSwitch; - mi->fp[i++] = (int *)osipf_AITurnTowardsVectors; - mi->fp[i++] = (int *)osipf_AISetType; - mi->fp[i++] = (int *)osipf_AIFindHidePos; - mi->fp[i++] = (int *)osipf_AIGoalAddEnabler; - mi->fp[i++] = (int *)osipf_AIGoalAdd; - mi->fp[i++] = (int *)osipf_AIGoalClear; - mi->fp[i++] = (int *)osipf_AIValue; - mi->fp[i++] = (int *)osipf_AIFindObjOfType; - mi->fp[i++] = (int *)osipf_AIGetRoomPathPoint; - mi->fp[i++] = (int *)osipf_AIFindEnergyCenter; - mi->fp[i++] = (int *)osipf_AIGetDistToObj; - mi->fp[i++] = (int *)osipf_AISetGoalFlags; - mi->fp[i++] = (int *)osipf_AISetGoalCircleDist; - mi->fp[i++] = (int *)osipf_CFReadBytes; - mi->fp[i++] = (int *)osipf_CFReadInt; - mi->fp[i++] = (int *)osipf_CFReadShort; - mi->fp[i++] = (int *)osipf_CFReadByte; - mi->fp[i++] = (int *)osipf_CFReadFloat; - mi->fp[i++] = (int *)osipf_CFReadDouble; - mi->fp[i++] = (int *)osipf_CFReadString; - mi->fp[i++] = (int *)osipf_CFWriteBytes; - mi->fp[i++] = (int *)osipf_CFWriteString; - mi->fp[i++] = (int *)osipf_CFWriteInt; - mi->fp[i++] = (int *)osipf_CFWriteShort; - mi->fp[i++] = (int *)osipf_CFWriteByte; - mi->fp[i++] = (int *)osipf_CFWriteFloat; - mi->fp[i++] = (int *)osipf_CFWriteDouble; - mi->fp[i++] = (int *)Osiris_AllocateMemory; - mi->fp[i++] = (int *)Osiris_FreeMemory; - mi->fp[i++] = (int *)Osiris_CancelTimer; - mi->fp[i++] = (int *)Osiris_CreateTimer; - mi->fp[i++] = (int *)msafe_DoPowerup; - mi->fp[i++] = (int *)osipf_ObjCreate; - mi->fp[i++] = (int *)osipf_GameTime; - mi->fp[i++] = (int *)osipf_FrameTime; - mi->fp[i++] = (int *)osipf_ObjWBValue; - mi->fp[i++] = (int *)Osiris_TimerExists; - mi->fp[i++] = (int *)osipf_ObjectValue; - mi->fp[i++] = (int *)osipf_MatcenValue; - mi->fp[i++] = (int *)osipf_MatcenReset; - mi->fp[i++] = (int *)osipf_MatcenCopy; - mi->fp[i++] = (int *)osipf_MatcenCreate; - mi->fp[i++] = (int *)osipf_MatcenFindId; - mi->fp[i++] = (int *)osipf_MissionFlagSet; - mi->fp[i++] = (int *)osipf_MissionFlagGet; - mi->fp[i++] = (int *)osipf_PlayerValue; - mi->fp[i++] = (int *)osipf_ObjectCustomAnim; - mi->fp[i++] = (int *)osipf_PlayerAddHudMessage; - mi->fp[i++] = (int *)osipf_ObjGhost; - mi->fp[i++] = (int *)osipf_ObjBurning; - mi->fp[i++] = (int *)osipf_ObjIsEffect; - mi->fp[i++] = (int *)osipf_CFopen; - mi->fp[i++] = (int *)osipf_CFclose; - mi->fp[i++] = (int *)osipf_CFtell; - mi->fp[i++] = (int *)osipf_CFeof; - mi->fp[i++] = (int *)osipf_SoundStop; - mi->fp[i++] = (int *)osipf_SoundPlay2d; - mi->fp[i++] = (int *)osipf_SoundPlay3d; - mi->fp[i++] = (int *)osipf_SoundFindId; - mi->fp[i++] = (int *)osipf_AIIsObjFriend; - mi->fp[i++] = (int *)osipf_AIIsObjEnemy; - mi->fp[i++] = (int *)osipf_AIGoalValue; - mi->fp[i++] = (int *)osipf_AIGetNearbyObjs; - mi->fp[i++] = (int *)osipf_AIGetCurGoalIndex; - mi->fp[i++] = (int *)Osiris_OMMS_Malloc; - mi->fp[i++] = (int *)Osiris_OMMS_Attach; - mi->fp[i++] = (int *)Osiris_OMMS_Detach; - mi->fp[i++] = (int *)Osiris_OMMS_Free; - mi->fp[i++] = (int *)Osiris_OMMS_Find; - mi->fp[i++] = (int *)Osiris_OMMS_GetInfo; - mi->fp[i++] = (int *)Cinematic_Start; - mi->fp[i++] = (int *)Cinematic_Stop; - mi->fp[i++] = (int *)osipf_FindSoundName; - mi->fp[i++] = (int *)osipf_FindRoomName; - mi->fp[i++] = (int *)osipf_FindTriggerName; - mi->fp[i++] = (int *)osipf_FindObjectName; - mi->fp[i++] = (int *)osipf_GetTriggerRoom; - mi->fp[i++] = (int *)osipf_GetTriggerFace; - mi->fp[i++] = (int *)osipf_FindDoorName; - mi->fp[i++] = (int *)osipf_FindTextureName; - mi->fp[i++] = (int *)osipf_CreateRandomSparks; - mi->fp[i++] = (int *)Osiris_CancelTimerID; - mi->fp[i++] = (int *)osipf_GetGroundPos; - mi->fp[i++] = (int *)osipf_EnableShip; - mi->fp[i++] = (int *)osipf_IsShipEnabled; - mi->fp[i++] = (int *)osipf_PathGetInformation; - mi->fp[i++] = (int *)Cinematic_StartCannedScript; - mi->fp[i++] = (int *)osipf_FindMatcenName; - mi->fp[i++] = (int *)osipf_FindPathName; - mi->fp[i++] = (int *)osipf_FindLevelGoalName; - mi->fp[i++] = (int *)osipf_ObjectFindType; - mi->fp[i++] = (int *)osipf_LGoalValue; - mi->fp[i++] = (int *)osipf_ObjMakeListOfType; - mi->fp[i++] = (int *)osipf_ObjKill; - // mi->fp[i++] = (int *)osipf_AIAreRoomsReachable; - mi->fp[i++] = (int *)osipf_AIIsDestReachable; - mi->fp[i++] = (int *)osipf_AIIsObjReachable; - mi->fp[i++] = (int *)osipf_GameGetDiffLevel; - mi->fp[i++] = (int *)osipf_GetLanguageSetting; - mi->fp[i++] = (int *)osipf_PathValue; - - // fill in the remaining with NULL - for (; i < MAX_MODULEFUNCS; i++) { - mi->fp[i] = NULL; - } + // Keep it in sync with scripts/osiris_import.h + mi->fp[0] = (int *)MonoPrintf; + mi->fp[1] = (int *)msafe_CallFunction; + mi->fp[2] = (int *)msafe_GetValue; + mi->fp[3] = (int *)osipf_CallObjectEvent; + mi->fp[4] = (int *)osipf_CallTriggerEvent; + mi->fp[5] = (int *)osipf_SoundTouch; + mi->fp[6] = (int *)osipf_ObjectFindID; + mi->fp[7] = (int *)osipf_WeaponFindID; + mi->fp[8] = (int *)osipf_ObjectGetTimeLived; + mi->fp[9] = (int *)osipf_GetGunPos; + mi->fp[10] = (int *)osipf_RoomValue; + mi->fp[11] = (int *)osipf_IsRoomValid; + mi->fp[12] = (int *)osipf_GetAttachParent; + mi->fp[13] = (int *)osipf_GetNumAttachSlots; + mi->fp[14] = (int *)osipf_GetAttachChildHandle; + mi->fp[15] = (int *)osipf_AttachObjectAP; + mi->fp[16] = (int *)osipf_AttachObjectRad; + mi->fp[17] = (int *)osipf_UnattachFromParent; + mi->fp[18] = (int *)osipf_UnattachChild; + mi->fp[19] = (int *)osipf_UnattachChildren; + mi->fp[20] = (int *)osipf_RayCast; + mi->fp[21] = (int *)osipf_AIGetPathID; + mi->fp[22] = (int *)osipf_AIGoalFollowPathSimple; + mi->fp[23] = (int *)osipf_AIPowerSwitch; + mi->fp[24] = (int *)osipf_AITurnTowardsVectors; + mi->fp[25] = (int *)osipf_AISetType; + mi->fp[26] = (int *)osipf_AIFindHidePos; + mi->fp[27] = (int *)osipf_AIGoalAddEnabler; + mi->fp[28] = (int *)osipf_AIGoalAdd; + mi->fp[29] = (int *)osipf_AIGoalClear; + mi->fp[30] = (int *)osipf_AIValue; + mi->fp[31] = (int *)osipf_AIFindObjOfType; + mi->fp[32] = (int *)osipf_AIGetRoomPathPoint; + mi->fp[33] = (int *)osipf_AIFindEnergyCenter; + mi->fp[34] = (int *)osipf_AIGetDistToObj; + mi->fp[35] = (int *)osipf_AISetGoalFlags; + mi->fp[36] = (int *)osipf_AISetGoalCircleDist; + mi->fp[37] = (int *)osipf_CFReadBytes; + mi->fp[38] = (int *)osipf_CFReadInt; + mi->fp[39] = (int *)osipf_CFReadShort; + mi->fp[40] = (int *)osipf_CFReadByte; + mi->fp[41] = (int *)osipf_CFReadFloat; + mi->fp[42] = (int *)osipf_CFReadDouble; + mi->fp[43] = (int *)osipf_CFReadString; + mi->fp[44] = (int *)osipf_CFWriteBytes; + mi->fp[45] = (int *)osipf_CFWriteString; + mi->fp[46] = (int *)osipf_CFWriteInt; + mi->fp[47] = (int *)osipf_CFWriteShort; + mi->fp[48] = (int *)osipf_CFWriteByte; + mi->fp[49] = (int *)osipf_CFWriteFloat; + mi->fp[50] = (int *)osipf_CFWriteDouble; + mi->fp[51] = (int *)Osiris_AllocateMemory; + mi->fp[52] = (int *)Osiris_FreeMemory; + mi->fp[53] = (int *)Osiris_CancelTimer; + mi->fp[54] = (int *)Osiris_CreateTimer; + mi->fp[55] = (int *)msafe_DoPowerup; + mi->fp[56] = (int *)osipf_ObjCreate; + mi->fp[57] = (int *)osipf_GameTime; + mi->fp[58] = (int *)osipf_FrameTime; + mi->fp[59] = (int *)osipf_ObjWBValue; + mi->fp[60] = (int *)Osiris_TimerExists; + mi->fp[61] = (int *)osipf_ObjectValue; + mi->fp[62] = (int *)osipf_MatcenValue; + mi->fp[63] = (int *)osipf_MatcenReset; + mi->fp[64] = (int *)osipf_MatcenCopy; + mi->fp[65] = (int *)osipf_MatcenCreate; + mi->fp[66] = (int *)osipf_MatcenFindId; + mi->fp[67] = (int *)osipf_MissionFlagSet; + mi->fp[68] = (int *)osipf_MissionFlagGet; + mi->fp[69] = (int *)osipf_PlayerValue; + mi->fp[70] = (int *)osipf_ObjectCustomAnim; + mi->fp[71] = (int *)osipf_PlayerAddHudMessage; + mi->fp[72] = (int *)osipf_ObjGhost; + mi->fp[73] = (int *)osipf_ObjBurning; + mi->fp[74] = (int *)osipf_ObjIsEffect; + mi->fp[75] = (int *)osipf_CFopen; + mi->fp[76] = (int *)osipf_CFclose; + mi->fp[77] = (int *)osipf_CFtell; + mi->fp[78] = (int *)osipf_CFeof; + mi->fp[79] = (int *)osipf_SoundStop; + mi->fp[80] = (int *)osipf_SoundPlay2d; + mi->fp[81] = (int *)osipf_SoundPlay3d; + mi->fp[82] = (int *)osipf_SoundFindId; + mi->fp[83] = (int *)osipf_AIIsObjFriend; + mi->fp[84] = (int *)osipf_AIIsObjEnemy; + mi->fp[85] = (int *)osipf_AIGoalValue; + mi->fp[86] = (int *)osipf_AIGetNearbyObjs; + mi->fp[87] = (int *)osipf_AIGetCurGoalIndex; + mi->fp[88] = (int *)Osiris_OMMS_Malloc; + mi->fp[89] = (int *)Osiris_OMMS_Attach; + mi->fp[90] = (int *)Osiris_OMMS_Detach; + mi->fp[91] = (int *)Osiris_OMMS_Free; + mi->fp[92] = (int *)Osiris_OMMS_Find; + mi->fp[93] = (int *)Osiris_OMMS_GetInfo; + mi->fp[94] = (int *)Cinematic_Start; + mi->fp[95] = (int *)Cinematic_Stop; + mi->fp[96] = (int *)osipf_FindSoundName; + mi->fp[97] = (int *)osipf_FindRoomName; + mi->fp[98] = (int *)osipf_FindTriggerName; + mi->fp[99] = (int *)osipf_FindObjectName; + mi->fp[100] = (int *)osipf_GetTriggerRoom; + mi->fp[101] = (int *)osipf_GetTriggerFace; + mi->fp[102] = (int *)osipf_FindDoorName; + mi->fp[103] = (int *)osipf_FindTextureName; + mi->fp[104] = (int *)osipf_CreateRandomSparks; + mi->fp[105] = (int *)Osiris_CancelTimerID; + mi->fp[106] = (int *)osipf_GetGroundPos; + mi->fp[107] = (int *)osipf_EnableShip; + mi->fp[108] = (int *)osipf_IsShipEnabled; + mi->fp[109] = (int *)osipf_PathGetInformation; + mi->fp[110] = (int *)Cinematic_StartCannedScript; + mi->fp[111] = (int *)osipf_FindMatcenName; + mi->fp[112] = (int *)osipf_FindPathName; + mi->fp[113] = (int *)osipf_FindLevelGoalName; + mi->fp[114] = (int *)osipf_ObjectFindType; + mi->fp[115] = (int *)osipf_LGoalValue; + mi->fp[116] = (int *)osipf_ObjMakeListOfType; + mi->fp[117] = (int *)osipf_ObjKill; + mi->fp[118] = (int *)osipf_AIIsDestReachable; + mi->fp[119] = (int *)osipf_AIIsObjReachable; + mi->fp[120] = (int *)osipf_GameGetDiffLevel; + mi->fp[121] = (int *)osipf_GetLanguageSetting; + mi->fp[122] = (int *)osipf_PathValue; + mi->fp[123] = (int *)CreateMessageMap; + mi->fp[124] = (int *)DestroyMessageMap; + mi->fp[125] = (int *)GetMessageMap; } diff --git a/Descent3/gamesequence.cpp b/Descent3/gamesequence.cpp index d94a799af..20cdfc670 100644 --- a/Descent3/gamesequence.cpp +++ b/Descent3/gamesequence.cpp @@ -1025,66 +1025,64 @@ #include #endif -#include "gamesequence.h" - -#include "game.h" -#include "gameloop.h" -#include "descent.h" -#include "player.h" -#include "Mission.h" +#include "aiambient.h" +#include "AIMain.h" +#include "ambient.h" +#include "args.h" #include "BOA.h" +#include "bsp.h" +#include "buddymenu.h" +#include "cockpit.h" +#include "d3music.h" +#include "debuggraph.h" +#include "dedicated_server.h" +#include "demofile.h" +#include "descent.h" +#include "doorway.h" +#include "fireball.h" +#include "game.h" +#include "game2dll.h" +#include "gamecinematics.h" #include "gameevent.h" -#include "AIMain.h" -#include "soar_helpers.h" -#include "terrain.h" -#include "hlsoundlib.h" -#include "SmallViews.h" -#include "polymodel.h" +#include "gameloop.h" +#include "gamepath.h" +#include "gamesave.h" +#include "gamesequence.h" #include "gametexture.h" +#include "help.h" +#include "hlsoundlib.h" #include "hud.h" +#include "levelgoal.h" +#include "lightmap.h" +#include "lightmap_info.h" +#include "localization.h" +#include "marker.h" +#include "matcen.h" +#include "mem.h" #include "menu.h" +#include "Mission.h" +#include "multi_dll_mgr.h" +#include "multi_ui.h" #include "newui.h" -#include "cockpit.h" -#include "help.h" -#include "buddymenu.h" -#include "mem.h" -#include "soundload.h" +#include "ObjScript.h" +#include "osiris_dll.h" +#include "pilot.h" +#include "player.h" +#include "polymodel.h" +#include "render.h" #include "robot.h" +#include "scorch.h" #include "screens.h" -#include "game2dll.h" #include "ship.h" -#include "TelCom.h" -#include "scorch.h" -#include "render.h" -#include "stringtable.h" -#include "ddio_common.h" -#include "gamesave.h" +#include "SmallViews.h" +#include "soar_helpers.h" +#include "soundload.h" #include "sounds.h" -#include "ambient.h" -#include "vclip.h" -#include "pilot.h" -#include "doorway.h" -#include "matcen.h" -#include "dedicated_server.h" -#include "levelgoal.h" -#include "log.h" -#include "demofile.h" -#include "lightmap_info.h" -#include "lightmap.h" -#include "fireball.h" -#include "d3music.h" +#include "stringtable.h" +#include "TelCom.h" #include "TelComAutoMap.h" -#include "aiambient.h" -#include "ObjScript.h" -#include "marker.h" -#include "gamecinematics.h" -#include "osiris_dll.h" -#include "debuggraph.h" -#include "multi_dll_mgr.h" -#include "multi_ui.h" -#include "gamepath.h" -#include "bsp.h" -#include "args.h" +#include "terrain.h" +#include "vclip.h" // Variables tGameState Game_state = GAMESTATE_IDLE; // current game state. @@ -1456,10 +1454,6 @@ void DeleteAmbientObjects() { } } -void Localization_SetLanguage(int type); -int Localization_GetLanguage(void); -void LoadLevelText(const char *level_filename); - // Starts the level, which has already been loaded void StartLevel() { extern void RestoreCameraRearviews(); // gameloop.cpp @@ -1568,7 +1562,7 @@ void StartLevel() { ResetGameMessages(); ResetReticle(); ResetSmallViews(); // ResetSmallViews() must come before InitCameraViews() - InitCameraViews(0); // ResetSmallViews() must come before InitCameraViews() + InitCameraViews(false); // ResetSmallViews() must come before InitCameraViews() RestoreCameraRearviews(); SetHUDMode(GetHUDMode()); // what does this do? diff --git a/Descent3/init.cpp b/Descent3/init.cpp index d5f6d40e5..3929c72d3 100644 --- a/Descent3/init.cpp +++ b/Descent3/init.cpp @@ -1545,13 +1545,12 @@ void InitIOSystems(bool editor) { bool MercInstalled() { return merc_hid > 0; } -extern int Num_languages; void InitStringTable() { int language = LANGUAGE_ENGLISH; Database->read("LanguageType", &language, sizeof(language)); - if (language < 0 || language >= Num_languages) { + if (language < 0 || language >= LANGUAGE_TOTAL) { Int3(); language = LANGUAGE_ENGLISH; } diff --git a/Descent3/localization.cpp b/Descent3/localization.cpp index 1e89a2b53..47fddc6b8 100644 --- a/Descent3/localization.cpp +++ b/Descent3/localization.cpp @@ -84,18 +84,20 @@ * $NoKeywords: $ */ -#include +#include #include #include -#include +#include +#include +#include +#include #include "cfile.h" -#include "ddio.h" -#include "descent.h" -#include "game.h" #include "localization.h" +#include "localization_external.h" #include "log.h" -#include "mem.h" +#include "pserror.h" +#include "pstring.h" struct tLangTag { const char *tag; @@ -108,61 +110,56 @@ tLangTag Language_tags[] = { {"!S!", -1}, // Spanish {"!I!", -1}, // Italian {"!F!", -1}, // French + {"!P!", -1}, // Polish }; -int Num_languages = sizeof(Language_tags) / sizeof(tLangTag); // The following data, in the anonymous namespace, are static to this file namespace { -int Localization_language = -1; +// Assume that we on English locale +int Localization_language = LANGUAGE_ENGLISH; -int String_table_size = 0; -char **String_table = NULL; +std::vector String_table; // list of the string table files, they will be loaded in the order they are listed -const char *String_table_list[] = {"D3.STR", NULL}; +const std::vector String_table_list = {"D3.STR"}; + +const char *Error_string = "!!ERROR MISSING STRING!!"; +const char *Empty_string = "\0"; -const char *_Error_string = "!!ERROR MISSING STRING!!"; -const char *_Empty_string = "\0"; +const char *NO_MESSAGE_STRING = "*Message Not Found*"; +const char *INV_MSGNAME_STRING = "*Message Name Invalid*"; } // namespace void Localization_SetLanguage(int type) { - ASSERT(type >= 0 && type < Num_languages); + ASSERT(type >= 0 && type < LANGUAGE_TOTAL); Localization_language = type; } -int Localization_GetLanguage(void) { return Localization_language; } +int Localization_GetLanguage() { return Localization_language; } #define COMMENT_TAG "!/!" // This line is to be ignored -#define STAG_CONTINUE -1 // this line is just a continuation of the last line -#define STAG_EMPTY -2 // empty line -#define STAG_COMMENT -3 // comment line +#define STAG_CONTINUE (-1) // this line is just a continuation of the last line +#define STAG_EMPTY (-2) // empty line +#define STAG_COMMENT (-3) // comment line // 0 -> Num_languages means it's the start of a string that begins with that language #define MAX_LINE_LENGTH 1024 -#define MAX_STRING_LENGTH 8 * MAX_LINE_LENGTH +#define MAX_STRING_LENGTH (8 * MAX_LINE_LENGTH) #define MAX_TAG_LENGTH 3 -int GetTotalStringCount(void); -int LoadStringFile(const char *filename, int starting_offset); -int8_t _parse_line_information(char *line); -char *_parse_string_tag(char *buffer); -char *_parse_escape_chars(char *buffer); +#define WHITESPACE_CHARS " \t\r\n" + +int GetTotalStringCount(); +int LoadStringFile(const std::filesystem::path &filename, int starting_offset); +int parse_line_information(char *line); +char *parse_string_tag(char *buffer); +char *parse_escape_chars(char *buffer); // Call this to load up the string tables into memory // Returns the number of strings loaded, if this is 0, then the program MUST not continue -int LoadStringTables(void) { - static bool called = false; - int old_language; - - if (called) { - // Only call this guy once - Int3(); - return 0; - } - called = true; - - old_language = Localization_language; +int LoadStringTables() { + int old_language = Localization_language; int string_count = GetTotalStringCount(); if (string_count == 0) { @@ -177,23 +174,12 @@ int LoadStringTables(void) { } } - String_table_size = 0; - - // malloc our array of char * - String_table = mem_rmalloc(string_count); - if (!String_table) { - Localization_language = old_language; - return 0; - } - - for (int tcount = 0; tcount < string_count; tcount++) - String_table[tcount] = NULL; + String_table = std::vector(string_count); int runcount = 0; int temp; - int index = 0; - while (String_table_list[index]) { - temp = LoadStringFile(String_table_list[index], runcount); + for (auto const &item : String_table_list) { + temp = LoadStringFile(item, runcount); if (temp == 0) { Localization_language = old_language; return 0; @@ -203,7 +189,6 @@ int LoadStringTables(void) { return 0; } runcount += temp; - index++; } if (runcount == 0) { @@ -211,77 +196,46 @@ int LoadStringTables(void) { return 0; } - String_table_size = runcount; Localization_language = old_language; atexit(FreeStringTables); - return String_table_size; + return runcount; } // Deallocates all the memory used for the string tables -void FreeStringTables(void) { - DestroyStringTable(String_table, String_table_size); - String_table = NULL; +void FreeStringTables() { + String_table.clear(); } -const char *GetStringFromTable(int index) { - if ((index < 0) || (index >= String_table_size)) - return _Error_string; +const char *GetStringFromTable(uint32_t index) { + if (index >= String_table.size()) + return Error_string; - if (!String_table[index]) - return _Empty_string; + if (String_table[index].empty()) + return Empty_string; - return String_table[index]; + return String_table[index].c_str(); } -void FixFilenameCase(const char *filename, char *newfile) { - char path[_MAX_PATH], file[_MAX_FNAME], ext[_MAX_EXT]; - ddio_SplitPath(filename, path, file, ext); - - char *p; - - p = file; - while (*p) { - *p = tolower(*p); - p++; - }; - p = ext; - while (*p) { - *p = tolower(*p); - p++; - }; - - strcat(file, ext); - - if (strlen(path) > 0) - ddio_MakePath(newfile, path, file, NULL); - else - strcpy(newfile, file); +/** + * Lowercase filename part in path + * @param path + * @return path with lowercased filename + */ +std::filesystem::path FixFilenameCase(const std::filesystem::path &path) { + std::filesystem::path parent = path.parent_path(); + std::string fname = path.filename().string(); + std::transform(fname.begin(), fname.end(), fname.begin(), [](unsigned char c){ return std::tolower(c); }); + return (parent / fname); } -// Given a filename, pointer to a char * array and a pointer to an int, -// it will load the string table and fill in the information -// returns true on success -bool CreateStringTable(const char *filename, char ***table, int *size) { - ASSERT(filename); +bool CreateStringTable(const std::filesystem::path &filename, std::vector &table) { + ASSERT(!filename.empty()); ASSERT(Localization_language != -1); - if (!filename) { - if (table) - *table = NULL; - if (size) - *size = 0; - return false; - } - CFILE *file; - char fname[_MAX_PATH]; - FixFilenameCase(filename, fname); - file = cfopen(fname, "rt"); + std::filesystem::path fname = FixFilenameCase(filename); + CFILE *file = cfopen(fname, "rt"); if (!file) { - if (table) - *table = NULL; - if (size) - *size = 0; return false; } @@ -297,7 +251,7 @@ bool CreateStringTable(const char *filename, char ***table, int *size) { while (!cfeof(file)) { cf_ReadString(tempbuffer, MAX_LINE_LENGTH + 1, file); - if (_parse_line_information(tempbuffer) == Localization_language) + if (parse_line_information(tempbuffer) == Localization_language) scount++; } cfclose(file); @@ -315,36 +269,14 @@ bool CreateStringTable(const char *filename, char ***table, int *size) { // no strings found Localization_language = old_language; LOG_WARNING << "Localization: Warning, 0 strings found in " << filename; - *table = NULL; - *size = 0; return true; } - *size = scount; - char **strtable; - - // malloc our array of char * - *table = mem_rmalloc(scount); - if (!*table) { - if (table) - *table = NULL; - if (size) - *size = 0; - Localization_language = old_language; - return false; - } - - strtable = *table; - for (int tcount = 0; tcount < scount; tcount++) - strtable[tcount] = NULL; + table = std::vector(scount); // now load the strings file = cfopen(fname, "rt"); if (!file) { - if (table) - *table = NULL; - if (size) - *size = 0; Localization_language = old_language; return false; } @@ -352,7 +284,7 @@ bool CreateStringTable(const char *filename, char ***table, int *size) { bool reading_string = false; scount = 0; - GrowString string; + std::string string; int line_info; @@ -361,13 +293,13 @@ bool CreateStringTable(const char *filename, char ***table, int *size) { if (scount >= 198) scount = scount; - line_info = _parse_line_information(tempbuffer); + line_info = parse_line_information(tempbuffer); switch (line_info) { case STAG_CONTINUE: if (reading_string) { // we need to add on to the working buffer - string += _parse_escape_chars(tempbuffer); + string += parse_escape_chars(tempbuffer); } break; case STAG_EMPTY: @@ -377,19 +309,19 @@ bool CreateStringTable(const char *filename, char ***table, int *size) { // ignore this line if (reading_string) { // ok we're done with the string, finish it and put it in the string table - string.GetString(&strtable[scount]); + table[scount] = string; scount++; - string.Destroy(); + string.clear(); } reading_string = false; break; default: { - if (line_info >= 0 && line_info < Num_languages) { + if (line_info >= 0 && line_info < LANGUAGE_TOTAL) { if (reading_string) { // ok we're done with the string, finish it and put it in the string table - string.GetString(&strtable[scount]); + table[scount] = string; scount++; - string.Destroy(); + string.clear(); reading_string = false; } @@ -397,8 +329,8 @@ bool CreateStringTable(const char *filename, char ***table, int *size) { if (line_info == Localization_language) { reading_string = true; // start filling in the buffer - string.Destroy(); - string = _parse_escape_chars(_parse_string_tag(tempbuffer)); + string.clear(); + string = parse_escape_chars(parse_string_tag(tempbuffer)); } } else { @@ -411,73 +343,55 @@ bool CreateStringTable(const char *filename, char ***table, int *size) { if (reading_string) { // we're at the end of the file and we're reading, so but it in the string table - string.GetString(&strtable[scount]); + table[scount] = string; scount++; - string.Destroy(); + string.clear(); reading_string = false; } cfclose(file); - LOG_INFO.printf("String Table (%s) loaded with %d strings", filename, *size); + LOG_INFO.printf("String Table (%s) loaded with %d strings", filename.u8string().c_str(), scount); Localization_language = old_language; - return (scount == (*size)); + return true; } -// Given a string table and its count of strings, it will free up its memory -void DestroyStringTable(char **table, int size) { - if ((size > 0) && (table)) { - for (int i = 0; i < size; i++) { - if (table[i]) - mem_free(table[i]); - } - } - - if (table) - mem_free(table); -} +void DestroyStringTable(std::vector &table) { + table.clear(); +}; // returns the total number of strings in all the string table files // returns 0 on error -int GetTotalStringCount(void) { +int GetTotalStringCount() { int scount = 0; - int findex = 0; - CFILE *file; char tempbuffer[MAX_LINE_LENGTH + 1]; ASSERT(Localization_language != -1); - while (String_table_list[findex]) { + for (auto const &item : String_table_list) { // open the file up - char fname[_MAX_PATH]; - FixFilenameCase(String_table_list[findex], fname); - file = cfopen(fname, "rt"); + CFILE *file = cfopen(FixFilenameCase(item), "rt"); if (!file) return 0; while (!cfeof(file)) { cf_ReadString(tempbuffer, MAX_LINE_LENGTH + 1, file); - if (_parse_line_information(tempbuffer) == Localization_language) + if (parse_line_information(tempbuffer) == Localization_language) scount++; } cfclose(file); - findex++; } return scount; } // Loads a string table file, returns number of strings read if everything went ok,else 0 -int LoadStringFile(const char *filename, int starting_offset) { - ASSERT(filename); +int LoadStringFile(const std::filesystem::path &filename, int starting_offset) { ASSERT(Localization_language != -1); - if (!filename) + if (filename.empty()) return 0; - CFILE *file; - char fname[_MAX_PATH]; - FixFilenameCase(filename, fname); - file = cfopen(fname, "rt"); + CFILE *file = cfopen(FixFilenameCase(filename), "rt"); if (!file) return 0; @@ -486,7 +400,7 @@ int LoadStringFile(const char *filename, int starting_offset) { bool reading_string = false; - GrowString string; + std::string string; int line_info; while (!cfeof(file)) { @@ -494,13 +408,13 @@ int LoadStringFile(const char *filename, int starting_offset) { if (scount >= 198) scount = scount; - line_info = _parse_line_information(buffer); + line_info = parse_line_information(buffer); switch (line_info) { case STAG_CONTINUE: if (reading_string) { // we need to add on to the working buffer - string += _parse_escape_chars(buffer); + string += parse_escape_chars(buffer); } break; case STAG_EMPTY: @@ -510,19 +424,19 @@ int LoadStringFile(const char *filename, int starting_offset) { // ignore this line if (reading_string) { // ok we're done with the string, finish it and put it in the string table - string.GetString(&String_table[scount + starting_offset]); + String_table[scount + starting_offset] = string; scount++; - string.Destroy(); + string.clear(); } reading_string = false; break; default: { - if (line_info >= 0 && line_info < Num_languages) { + if (line_info >= 0 && line_info < LANGUAGE_TOTAL) { if (reading_string) { // ok we're done with the string, finish it and put it in the string table - string.GetString(&String_table[scount + starting_offset]); + String_table[scount + starting_offset] = string; scount++; - string.Destroy(); + string.clear(); reading_string = false; } @@ -530,8 +444,8 @@ int LoadStringFile(const char *filename, int starting_offset) { if (line_info == Localization_language) { reading_string = true; // start filling in the buffer - string.Destroy(); - string = _parse_escape_chars(_parse_string_tag(buffer)); + string.clear(); + string = parse_escape_chars(parse_string_tag(buffer)); } } else { @@ -544,9 +458,9 @@ int LoadStringFile(const char *filename, int starting_offset) { if (reading_string) { // we're at the end of the file and we're reading, so but it in the string table - string.GetString(&String_table[scount + starting_offset]); + String_table[scount + starting_offset] = string; scount++; - string.Destroy(); + string.clear(); reading_string = false; } @@ -555,8 +469,8 @@ int LoadStringFile(const char *filename, int starting_offset) { } // returns STAG_* information about the line -int8_t _parse_line_information(char *line) { - for (int i = 0; i < Num_languages; i++) { +int parse_line_information(char *line) { + for (int i = 0; i < LANGUAGE_TOTAL; i++) { if (Language_tags[i].length == -1) Language_tags[i].length = strlen(Language_tags[i].tag); @@ -572,8 +486,8 @@ int8_t _parse_line_information(char *line) { } // parses a string_tag out -char *_parse_string_tag(char *buffer) { - int8_t i = _parse_line_information(buffer); +char *parse_string_tag(char *buffer) { + int i = parse_line_information(buffer); switch (i) { case STAG_CONTINUE: @@ -584,7 +498,7 @@ char *_parse_string_tag(char *buffer) { return buffer + (strlen(COMMENT_TAG)); break; default: - if (i >= 0 && i < Num_languages) { + if (i >= 0 && i < LANGUAGE_TOTAL) { // we have a specific language... return buffer + (Language_tags[i].length); } @@ -595,7 +509,7 @@ char *_parse_string_tag(char *buffer) { } // parses out escape chars...like /t,/n -char *_parse_escape_chars(char *buffer) { +char *parse_escape_chars(char *buffer) { char tempbuffer[MAX_STRING_LENGTH]; int t_index, b_index; @@ -652,125 +566,67 @@ char *_parse_escape_chars(char *buffer) { return buffer; } -GrowString::GrowString() { - root.string_data = NULL; - root.next = NULL; - curr = &root; -} -GrowString::~GrowString() { Destroy(); } - -void GrowString::operator+=(char *str) { - if (!str) - return; - if (root.string_data) { - tbufferinfo *node; - node = mem_rmalloc(); - if (!node) - return; - node->string_data = mem_rmalloc(strlen(str) + 2); - if (!node->string_data) { - mem_free(node); - return; - } - sprintf(node->string_data, "\n%s", str); - curr->next = node; - node->next = NULL; - curr = node; - } else { - root.string_data = mem_rmalloc(strlen(str) + 1); - if (!root.string_data) - return; - strcpy(root.string_data, str); - root.next = NULL; - } -} +// Message handling -void GrowString::Destroy(void) { - if (root.string_data) - mem_free(root.string_data); - root.string_data = NULL; - - tbufferinfo *c, *next; - c = next = root.next; - while (c) { - next = c->next; - if (c->string_data) - mem_free(c->string_data); - mem_free(c); - c = next; - } - root.next = NULL; - root.string_data = NULL; - curr = &root; -} +bool CreateMessageMap(const std::filesystem::path &filename, std::map &map) { + char filebuffer[MAX_LINE_LENGTH + 1]; + char line[MAX_LINE_LENGTH + 1]; + char *msg_start; -GrowString GrowString::operator+(char *str) { - *this += str; - return *this; -} + // Try to open the file for loading + CFILE *infile = cfopen(filename, "rt"); + if (!infile) + return false; -GrowString GrowString::operator+(GrowString &gs) { - char *str = NULL; - gs.GetString(&str); - *this += str; - if (str) - mem_free(str); - return *this; -} + // Clear the message list + map.clear(); -void GrowString::operator+=(GrowString &gs) { - char *str = NULL; - gs.GetString(&str); - *this += str; - if (str) - mem_free(str); -} + // Read in and parse each line of the file + while (!cfeof(infile)) { -void GrowString::operator=(char *str) { - Destroy(); - *this += str; -} + // Clear the buffer + strcpy(filebuffer, ""); -void GrowString::operator=(GrowString &gs) { - char *str = NULL; - gs.GetString(&str); - *this = str; - if (str) - mem_free(str); -} + // Read in a line from the file + cf_ReadString(filebuffer, MAX_LINE_LENGTH, infile); -void GrowString::GetString(char **str) { - *str = NULL; - int size = Length(); - if (size == -1) - return; + // Remove whitespace padding at start and end of line + CleanupStr(line, filebuffer, MAX_LINE_LENGTH); - tbufferinfo *next; - next = root.next; + // If line is a comment, or empty, discard it + if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) + continue; - *str = (char *)mem_malloc(size + 1); + // Find the start of message, and mark it + msg_start = strchr(line, '='); + if (msg_start == nullptr) + continue; + msg_start[0] = '\0'; + msg_start++; - strcpy(*str, root.string_data); - next = root.next; - while (next) { - if (next->string_data) { - strcat(*str, next->string_data); - } - next = next->next; + // Add the message to the list + map.insert_or_assign(line, msg_start); } + cfclose(infile); + + return true; +} + +void DestroyMessageMap(std::map &map) { + map.clear(); } -int GrowString::Length(void) { - if (!root.string_data) - return -1; - - tbufferinfo *next; - next = root.next; - int size = strlen(root.string_data); - while (next) { - if (next->string_data) - size += strlen(next->string_data); - next = next->next; +const char *GetMessageMap(const std::string &name, std::map &map) { + // Make sure given name is valid + if (name.empty()) { + return INV_MSGNAME_STRING; } - return size; + + // We have key in map + if (map.count(name) > 0) { + return map[name].c_str(); + } + + // Couldn't find it + return NO_MESSAGE_STRING; } diff --git a/Descent3/localization.h b/Descent3/localization.h index 442ae9123..b4bafc73f 100644 --- a/Descent3/localization.h +++ b/Descent3/localization.h @@ -1,5 +1,5 @@ /* -* Descent 3 +* Descent 3 * Copyright (C) 2024 Parallax Software * * This program is free software: you can redistribute it and/or modify @@ -38,59 +38,65 @@ * $NoKeywords: $ */ -#ifndef __LOCALIZATION_H__ -#define __LOCALIZATION_H__ +#ifndef LOCALIZATION_H +#define LOCALIZATION_H + +#include +#include +#include + +#include "localization_external.h" -#define LANGUAGE_ENGLISH 0 -#define LANGUAGE_GERMAN 1 -#define LANGUAGE_SPANISH 2 -#define LANGUAGE_ITALIAN 3 -#define LANGUAGE_FRENCH 4 void Localization_SetLanguage(int type); -int Localization_GetLanguage(void); +int Localization_GetLanguage(); // Call this to load up the string tables into memory // Returns the number of strings loaded, if this is 0, then the program MUST not continue -int LoadStringTables(void); +int LoadStringTables(); // Deallocates all the memory used for the string tables -void FreeStringTables(void); +void FreeStringTables(); // Returns a pointer to the string at the index location from the string table // if it is a bad index given, then the pointer to the error string "ERROR MISSING STRING" is given -const char *GetStringFromTable(int index); - -// Given a filename, pointer to a char * array and a pointer to an int, -// it will load the string table and fill in the information -// returns true on success -bool CreateStringTable(const char *filename, char ***table, int *size); -// Given a string table and its count of strings, it will free up its memory -void DestroyStringTable(char **table, int size); - -// GrowString class -// handles a string of increasing size (using +,=,+=) -struct tbufferinfo { - char *string_data; - tbufferinfo *next; -}; - -class GrowString { -public: - GrowString(); - ~GrowString(); - void Destroy(void); - void operator+=(char *str); - GrowString operator+(char *str); - GrowString operator+(GrowString &gs); - void operator+=(GrowString &gs); - void operator=(char *str); - void operator=(GrowString &gs); - void GetString(char **str); - int Length(void); - -private: - tbufferinfo root; - tbufferinfo *curr; -}; +const char *GetStringFromTable(uint32_t index); + +/** + * Creates table of strings from given filename + * @param filename + * @param table + * @return true on success + */ +bool CreateStringTable(const std::filesystem::path &filename, std::vector &table); + +/** + * Clears table from loaded strings + * @param table + */ +void DestroyStringTable(std::vector &table); + +// Message file handling (used in scripts) + +/** + * Creates map of strings from given filename + * @param filename + * @param map + * @return true on success + */ +bool CreateMessageMap(const std::filesystem::path &filename, std::map &map); + +/** + * Clears map from loaded strings + * @param map + */ +void DestroyMessageMap(std::map &map); + +/** + * Gets message by name from corresponding map + * @param name + * @param map + * @return return message by name, NO_MESSAGE_STRING if there no such name + */ +const char *GetMessageMap(const std::string &name, std::map &map); #endif diff --git a/Descent3/localization_external.h b/Descent3/localization_external.h new file mode 100644 index 000000000..dfd70ab8f --- /dev/null +++ b/Descent3/localization_external.h @@ -0,0 +1,47 @@ +/* + * Descent 3 + * Copyright (C) 2024 Descent Developers + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef LOCALIZATION_EXTERNAL_H +#define LOCALIZATION_EXTERNAL_H + +// ======================================================================= +// Language defines +// ======================================================================= + +enum LANGS { + LANGUAGE_ENGLISH = 0, + LANGUAGE_GERMAN, + LANGUAGE_SPANISH, + LANGUAGE_ITALIAN, + LANGUAGE_FRENCH, + LANGUAGE_POLISH, + + LANGUAGE_TOTAL, +}; + +// Lang suffixes for message files +const std::vector lang_suffixes = { + "", // No suffix for English + "_GER", // German + "_SPN", // Spanish + "_ITN", // Italian + "_FRN", // French + "_POL", // Polish +}; + +#endif // LOCALIZATION_EXTERNAL_H diff --git a/Descent3/stringtable.h b/Descent3/stringtable.h index d5ea10e00..b86b99ca3 100644 --- a/Descent3/stringtable.h +++ b/Descent3/stringtable.h @@ -26,7 +26,7 @@ // Returns a pointer to the string at the index location from the string table // if it is a bad index given, then the pointer to the error string "ERROR MISSING STRING" is given -const char *GetStringFromTable(int index); +const char *GetStringFromTable(uint32_t index); #define TXT_NEW TXT(0) //"New" #define TXT_DELETE TXT(1) //"Delete" diff --git a/Descent3/tests/CMakeLists.txt b/Descent3/tests/CMakeLists.txt index 20bb30dec..3f47905fc 100644 --- a/Descent3/tests/CMakeLists.txt +++ b/Descent3/tests/CMakeLists.txt @@ -23,3 +23,22 @@ target_link_libraries( GTest::gtest_main ) gtest_discover_tests(gamespyutils_tests) + +add_executable( + localization_tests + localization_tests.cpp + ../localization.cpp +) + +target_link_libraries( + localization_tests + GTest::gtest_main + cfile + ddio + logger + misc +) + +gtest_discover_tests(localization_tests + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/Descent3/tests +) diff --git a/Descent3/tests/localization_tests.cpp b/Descent3/tests/localization_tests.cpp new file mode 100644 index 000000000..fe87f7482 --- /dev/null +++ b/Descent3/tests/localization_tests.cpp @@ -0,0 +1,60 @@ +/* +* Descent 3 +* Copyright (C) 2024 Descent Developers +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + +#include +#include +#include + +#include "cfile.h" +#include "localization.h" + +std::vector messages = { + "English message", + "Deutsche Botschaft", + "Mensaje en español", + "Messaggio italiano", + "Message en français", +}; + +std::string error_string = "!!ERROR MISSING STRING!!"; + +TEST(D3, LocalizationTests) { + cf_SetSearchPath("test_data"); + + for (int i = 0; i < 5; i++) { + Localization_SetLanguage(i); + + int count = LoadStringTables(); + EXPECT_EQ(count, 1); + + const char *message; + message = GetStringFromTable(0); + EXPECT_STREQ(message, messages[i].c_str()); + message = GetStringFromTable(1); + EXPECT_STREQ(message, error_string.c_str()); + FreeStringTables(); + } + + for (int i = 0; i < 5; i++) { + Localization_SetLanguage(i); + std::vector loc_msgs; + int count = CreateStringTable("d3.str", loc_msgs); + EXPECT_EQ(count, 1); + EXPECT_STREQ(loc_msgs[0].c_str(), messages[i].c_str()); + } +} diff --git a/Descent3/tests/porting-tests.cpp b/Descent3/tests/porting-tests.cpp index cf62bb886..a256458fb 100644 --- a/Descent3/tests/porting-tests.cpp +++ b/Descent3/tests/porting-tests.cpp @@ -25,10 +25,11 @@ // This is copy of actual Osiris_CreateGameChecksum(void) from OsirisLoadandBind.cpp uint32_t Osiris_CreateGameChecksumTest() { uint32_t value = 0xe1e1b0b0; + tOSIRISModuleInit tmp; value += sizeof(object); value += sizeof(player) * 2; - value += sizeof(tOSIRISModuleInit) * 3; + value += tmp.serial_version * 3; value += sizeof(tOSIRISEventInfo) * 5; value += sizeof(tOSIRISTIMER) * 7; value += sizeof(tOSIRISSCRIPTID) * 11; @@ -43,7 +44,7 @@ uint32_t Osiris_CreateGameChecksumTest() { value = value << 2; /* Adds count of Osiris_module_init.fp */ - value += 123; + value += 126; return value; } diff --git a/Descent3/tests/test_data/d3.str b/Descent3/tests/test_data/d3.str new file mode 100644 index 000000000..c78927ecb --- /dev/null +++ b/Descent3/tests/test_data/d3.str @@ -0,0 +1,8 @@ +!/! This is comment + +!/!0:A message +!=!English message +!G!Deutsche Botschaft +!S!Mensaje en español +!I!Messaggio italiano +!F!Message en français diff --git a/editor/ScriptLevelInterface.cpp b/editor/ScriptLevelInterface.cpp index ef7714c86..16a0f401c 100644 --- a/editor/ScriptLevelInterface.cpp +++ b/editor/ScriptLevelInterface.cpp @@ -2313,7 +2313,7 @@ bool IsScriptOutofSync(char *name) { ddio_SplitPath(name, NULL, filename, ext); Osiris_module_init.string_count = 0; - Osiris_module_init.string_table = NULL; + Osiris_module_init.string_table.clear(); Osiris_module_init.module_is_static = false; Osiris_module_init.module_identifier = 0; Osiris_module_init.script_identifier = filename; diff --git a/netcon/descent3onlineclient/odtclient.cpp b/netcon/descent3onlineclient/odtclient.cpp index 195eb899c..d34a0c8bd 100644 --- a/netcon/descent3onlineclient/odtclient.cpp +++ b/netcon/descent3onlineclient/odtclient.cpp @@ -247,9 +247,9 @@ void DLLFUNCCALL DLLMultiInit(int *api_func) { Auto_start = false; DLLmprintf(0, "About to create string table...\n"); - DLLCreateStringTable("d3online.str", &StringTable, &StringTableSize); - DLLmprintf(0, "%d strings loaded from string table\n", StringTableSize); - if (!StringTableSize) { + DLLCreateStringTable("d3online.str", StringTable); + DLLmprintf(0, "%d strings loaded from string table\n", StringTable.size()); + if (StringTable.empty()) { All_ok = false; return; } @@ -260,7 +260,7 @@ void DLLFUNCCALL DLLMultiInit(int *api_func) { // Called when the DLL is shutdown void DLLFUNCCALL DLLMultiClose() { DLLmprintf(0, "Closing down Online Direct TCP-IP DLL\n"); - DLLDestroyStringTable(StringTable, StringTableSize); + DLLDestroyStringTable(StringTable); #ifdef MACINTOSH ShutdownOTSockets(); #endif diff --git a/netcon/includes/con_dll.h b/netcon/includes/con_dll.h index 94c81df85..37408a704 100644 --- a/netcon/includes/con_dll.h +++ b/netcon/includes/con_dll.h @@ -269,6 +269,7 @@ #include #include #include +#include #include "crossplat.h" #include "ship.h" @@ -278,14 +279,13 @@ // #define DEMO 1 // localization info -char **StringTable; -int StringTableSize = 0; +std::vector StringTable; const char *_ErrorString = "Missing String"; const char *GetString(int d) { - if ((d < 0) || (d >= StringTableSize)) + if ((d < 0) || (d >= StringTable.size())) return _ErrorString; else - return StringTable[d]; + return StringTable[d].c_str(); } #define TXT(d) GetString(d) /////////////////////////////////////////////// @@ -576,14 +576,10 @@ typedef int (*dp_GetModemChoices_fp)(char *buffer, uint32_t *size); dp_GetModemChoices_fp DLLdp_GetModemChoices; #endif -// Given a filename, pointer to a char * array and a pointer to an int, -// it will load the string table and fill in the information -// returns true on success -typedef bool (*CreateStringTable_fp)(const char *filename, char ***table, int *size); +typedef bool (*CreateStringTable_fp)(const std::filesystem::path &filename, std::vector &table); CreateStringTable_fp DLLCreateStringTable; -// Given a string table and its count of strings, it will free up its memory -typedef void (*DestroyStringTable_fp)(char **table, int size); +typedef void (*DestroyStringTable_fp)(std::vector &table); DestroyStringTable_fp DLLDestroyStringTable; typedef void (*DatabaseReadInt_fp)(const char *label, int *val); diff --git a/netcon/lanclient/lanclient.cpp b/netcon/lanclient/lanclient.cpp index 17b7d5485..33c3e0f4c 100644 --- a/netcon/lanclient/lanclient.cpp +++ b/netcon/lanclient/lanclient.cpp @@ -263,6 +263,9 @@ * $NoKeywords: $ */ +#include +#include + #include "ui.h" #include "newui.h" #include "grdefs.h" @@ -336,11 +339,11 @@ DLLEXPORT void DLLFUNCCALL DLLMultiClose(); static bool All_ok = true; // Initializes the game function pointers void DLLFUNCCALL DLLMultiInit(int *api_func) { - Use_netgame_flags = 1; + Use_netgame_flags = true; #include "mdllinit.h" - DLLCreateStringTable("lanclient.str", &StringTable, &StringTableSize); - DLLmprintf(0, "%d strings loaded from string table\n", StringTableSize); - if (!StringTableSize) { + DLLCreateStringTable("lanclient.str", StringTable); + DLLmprintf(0, "%d strings loaded from string table\n", StringTable.size()); + if (StringTable.empty()) { All_ok = false; return; } @@ -348,7 +351,7 @@ void DLLFUNCCALL DLLMultiInit(int *api_func) { } // Called when the DLL is shutdown -void DLLFUNCCALL DLLMultiClose() { DLLDestroyStringTable(StringTable, StringTableSize); } +void DLLFUNCCALL DLLMultiClose() { DLLDestroyStringTable(StringTable); } // The main entry point where the game calls the dll void DLLFUNCCALL DLLMultiCall(int eventnum) { diff --git a/netcon/mtclient/mtclient.cpp b/netcon/mtclient/mtclient.cpp index 39212f85a..80f6f7d55 100644 --- a/netcon/mtclient/mtclient.cpp +++ b/netcon/mtclient/mtclient.cpp @@ -411,6 +411,9 @@ * $NoKeywords: $ */ +#include +#include + #include "ui.h" #include "newui.h" #include "grdefs.h" @@ -666,9 +669,9 @@ void DLLFUNCCALL DLLMultiInit(int *api_func) { *DLLUse_DirectPlay = false; Auto_start = false; DLLmprintf(0, "About to create string table...\n"); - DLLCreateStringTable("mtclient.str", &StringTable, &StringTableSize); - DLLmprintf(0, "%d strings loaded from string table\n", StringTableSize); - if (!StringTableSize) { + DLLCreateStringTable("mtclient.str", StringTable); + DLLmprintf(0, "%d strings loaded from string table\n", StringTable.size()); + if (StringTable.empty()) { All_ok = false; return; } @@ -679,7 +682,7 @@ void DLLFUNCCALL DLLMultiInit(int *api_func) { // Called when the DLL is shutdown void DLLFUNCCALL DLLMultiClose() { DLLmprintf(0, "Closing down PXO DLL\n"); - DLLDestroyStringTable(StringTable, StringTableSize); + DLLDestroyStringTable(StringTable); DLLnw_UnRegisterCallback(PXO_NETID_USER_TRACKER); DLLnw_UnRegisterCallback(PXO_NETID_GAME_TRACKER); if (MT_Sock_inited) { diff --git a/netgames/anarchy/anarchy.cpp b/netgames/anarchy/anarchy.cpp index 8c0934154..6890f446c 100644 --- a/netgames/anarchy/anarchy.cpp +++ b/netgames/anarchy/anarchy.cpp @@ -50,15 +50,15 @@ * $NoKeywords: $ */ -#include -#include -#include +#include +#include +#include +#include + #include "idmfc.h" #include "Anarchy.h" #include "anarchystr.h" -#include - IDMFC *DMFCBase = NULL; static IDmfcStats *dstat = NULL; @@ -86,14 +86,13 @@ static void DetermineScore(int precord_num, int column_num, char *buffer, int bu /////////////////////////////////////////////// // localization info -static char **StringTable; -static int StringTableSize = 0; +static std::vector StringTable; static const char *_ErrorString = "Missing String"; const char *GetString(int d) { - if ((d < 0) || (d >= StringTableSize)) + if ((d < 0) || (d >= StringTable.size())) return _ErrorString; else - return StringTable[d]; + return StringTable[d].c_str(); } /////////////////////////////////////////////// @@ -159,9 +158,9 @@ void DLLFUNCCALL DLLGameInit(int *api_func, uint8_t *all_ok, int num_teams_to_us DMFCBase->Set_OnDisconnectSaveStatsToFile(OnDisconnectSaveStatsToFile); DMFCBase->Set_OnPrintScores(OnPrintScores); - DLLCreateStringTable("Anarchy.str", &StringTable, &StringTableSize); - mprintf(0, "%d strings loaded from string table\n", StringTableSize); - if (!StringTableSize) { + DLLCreateStringTable("Anarchy.str", StringTable); + mprintf(0, "%d strings loaded from string table\n", StringTable.size()); + if (StringTable.empty()) { *all_ok = 0; return; } @@ -214,7 +213,7 @@ void DLLFUNCCALL DLLGameClose() { if (Highlight_bmp > BAD_BITMAP_HANDLE) DLLbm_FreeBitmap(Highlight_bmp); - DLLDestroyStringTable(StringTable, StringTableSize); + DLLDestroyStringTable(StringTable); if (dstat) { dstat->DestroyPointer(); diff --git a/netgames/coop/coop.cpp b/netgames/coop/coop.cpp index f055e2edd..cb624d710 100644 --- a/netgames/coop/coop.cpp +++ b/netgames/coop/coop.cpp @@ -99,15 +99,15 @@ * $NoKeywords: $ */ -#include -#include -#include +#include +#include +#include +#include + #include "idmfc.h" #include "coop.h" #include "coopstr.h" -#include - IDMFC *DMFCBase = NULL; static IDmfcStats *dstat = NULL; static player *dPlayers; @@ -135,14 +135,13 @@ int unpack_pstat(tPlayerStat *user_info, uint8_t *data) { /////////////////////////////////////////////// // localization info -static char **StringTable; -static int StringTableSize = 0; +static std::vector StringTable; static const char *_ErrorString = "Missing String"; -const char *GetStringFromTable(int d) { - if ((d < 0) || (d >= StringTableSize)) +const char *GetStringFromTable(uint32_t index) { + if (index >= StringTable.size()) return _ErrorString; else - return StringTable[d]; + return StringTable[index].c_str(); } /////////////////////////////////////////////// static int SortedPlayers[MAX_PLAYER_RECORDS]; @@ -215,9 +214,9 @@ void DLLFUNCCALL DLLGameInit(int *api_func, uint8_t *all_ok, int num_teams_to_us dPlayers = DMFCBase->GetPlayers(); - DLLCreateStringTable("Coop.str", &StringTable, &StringTableSize); - mprintf(0, "%d strings loaded from string table\n", StringTableSize); - if (!StringTableSize) { + DLLCreateStringTable("Coop.str", StringTable); + mprintf(0, "%d strings loaded from string table\n", StringTable.size()); + if (StringTable.empty()) { *all_ok = 0; return; } @@ -300,7 +299,7 @@ void DLLFUNCCALL DLLGameClose() { if (Highlight_bmp > BAD_BITMAP_HANDLE) DLLbm_FreeBitmap(Highlight_bmp); - DLLDestroyStringTable(StringTable, StringTableSize); + DLLDestroyStringTable(StringTable); if (dstat) { dstat->DestroyPointer(); diff --git a/netgames/coop/coopstr.h b/netgames/coop/coopstr.h index 3e3e8be69..2f0b58697 100644 --- a/netgames/coop/coopstr.h +++ b/netgames/coop/coopstr.h @@ -26,7 +26,7 @@ // Returns a pointer to the string at the index location from the string table // if it is a bad index given, then the pointer to the error string "ERROR MISSING STRING" is given -const char *GetStringFromTable(int index); +const char *GetStringFromTable(uint32_t index); #define TXT_COOP TXT(0) //"Coop" #define TXT_STATGAMENAME TXT(1) //"Co-op Descent 3" diff --git a/netgames/ctf/ctf.cpp b/netgames/ctf/ctf.cpp index ce558f9bf..7c9fdfcad 100644 --- a/netgames/ctf/ctf.cpp +++ b/netgames/ctf/ctf.cpp @@ -84,8 +84,11 @@ * $NoKeywords: $ */ +#include +#include +#include + #include "gamedll_header.h" -#include #include "idmfc.h" #include "ctf.h" @@ -229,14 +232,13 @@ static void LoseFlagForPlayer(int pnum, uint8_t team, bool remove_from_inven = t /////////////////////////////////////////////// // localization info/functions -static char **StringTable; -static int StringTableSize = 0; +static std::vector StringTable; static const char *_ErrorString = "Missing String"; const char *GetString(int d) { - if ((d < 0) || (d >= StringTableSize)) + if ((d < 0) || (d >= StringTable.size())) return _ErrorString; else - return StringTable[d]; + return StringTable[d].c_str(); } static void SaveStatsToFile(char *filename); static void DetermineScore(int precord_num, int column_num, char *buffer, int buffer_size); @@ -351,9 +353,9 @@ void DLLFUNCCALL DLLGameInit(int *api_func, uint8_t *all_ok, int num_teams_to_us CTFNumOfTeams = num_teams_to_use; DMFCBase->GameInit(CTFNumOfTeams); - DLLCreateStringTable("CTF.str", &StringTable, &StringTableSize); - DLLmprintf(0, "%d strings loaded from string table\n", StringTableSize); - if (!StringTableSize) { + DLLCreateStringTable("CTF.str", StringTable); + DLLmprintf(0, "%d strings loaded from string table\n", StringTable.size()); + if (StringTable.empty()) { *all_ok = 0; return; } @@ -554,7 +556,7 @@ void DLLFUNCCALL DLLGameClose() { if (Highlight_bmp > BAD_BITMAP_HANDLE) DLLbm_FreeBitmap(Highlight_bmp); - DLLDestroyStringTable(StringTable, StringTableSize); + DLLDestroyStringTable(StringTable); if (dstat) { dstat->DestroyPointer(); diff --git a/netgames/dmfc/dmfcbase.cpp b/netgames/dmfc/dmfcbase.cpp index 4e88d8572..8a6862708 100644 --- a/netgames/dmfc/dmfcbase.cpp +++ b/netgames/dmfc/dmfcbase.cpp @@ -467,27 +467,28 @@ * $NoKeywords: $ */ +#include +#include +#include +#include +#include + #include "gamedll_header.h" #include "DMFC.h" #include "dmfcinternal.h" #include "dmfcinputcommands.h" -#include -#include -#include - -char **DMFCStringTable; -int DMFCStringTableSize = 0; +std::vector DMFCStringTable; const char *_DMFCErrorString = "DMFC Missing String"; uint8_t seeds1[31] = {49, 73, 0, 44, 87, 253, 35, 74, 62, 250, 4, 247, 251, 72, 244, 30, 59, 61, 60, 52, 50, 237, 23, 48, 56, 55, 65, 232, 231, 230, 0}; uint8_t seeds2[6] = {70, 95, 103, 102, 112, 0}; const char *DMFCGetString(int d) { - if ((d < 0) || (d >= DMFCStringTableSize)) + if ((d < 0) || (d >= DMFCStringTable.size())) return _DMFCErrorString; else - return DMFCStringTable[d]; + return DMFCStringTable[d].c_str(); } DMFCBase::DMFCBase(void) { @@ -1197,8 +1198,8 @@ void DMFCBase::GameInit(int teams) { LoadSettings(); - DLLCreateStringTable("dmfc.str", &DMFCStringTable, &DMFCStringTableSize); - mprintf(0, "DMFC Note: %d strings loaded from string table\n", DMFCStringTableSize); + DLLCreateStringTable("dmfc.str", DMFCStringTable); + mprintf(0, "DMFC Note: %d strings loaded from string table\n", DMFCStringTable.size()); // initialize player records PRec_Init(); @@ -1530,7 +1531,7 @@ void DMFCBase::GameClose(void) { if (MenuBackgroundBMP > BAD_BITMAP_HANDLE) DLLbm_FreeBitmap(MenuBackgroundBMP); - DLLDestroyStringTable(DMFCStringTable, DMFCStringTableSize); + DLLDestroyStringTable(DMFCStringTable); } void DMFCBase::DrawMenu(void) { diff --git a/netgames/dmfc/dmfcfunctions.cpp b/netgames/dmfc/dmfcfunctions.cpp index e9698ca7c..7f72df94d 100644 --- a/netgames/dmfc/dmfcfunctions.cpp +++ b/netgames/dmfc/dmfcfunctions.cpp @@ -118,10 +118,9 @@ */ #include +#include +#include -#include "DMFC.h" -#include "dmfcinternal.h" -#include "dmfcinputcommands.h" #include "gamedll_header.h" void (*DLLGetGameAPI)(game_api *); @@ -212,8 +211,8 @@ bool (*DLLcf_Diff)(const char *a, const char *b); void (*DLLMultiDisconnectPlayer)(int slot); void (*DLLnw_GetNumbersFromHostAddress)(network_address *address, char *str); int (*DLLnw_GetThisIP)(void); -bool (*DLLCreateStringTable)(const char *filename, char ***table, int *size); -void (*DLLDestroyStringTable)(char **table, int size); +bool (*DLLCreateStringTable)(const std::filesystem::path &filename, std::vector &table); +void (*DLLDestroyStringTable)(std::vector &table); void (*DLLRenderHUDTextFlags)(int flags, ddgr_color col, uint8_t alpha, int sat_count, int x, int y, const char *fmt, ...); void (*DLLPlayerSetHUDNameFOV)(int fov); void (*DLLGetUltimateParentForObject)(object **parent, object *child); diff --git a/netgames/entropy/EntropyBase.cpp b/netgames/entropy/EntropyBase.cpp index f03c6125a..8e3215b14 100644 --- a/netgames/entropy/EntropyBase.cpp +++ b/netgames/entropy/EntropyBase.cpp @@ -95,8 +95,11 @@ * $NoKeywords: $ */ +#include +#include +#include + #include "gamedll_header.h" //included by all mods, it includes all needed headers, etc. -#include #include "idmfc.h" //dmfc! (required) #include "Entropy.h" #include "Entropystr.h" //our string table for Entropy @@ -209,14 +212,13 @@ static void OnPrintScores(int level); /////////////////////////////////////////////// // localization info -static char **StringTable; -static int StringTableSize = 0; +static std::vector StringTable; static const char *_ErrorString = "Missing String"; -const char *GetStringFromTable(int d) { - if ((d < 0) || (d >= StringTableSize)) +const char *GetStringFromTable(uint32_t index) { + if (index >= StringTable.size()) return _ErrorString; else - return StringTable[d]; + return StringTable[index].c_str(); } /////////////////////////////////////////////// @@ -297,9 +299,9 @@ void DLLFUNCCALL DLLGameInit(int *api_func, uint8_t *all_ok, int num_teams_to_us Netgame->flags |= (NF_TRACK_RANK); DMFCBase->GameInit(NUM_TEAMS); - DLLCreateStringTable("entropy.str", &StringTable, &StringTableSize); - DLLmprintf(0, "%d strings loaded from string table\n", StringTableSize); - if (!StringTableSize) { + DLLCreateStringTable("entropy.str", StringTable); + DLLmprintf(0, "%d strings loaded from string table\n", StringTable.size()); + if (StringTable.empty()) { *all_ok = 0; return; } @@ -417,7 +419,7 @@ void DLLFUNCCALL DLLGameClose() { RoomList = NULL; } - DLLDestroyStringTable(StringTable, StringTableSize); + DLLDestroyStringTable(StringTable); if (dstat) { dstat->DestroyPointer(); diff --git a/netgames/entropy/Entropystr.h b/netgames/entropy/Entropystr.h index 1dfef5c50..d6d59442e 100644 --- a/netgames/entropy/Entropystr.h +++ b/netgames/entropy/Entropystr.h @@ -26,7 +26,7 @@ // Returns a pointer to the string at the index location from the string table // if it is a bad index given, then the pointer to the error string "ERROR MISSING STRING" is given -const char *GetStringFromTable(int index); +const char *GetStringFromTable(uint32_t index); #define TXT_GAMENAME TXT(0) //"Entropy" #define TXT_KILLA TXT(1) //"%s was killed by %s" diff --git a/netgames/hoard/hoard.cpp b/netgames/hoard/hoard.cpp index 9dc343f1b..1a181e0a4 100644 --- a/netgames/hoard/hoard.cpp +++ b/netgames/hoard/hoard.cpp @@ -63,8 +63,11 @@ * $NoKeywords: $ */ +#include +#include +#include + #include "gamedll_header.h" -#include #include "idmfc.h" #include "Hoard.h" #include "hoardstr.h" @@ -139,14 +142,13 @@ static bool Config_displayed = false; /////////////////////////////////////////////// // localization info -static char **StringTable; -static int StringTableSize = 0; +static std::vector StringTable; static const char *_ErrorString = "Missing String"; -const char *GetStringFromTable(int d) { - if ((d < 0) || (d >= StringTableSize)) +const char *GetStringFromTable(uint32_t index) { + if (index >= StringTable.size()) return _ErrorString; else - return StringTable[d]; + return StringTable[index].c_str(); } /////////////////////////////////////////////// @@ -308,9 +310,9 @@ void DLLFUNCCALL DLLGameInit(int *api_func, uint8_t *all_ok, int num_teams_to_us dObjects = DMFCBase->GetObjects(); dPlayers = DMFCBase->GetPlayers(); - DLLCreateStringTable("Hoard.str", &StringTable, &StringTableSize); - DLLmprintf(0, "%d strings loaded from string table\n", StringTableSize); - if (!StringTableSize) { + DLLCreateStringTable("Hoard.str", StringTable); + DLLmprintf(0, "%d strings loaded from string table\n", StringTable.size()); + if (StringTable.empty()) { *all_ok = 0; return; } @@ -451,7 +453,7 @@ void DLLFUNCCALL DLLGameClose() { if (Highlight_bmp > BAD_BITMAP_HANDLE) DLLbm_FreeBitmap(Highlight_bmp); - DLLDestroyStringTable(StringTable, StringTableSize); + DLLDestroyStringTable(StringTable); if (HoardOrbIcon > BAD_BITMAP_HANDLE) DLLbm_FreeBitmap(HoardOrbIcon); diff --git a/netgames/hoard/hoardstr.h b/netgames/hoard/hoardstr.h index 041f0f302..e35b74b73 100644 --- a/netgames/hoard/hoardstr.h +++ b/netgames/hoard/hoardstr.h @@ -26,7 +26,7 @@ // Returns a pointer to the string at the index location from the string table // if it is a bad index given, then the pointer to the error string "ERROR MISSING STRING" is given -const char *GetStringFromTable(int index); +const char *GetStringFromTable(uint32_t index); #define TXT_DEATH1 TXT(0) //"%s got blasted by %s" #define TXT_DEATH2 TXT(1) //"%s knows %s is his god" diff --git a/netgames/hyperanarchy/hyperanarchy.cpp b/netgames/hyperanarchy/hyperanarchy.cpp index 7830b472d..66182c1e3 100644 --- a/netgames/hyperanarchy/hyperanarchy.cpp +++ b/netgames/hyperanarchy/hyperanarchy.cpp @@ -53,12 +53,16 @@ * $NoKeywords: $ */ -#include -#include +#include +#include +#include +#include + #include "gamedll_header.h" #include "idmfc.h" #include "HyperAnarchy.h" #include "hyperstr.h" + IDMFC *DMFCBase = NULL; static IDmfcStats *dstat = NULL; static object *dObjects; @@ -107,14 +111,13 @@ static void OnClientPlayerEntersGame(int player_num); /////////////////////////////////////////////// // localization info -static char **StringTable; -static int StringTableSize = 0; +static std::vector StringTable; static const char *_ErrorString = "Missing String"; -const char *GetStringFromTable(int d) { - if ((d < 0) || (d >= StringTableSize)) +const char *GetStringFromTable(uint32_t index) { + if (index >= StringTable.size()) return _ErrorString; else - return StringTable[d]; + return StringTable[index].c_str(); } /////////////////////////////////////////////// @@ -231,9 +234,9 @@ void DLLFUNCCALL DLLGameInit(int *api_func, uint8_t *all_ok, int num_teams_to_us DMFCBase->Set_OnPlayerEntersObserver(OnPlayerEntersObserver); DMFCBase->Set_OnClientPlayerEntersGame(OnClientPlayerEntersGame); - DLLCreateStringTable("hyper.str", &StringTable, &StringTableSize); - DLLmprintf(0, "%d strings loaded from string table\n", StringTableSize); - if (!StringTableSize) { + DLLCreateStringTable("hyper.str", StringTable); + DLLmprintf(0, "%d strings loaded from string table\n", StringTable.size()); + if (StringTable.empty()) { *all_ok = 0; return; } @@ -365,7 +368,7 @@ void DLLFUNCCALL DLLGameClose() { if (Highlight_bmp > BAD_BITMAP_HANDLE) DLLbm_FreeBitmap(Highlight_bmp); - DLLDestroyStringTable(StringTable, StringTableSize); + DLLDestroyStringTable(StringTable); if (HyperOrbIcon > 0) DLLbm_FreeBitmap(HyperOrbIcon); diff --git a/netgames/hyperanarchy/hyperstr.h b/netgames/hyperanarchy/hyperstr.h index 9512a955b..2a0511b73 100644 --- a/netgames/hyperanarchy/hyperstr.h +++ b/netgames/hyperanarchy/hyperstr.h @@ -26,7 +26,7 @@ // Returns a pointer to the string at the index location from the string table // if it is a bad index given, then the pointer to the error string "ERROR MISSING STRING" is given -const char *GetStringFromTable(int index); +const char *GetStringFromTable(uint32_t index); #define TXT_DEATH1 TXT(0) //"%s got butchered by %s" #define TXT_SUICIDE1 TXT(1) //"%s shags himself" diff --git a/netgames/includes/gamedll_header.h b/netgames/includes/gamedll_header.h index b2758bab1..5c3ea8081 100644 --- a/netgames/includes/gamedll_header.h +++ b/netgames/includes/gamedll_header.h @@ -20,6 +20,8 @@ #define GAMEDLL_HEADER_H #include +#include +#include #include "spew.h" #include "gamefont.h" @@ -520,14 +522,10 @@ DMFCDLLOUT(nw_GetNumbersFromHostAddress_fp DLLnw_GetNumbersFromHostAddress;) typedef int (*nw_GetThisIP_fp)(void); DMFCDLLOUT(nw_GetThisIP_fp DLLnw_GetThisIP;) -// Given a filename, pointer to a char * array and a pointer to an int, -// it will load the string table and fill in the information -// returns true on success -typedef bool (*CreateStringTable_fp)(const char *filename, char ***table, int *size); +typedef bool (*CreateStringTable_fp)(const std::filesystem::path &filename, std::vector &table); DMFCDLLOUT(CreateStringTable_fp DLLCreateStringTable;) -// Given a string table and its count of strings, it will free up its memory -typedef void (*DestroyStringTable_fp)(char **table, int size); +typedef void (*DestroyStringTable_fp)(std::vector &table); DMFCDLLOUT(DestroyStringTable_fp DLLDestroyStringTable;) // renders text, scaled, alphaed, saturated, diff --git a/netgames/monsterball/monsterball.cpp b/netgames/monsterball/monsterball.cpp index eb333184e..ea7007a7f 100644 --- a/netgames/monsterball/monsterball.cpp +++ b/netgames/monsterball/monsterball.cpp @@ -163,11 +163,13 @@ */ #include +#include +#include +#include #include "gamedll_header.h" #include "idmfc.h" #include "monsterball.h" -#include #include "monsterstr.h" #include @@ -270,14 +272,13 @@ static bool monsterball_info_set = false; /////////////////////////////////////////////// // localization info -static char **StringTable; -static int StringTableSize = 0; +static std::vector StringTable; static const char *_ErrorString = "Missing String"; -const char *GetStringFromTable(int d) { - if ((d < 0) || (d >= StringTableSize)) +const char *GetStringFromTable(uint32_t index) { + if (index >= StringTable.size()) return _ErrorString; else - return StringTable[d]; + return StringTable[index].c_str(); } /////////////////////////////////////////////// @@ -418,8 +419,8 @@ void DLLFUNCCALL DLLGameInit(int *api_func, uint8_t *all_ok, int num_teams_to_us Netgame->flags |= (NF_TRACK_RANK); DMFCBase->GameInit(NumOfTeams); - DLLCreateStringTable("monster.str", &StringTable, &StringTableSize); - DLLmprintf(0, "%d strings loaded from string table\n", StringTableSize); + DLLCreateStringTable("monster.str", StringTable); + DLLmprintf(0, "%d strings loaded from string table\n", StringTable.size()); // add the death and suicide messages DMFCBase->AddDeathMessage(TXT_KILLEDA, true); @@ -527,7 +528,7 @@ void DLLFUNCCALL DLLGameClose() { if (Monsterball_info.icon > BAD_BITMAP_HANDLE) DLLbm_FreeBitmap(Monsterball_info.icon); - DLLDestroyStringTable(StringTable, StringTableSize); + DLLDestroyStringTable(StringTable); if (dstat) { dstat->DestroyPointer(); diff --git a/netgames/monsterball/monsterstr.h b/netgames/monsterball/monsterstr.h index 1eeb1e0f0..1e5245c9d 100644 --- a/netgames/monsterball/monsterstr.h +++ b/netgames/monsterball/monsterstr.h @@ -26,7 +26,7 @@ // Returns a pointer to the string at the index location from the string table // if it is a bad index given, then the pointer to the error string "ERROR MISSING STRING" is given -const char *GetStringFromTable(int index); +const char *GetStringFromTable(uint32_t index); #define TXT_GAMENAME TXT(0) //"Monsterball" #define TXT_KILLEDA TXT(1) //"%s was killed by %s" diff --git a/netgames/roboanarchy/roboanarchy.cpp b/netgames/roboanarchy/roboanarchy.cpp index 678c3fbc9..64662da3d 100644 --- a/netgames/roboanarchy/roboanarchy.cpp +++ b/netgames/roboanarchy/roboanarchy.cpp @@ -47,9 +47,11 @@ * $NoKeywords: $ */ -#include -#include -#include +#include +#include +#include +#include + #include "idmfc.h" #include "roboAnarchy.h" #include "roboanarchystr.h" @@ -81,14 +83,13 @@ static void SwitchAnarchyScores(int i); /////////////////////////////////////////////// // localization info -static char **StringTable; -static int StringTableSize = 0; +static std::vector StringTable; static const char *_ErrorString = "Missing String"; const char *GetString(int d) { - if ((d < 0) || (d >= StringTableSize)) + if ((d < 0) || (d >= StringTable.size())) return _ErrorString; else - return StringTable[d]; + return StringTable[d].c_str(); } /////////////////////////////////////////////// @@ -154,9 +155,9 @@ void DLLFUNCCALL DLLGameInit(int *api_func, uint8_t *all_ok, int num_teams_to_us DMFCBase->Set_OnDisconnectSaveStatsToFile(OnDisconnectSaveStatsToFile); DMFCBase->Set_OnPrintScores(OnPrintScores); - DLLCreateStringTable("Anarchy.str", &StringTable, &StringTableSize); - mprintf(0, "%d strings loaded from string table\n", StringTableSize); - if (!StringTableSize) { + DLLCreateStringTable("Anarchy.str", StringTable); + mprintf(0, "%d strings loaded from string table\n", StringTable.size()); + if (StringTable.empty()) { *all_ok = 0; return; } @@ -209,7 +210,7 @@ void DLLFUNCCALL DLLGameClose() { if (Highlight_bmp > BAD_BITMAP_HANDLE) DLLbm_FreeBitmap(Highlight_bmp); - DLLDestroyStringTable(StringTable, StringTableSize); + DLLDestroyStringTable(StringTable); if (dstat) { dstat->DestroyPointer(); diff --git a/netgames/tanarchy/tanarchy.cpp b/netgames/tanarchy/tanarchy.cpp index 26080e2ff..8fd6fc548 100644 --- a/netgames/tanarchy/tanarchy.cpp +++ b/netgames/tanarchy/tanarchy.cpp @@ -76,11 +76,15 @@ * $NoKeywords: $ */ +#include +#include +#include + #include "gamedll_header.h" -#include #include "idmfc.h" #include "tanDMFC.h" #include "tanarchystr.h" + IDMFC *DMFCBase = NULL; static IDmfcStats *dstat = NULL; static player *dPlayers; @@ -113,14 +117,13 @@ static int Highlight_bmp = -1; /////////////////////////////////////////////// // localization info -static char **StringTable; -static int StringTableSize = 0; +static std::vector StringTable; static const char *_ErrorString = "Missing String"; -const char *GetStringFromTable(int d) { - if ((d < 0) || (d >= StringTableSize)) +const char *GetStringFromTable(uint32_t index) { + if (index >= StringTable.size()) return _ErrorString; else - return StringTable[d]; + return StringTable[index].c_str(); } /////////////////////////////////////////////// @@ -184,9 +187,9 @@ void DLLFUNCCALL DLLGameInit(int *api_func, uint8_t *all_ok, int num_teams_to_us dPlayers = DMFCBase->GetPlayers(); DMFCBase->GameInit(NUM_TEAMS); - DLLCreateStringTable("tanarchy.str", &StringTable, &StringTableSize); - DLLmprintf(0, "%d strings loaded from string table\n", StringTableSize); - if (!StringTableSize) { + DLLCreateStringTable("tanarchy.str", StringTable); + DLLmprintf(0, "%d strings loaded from string table\n", StringTable.size()); + if (StringTable.empty()) { *all_ok = 0; return; } @@ -294,7 +297,7 @@ void DLLFUNCCALL DLLGameClose() { if (Highlight_bmp > BAD_BITMAP_HANDLE) DLLbm_FreeBitmap(Highlight_bmp); - DLLDestroyStringTable(StringTable, StringTableSize); + DLLDestroyStringTable(StringTable); if (dstat) { dstat->DestroyPointer(); diff --git a/netgames/tanarchy/tanarchystr.h b/netgames/tanarchy/tanarchystr.h index cbb068091..54af6866a 100644 --- a/netgames/tanarchy/tanarchystr.h +++ b/netgames/tanarchy/tanarchystr.h @@ -26,7 +26,7 @@ // Returns a pointer to the string at the index location from the string table // if it is a bad index given, then the pointer to the error string "ERROR MISSING STRING" is given -const char *GetStringFromTable(int index); +const char *GetStringFromTable(uint32_t index); #define TXT_DEATH1 TXT(0) //"%s got blasted by %s" #define TXT_DEATH2 TXT(1) //"%s knows %s is his god" diff --git a/scripts/AIGame.cpp b/scripts/AIGame.cpp index dfc24899b..6a7eb933c 100644 --- a/scripts/AIGame.cpp +++ b/scripts/AIGame.cpp @@ -19,9 +19,11 @@ // AIGame.cpp // #include -#include -#include -#include +#include +#include +#include +#include +#include #include "osiris_import.h" #include "osiris_common.h" #include "osiris_vector.h" @@ -43,16 +45,15 @@ DLLEXPORT int STDCALL SaveRestoreState(void *file_ptr, uint8_t saving_state); } #endif -static int String_table_size = 0; -static char **String_table = NULL; +static std::vector String_table; static const char *_Error_string = "!!ERROR MISSING STRING!!"; static const char *_Empty_string = ""; -const char *GetStringFromTable(int index) { - if ((index < 0) || (index >= String_table_size)) +const char *GetStringFromTable(uint32_t index) { + if (index >= String_table.size()) return _Error_string; - if (!String_table[index]) + if (String_table[index].empty()) return _Empty_string; - return String_table[index]; + return String_table[index].c_str(); } #define TXT(x) GetStringFromTable(x) #define TXT_GBM_RENAME 0 //"Rename GB Unit" @@ -2469,7 +2470,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { return 0; } aigame_mod_id = func_list->module_identifier; - String_table_size = func_list->string_count; String_table = func_list->string_table; return 1; diff --git a/scripts/AIGame3.cpp b/scripts/AIGame3.cpp index b7374af2e..bcf214cfb 100644 --- a/scripts/AIGame3.cpp +++ b/scripts/AIGame3.cpp @@ -19,8 +19,10 @@ // AIGame3.cpp // 0.1 #include -#include -#include +#include +#include +#include +#include #include "osiris_import.h" #include "osiris_common.h" #include "osiris_vector.h" @@ -44,16 +46,15 @@ DLLEXPORT int STDCALL SaveRestoreState(void *file_ptr, uint8_t saving_state); } #endif -static int String_table_size = 0; -static char **String_table = NULL; +static std::vector String_table; static const char *_Error_string = "!!ERROR MISSING STRING!!"; static const char *_Empty_string = ""; -const char *GetStringFromTable(int index) { - if ((index < 0) || (index >= String_table_size)) +const char *GetStringFromTable(uint32_t index) { + if (index >= String_table.size()) return _Error_string; - if (!String_table[index]) + if (String_table[index].empty()) return _Empty_string; - return String_table[index]; + return String_table[index].c_str(); } #define TXT(x) GetStringFromTable(x) @@ -1491,7 +1492,6 @@ void DoNameLookups(void) { // Returns 1 if initialization went ok, 0 if there was an error and the DLL should not be loaded. char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { osicommon_Initialize((tOSIRISModuleInit *)func_list); - String_table_size = func_list->string_count; String_table = func_list->string_table; // Do name lookups diff --git a/scripts/BatteriesIncluded.cpp b/scripts/BatteriesIncluded.cpp index 9a5746736..843cd5b2c 100644 --- a/scripts/BatteriesIncluded.cpp +++ b/scripts/BatteriesIncluded.cpp @@ -22,10 +22,10 @@ // Filename: BatteriesIncluded.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -489,185 +489,6 @@ void RestoreGlobalActionCtrs(void *file_ptr) { // End of Custom Script Block - DO NOT EDIT ANYTHING AFTER THIS // ============================================================ -// ================= -// Message File Data -// ================= - -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - -// Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} - -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} - //====================== // Name List Arrays //====================== @@ -719,11 +540,12 @@ int *Matcen_indexes = NULL; const char **Goal_names = NULL; int *Goal_indexes = NULL; -#define NUM_MESSAGE_NAMES 17 -const char *Message_names[NUM_MESSAGE_NAMES] = {"Chris", "Kevin", "JeffNate", "Matt", "Jay", "Jerry", - "Long", "Andy", "Claflin", "Mea", "LukeJosh", "Interplay", - "Hayes", "Sean", "Doug", "Samir", "Mark"}; -const char *Message_strings[NUM_MESSAGE_NAMES]; +// Global storage for level script messages +std::map Messages; + +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) // =============== // InitializeDLL() @@ -738,37 +560,19 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - char english_filename[(_MAX_PATH + 32) * 2]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - snprintf(english_filename, sizeof(english_filename), "%s.msg", filename); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); - else if (lang_type == LANGUAGE_POLISH) - strcat(filename, "_POL"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "BatteriesIncluded.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { - if (lang_type == LANGUAGE_ENGLISH) { - mprintf(0, "ERROR: Could not load message file - %s\n", filename); - } else if (!ReadMessageFile(english_filename)) { - mprintf(0, "ERROR: Could not load message file - %s\n", english_filename); - } + mprintf(0, "ERROR: Could not load message file - %s\n", filename); } int j; @@ -812,10 +616,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } @@ -1351,7 +1151,7 @@ int16_t TriggerScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 003: Chris'Office if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[0], event_data->it_handle); + aShowHUDMessageObj(TXT("Chris"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -1370,7 +1170,7 @@ int16_t TriggerScript_0003::CallEvent(int event, tOSIRISEventInfo *data) { // Script 004: Kevin's Office if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[1], event_data->it_handle); + aShowHUDMessageObj(TXT("Kevin"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -1389,7 +1189,7 @@ int16_t TriggerScript_0001::CallEvent(int event, tOSIRISEventInfo *data) { // Script 006: Jeff & Nate's Office 2 if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[2], event_data->it_handle); + aShowHUDMessageObj(TXT("JeffNate"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -1408,7 +1208,7 @@ int16_t TriggerScript_0002::CallEvent(int event, tOSIRISEventInfo *data) { // Script 005: Jeff & Nate's Office if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[2], event_data->it_handle); + aShowHUDMessageObj(TXT("JeffNate"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -1427,7 +1227,7 @@ int16_t TriggerScript_0005::CallEvent(int event, tOSIRISEventInfo *data) { // Script 007: Matt's Office if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[3], event_data->it_handle); + aShowHUDMessageObj(TXT("Matt"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -1446,7 +1246,7 @@ int16_t TriggerScript_001C::CallEvent(int event, tOSIRISEventInfo *data) { // Script 029: Jay's Office 4 if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[4], event_data->it_handle); + aShowHUDMessageObj(TXT("Jay"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -1465,7 +1265,7 @@ int16_t TriggerScript_001B::CallEvent(int event, tOSIRISEventInfo *data) { // Script 028: Jay's Office 3 if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[4], event_data->it_handle); + aShowHUDMessageObj(TXT("Jay"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -1484,7 +1284,7 @@ int16_t TriggerScript_001A::CallEvent(int event, tOSIRISEventInfo *data) { // Script 027: Jay's Office 2 if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[4], event_data->it_handle); + aShowHUDMessageObj(TXT("Jay"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -1503,7 +1303,7 @@ int16_t TriggerScript_0019::CallEvent(int event, tOSIRISEventInfo *data) { // Script 026: Jay's Office if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[4], event_data->it_handle); + aShowHUDMessageObj(TXT("Jay"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -1522,7 +1322,7 @@ int16_t TriggerScript_0018::CallEvent(int event, tOSIRISEventInfo *data) { // Script 025: Jerry's Office 2 if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[5], event_data->it_handle); + aShowHUDMessageObj(TXT("Jerry"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -1541,7 +1341,7 @@ int16_t TriggerScript_0017::CallEvent(int event, tOSIRISEventInfo *data) { // Script 024: Jerry's Office if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[5], event_data->it_handle); + aShowHUDMessageObj(TXT("Jerry"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -1560,7 +1360,7 @@ int16_t TriggerScript_0016::CallEvent(int event, tOSIRISEventInfo *data) { // Script 023: Long's Office if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[6], event_data->it_handle); + aShowHUDMessageObj(TXT("Long"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -1579,7 +1379,7 @@ int16_t TriggerScript_0015::CallEvent(int event, tOSIRISEventInfo *data) { // Script 022: Andy's Lab 4 if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[7], event_data->it_handle); + aShowHUDMessageObj(TXT("Andy"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -1598,7 +1398,7 @@ int16_t TriggerScript_0014::CallEvent(int event, tOSIRISEventInfo *data) { // Script 021: Andy's Lab 3 if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[7], event_data->it_handle); + aShowHUDMessageObj(TXT("Andy"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -1617,7 +1417,7 @@ int16_t TriggerScript_0013::CallEvent(int event, tOSIRISEventInfo *data) { // Script 020: Andy's Lab 2 if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[7], event_data->it_handle); + aShowHUDMessageObj(TXT("Andy"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -1636,7 +1436,7 @@ int16_t TriggerScript_0012::CallEvent(int event, tOSIRISEventInfo *data) { // Script 019: Andy's Lab if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[7], event_data->it_handle); + aShowHUDMessageObj(TXT("Andy"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -1655,7 +1455,7 @@ int16_t TriggerScript_0011::CallEvent(int event, tOSIRISEventInfo *data) { // Script 018: Claflin's Office 2 if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[8], event_data->it_handle); + aShowHUDMessageObj(TXT("Claflin"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -1674,7 +1474,7 @@ int16_t TriggerScript_0010::CallEvent(int event, tOSIRISEventInfo *data) { // Script 017: Claflin's Office if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[8], event_data->it_handle); + aShowHUDMessageObj(TXT("Claflin"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -1693,7 +1493,7 @@ int16_t TriggerScript_000E::CallEvent(int event, tOSIRISEventInfo *data) { // Script 016: Mea's Office if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[9], event_data->it_handle); + aShowHUDMessageObj(TXT("Mea"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -1712,7 +1512,7 @@ int16_t TriggerScript_000D::CallEvent(int event, tOSIRISEventInfo *data) { // Script 015: Luke & Josh's Office 3 if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[10], event_data->it_handle); + aShowHUDMessageObj(TXT("LukeJosh"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -1731,7 +1531,7 @@ int16_t TriggerScript_000C::CallEvent(int event, tOSIRISEventInfo *data) { // Script 014: Luke & Josh's Office 2 if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[10], event_data->it_handle); + aShowHUDMessageObj(TXT("LukeJosh"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -1750,7 +1550,7 @@ int16_t TriggerScript_0025::CallEvent(int event, tOSIRISEventInfo *data) { // Script 039: Interplay Lab 3 if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[11], event_data->it_handle); + aShowHUDMessageObj(TXT("Interplay"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -1769,7 +1569,7 @@ int16_t TriggerScript_0024::CallEvent(int event, tOSIRISEventInfo *data) { // Script 038: Interplay Lab 2 if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[11], event_data->it_handle); + aShowHUDMessageObj(TXT("Interplay"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -1788,7 +1588,7 @@ int16_t TriggerScript_0023::CallEvent(int event, tOSIRISEventInfo *data) { // Script 037: Interplay Lab if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[11], event_data->it_handle); + aShowHUDMessageObj(TXT("Interplay"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -1807,7 +1607,7 @@ int16_t TriggerScript_000B::CallEvent(int event, tOSIRISEventInfo *data) { // Script 013: Luke & Josh's Office if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[10], event_data->it_handle); + aShowHUDMessageObj(TXT("LukeJosh"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -1826,7 +1626,7 @@ int16_t TriggerScript_000A::CallEvent(int event, tOSIRISEventInfo *data) { // Script 012: Hayes' Office if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[12], event_data->it_handle); + aShowHUDMessageObj(TXT("Hayes"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -1845,7 +1645,7 @@ int16_t TriggerScript_0009::CallEvent(int event, tOSIRISEventInfo *data) { // Script 011: Sean's Office if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[13], event_data->it_handle); + aShowHUDMessageObj(TXT("Sean"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -1864,7 +1664,7 @@ int16_t TriggerScript_0008::CallEvent(int event, tOSIRISEventInfo *data) { // Script 010: Doug's Office 2 if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[14], event_data->it_handle); + aShowHUDMessageObj(TXT("Doug"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -1883,7 +1683,7 @@ int16_t TriggerScript_0007::CallEvent(int event, tOSIRISEventInfo *data) { // Script 009: Doug's Office if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[14], event_data->it_handle); + aShowHUDMessageObj(TXT("Doug"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -1902,7 +1702,7 @@ int16_t TriggerScript_0006::CallEvent(int event, tOSIRISEventInfo *data) { // Script 008: Samir's Office if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[15], event_data->it_handle); + aShowHUDMessageObj(TXT("Samir"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -2029,7 +1829,7 @@ int16_t TriggerScript_0004::CallEvent(int event, tOSIRISEventInfo *data) { // Script 002: Mark's Office if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[16], event_data->it_handle); + aShowHUDMessageObj(TXT("Mark"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); // Increment the script action counter diff --git a/scripts/BossCamera.cpp b/scripts/BossCamera.cpp index 4c467cd60..4cd28b831 100644 --- a/scripts/BossCamera.cpp +++ b/scripts/BossCamera.cpp @@ -22,10 +22,10 @@ // Filename: BossCamera.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -111,185 +111,6 @@ void RestoreGlobalActionCtrs(void *file_ptr) { ScriptActionCtr_000 = File_ReadIn // End of Custom Script Block - DO NOT EDIT ANYTHING AFTER THIS // ============================================================ -// ================= -// Message File Data -// ================= - -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - -// Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} - -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} - //====================== // Name List Arrays //====================== @@ -332,9 +153,12 @@ int *Matcen_indexes = NULL; const char **Goal_names = NULL; int *Goal_indexes = NULL; -#define NUM_MESSAGE_NAMES 1 -const char *Message_names[NUM_MESSAGE_NAMES] = {"Message2"}; -const char *Message_strings[NUM_MESSAGE_NAMES]; +// Global storage for level script messages +std::map Messages; + +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) // =============== // InitializeDLL() @@ -349,26 +173,16 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "BossCamera.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { mprintf(0, "ERROR: Could not load message file - %s\n", filename); @@ -415,10 +229,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } @@ -555,7 +365,7 @@ int16_t TriggerScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 000: Script Description Goes Here if (qObjIsPlayer(event_data->it_handle) == true) { - aCinematicSimple(Path_indexes[0], Message_strings[0], Object_handles[0], 10.000000f, 1); + aCinematicSimple(Path_indexes[0], TXT("Message2"), Object_handles[0], 10.000000f, 1); // Increment the script action counter if (ScriptActionCtr_000 < MAX_ACTION_CTR_VALUE) diff --git a/scripts/CanyonsCTF.cpp b/scripts/CanyonsCTF.cpp index bc53160a0..20b724e0c 100644 --- a/scripts/CanyonsCTF.cpp +++ b/scripts/CanyonsCTF.cpp @@ -22,10 +22,10 @@ // Filename: CanyonsCTF.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -102,185 +102,6 @@ void RestoreGlobalActionCtrs(void *file_ptr) {} // End of Custom Script Block - DO NOT EDIT ANYTHING AFTER THIS // ============================================================ -// ================= -// Message File Data -// ================= - -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - -// Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} - -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} - //====================== // Name List Arrays //====================== @@ -323,9 +144,12 @@ int *Matcen_indexes = NULL; const char **Goal_names = NULL; int *Goal_indexes = NULL; -#define NUM_MESSAGE_NAMES 0 -const char **Message_names = NULL; -const char **Message_strings = NULL; +// Global storage for level script messages +std::map Messages; + +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) // =============== // InitializeDLL() @@ -340,26 +164,16 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "CanyonsCTF.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { mprintf(0, "ERROR: Could not load message file - %s\n", filename); @@ -406,10 +220,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } diff --git a/scripts/CellTestLevel.cpp b/scripts/CellTestLevel.cpp index 6d8628e69..ff713116c 100644 --- a/scripts/CellTestLevel.cpp +++ b/scripts/CellTestLevel.cpp @@ -22,10 +22,10 @@ // Filename: CellTestLevel.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -108,180 +108,12 @@ void RestoreGlobalActionCtrs(void *file_ptr) { ScriptActionCtr_000 = File_ReadIn // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} +std::map Messages; -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -342,26 +174,16 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "CellTestLevel.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { mprintf(0, "ERROR: Could not load message file - %s\n", filename); @@ -408,10 +230,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } diff --git a/scripts/ChrisTest.cpp b/scripts/ChrisTest.cpp index 4fce894a9..cea2e619f 100644 --- a/scripts/ChrisTest.cpp +++ b/scripts/ChrisTest.cpp @@ -22,10 +22,10 @@ // Filename: Train03.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -133,180 +133,12 @@ void RestoreGlobalActionCtrs(void *file_ptr) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} +std::map Messages; -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -350,10 +182,6 @@ int Matcen_indexes[NUM_MATCEN_NAMES]; const char **Goal_names = NULL; int *Goal_indexes = NULL; -#define NUM_MESSAGE_NAMES 0 -const char **Message_names = NULL; -const char **Message_strings = NULL; - // =============== // InitializeDLL() // =============== @@ -367,26 +195,16 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "Train03.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { mprintf(0, "ERROR: Could not load message file - %s\n", filename); @@ -433,10 +251,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } diff --git a/scripts/Geodomes.cpp b/scripts/Geodomes.cpp index 2802bed7b..68a4dcfc9 100644 --- a/scripts/Geodomes.cpp +++ b/scripts/Geodomes.cpp @@ -22,10 +22,10 @@ // Filename: Geodomes.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -159,180 +159,12 @@ void RestoreGlobalActionCtrs(void *file_ptr) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} +std::map Messages; -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -376,10 +208,6 @@ int *Matcen_indexes = NULL; const char **Goal_names = NULL; int *Goal_indexes = NULL; -#define NUM_MESSAGE_NAMES 0 -const char **Message_names = NULL; -const char **Message_strings = NULL; - // =============== // InitializeDLL() // =============== @@ -393,26 +221,16 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "Geodomes.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { mprintf(0, "ERROR: Could not load message file - %s\n", filename); @@ -459,10 +277,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } diff --git a/scripts/HalfPipe.cpp b/scripts/HalfPipe.cpp index a7cffd385..d779848de 100644 --- a/scripts/HalfPipe.cpp +++ b/scripts/HalfPipe.cpp @@ -22,10 +22,10 @@ // Filename: HalfPipe5.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -155,180 +155,12 @@ void RestoreGlobalActionCtrs(void *file_ptr) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} +std::map Messages; -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -372,10 +204,6 @@ int *Matcen_indexes = NULL; const char **Goal_names = NULL; int *Goal_indexes = NULL; -#define NUM_MESSAGE_NAMES 0 -const char **Message_names = NULL; -const char **Message_strings = NULL; - // =============== // InitializeDLL() // =============== @@ -389,26 +217,16 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "HalfPipe5.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { mprintf(0, "ERROR: Could not load message file - %s\n", filename); @@ -455,10 +273,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } diff --git a/scripts/HalfPipe_Ger.msg b/scripts/HalfPipe_Ger.msg deleted file mode 100644 index 9ad5f0791..000000000 --- a/scripts/HalfPipe_Ger.msg +++ /dev/null @@ -1,7 +0,0 @@ -////////////////////////////////////////////// -// D.A.L.L.A.S. Generated Message Table File -////////////////////////////////////////////// - -NEXT_MESSAGE_ID_NUMBER 1 - -// Message List diff --git a/scripts/InfernalBolt.cpp b/scripts/InfernalBolt.cpp index f9ff47c66..85283de2c 100644 --- a/scripts/InfernalBolt.cpp +++ b/scripts/InfernalBolt.cpp @@ -22,10 +22,10 @@ // Filename: InfernalBolt5.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -164,180 +164,12 @@ void RestoreGlobalActionCtrs(void *file_ptr) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} +std::map Messages; -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -382,10 +214,6 @@ int *Matcen_indexes = NULL; const char **Goal_names = NULL; int *Goal_indexes = NULL; -#define NUM_MESSAGE_NAMES 0 -const char **Message_names = NULL; -const char **Message_strings = NULL; - // =============== // InitializeDLL() // =============== @@ -399,7 +227,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; @@ -407,14 +234,7 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { if (func_list->script_identifier != NULL) { _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "InfernalBolt5.msg"); @@ -465,10 +285,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } diff --git a/scripts/InfernalBolt_Ger.msg b/scripts/InfernalBolt_Ger.msg deleted file mode 100644 index 9ad5f0791..000000000 --- a/scripts/InfernalBolt_Ger.msg +++ /dev/null @@ -1,7 +0,0 @@ -////////////////////////////////////////////// -// D.A.L.L.A.S. Generated Message Table File -////////////////////////////////////////////// - -NEXT_MESSAGE_ID_NUMBER 1 - -// Message List diff --git a/scripts/Inversion.cpp b/scripts/Inversion.cpp index 0864847ee..14f415e34 100644 --- a/scripts/Inversion.cpp +++ b/scripts/Inversion.cpp @@ -22,10 +22,10 @@ // Filename: Invasion.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -396,180 +396,12 @@ void RestoreGlobalActionCtrs(void *file_ptr) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} +std::map Messages; -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -616,10 +448,6 @@ int *Matcen_indexes = NULL; const char **Goal_names = NULL; int *Goal_indexes = NULL; -#define NUM_MESSAGE_NAMES 0 -const char **Message_names = NULL; -const char **Message_strings = NULL; - // =============== // InitializeDLL() // =============== @@ -633,7 +461,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; @@ -641,14 +468,7 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { if (func_list->script_identifier != NULL) { _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "Invasion.msg"); @@ -699,10 +519,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } diff --git a/scripts/LEVEL0.cpp b/scripts/LEVEL0.cpp index 71319b99a..cdc25dfb0 100644 --- a/scripts/LEVEL0.cpp +++ b/scripts/LEVEL0.cpp @@ -22,10 +22,10 @@ // Filename: LEVEL0.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -380,180 +380,12 @@ void RestoreGlobalActionCtrs(void *file_ptr) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} +std::map Messages; -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -625,20 +457,6 @@ const char *Goal_names[NUM_GOAL_NAMES] = {"Deactivate the Containment Forcefield "Find the Main Data Retention Complex"}; int Goal_indexes[NUM_GOAL_NAMES]; -#define NUM_MESSAGE_NAMES 21 -const char *Message_names[NUM_MESSAGE_NAMES] = {"FirstForcefield", "ClassifiedAccessPass", - "LeftConsoleSwitch", "RightConsoleSwitch", - "PrimaryLoginSwitch", "EndLevel", - "AccessDenied", "CEDData", - "ShipMessageLog", "BossData", - "PTMCdisconnected", "DravisData", - "SRADLabData", "ConsoleCrash", - "SweitzerData", "SecurityAlert", - "LockDown", "MDData", - "SingleFireSwitch", "BothFireSwitches", - "IntroMessage"}; -const char *Message_strings[NUM_MESSAGE_NAMES]; - // =============== // InitializeDLL() // =============== @@ -652,7 +470,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; @@ -705,10 +522,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } @@ -1096,7 +909,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 029: IntroCam if (1) { - aCinematicIntro(Path_indexes[2], Message_strings[20], Object_handles[2], Path_indexes[3], 12.000000f); + aCinematicIntro(Path_indexes[2], TXT("IntroMessage"), Object_handles[2], Path_indexes[3], 12.000000f); // Increment the script action counter if (ScriptActionCtr_029 < MAX_ACTION_CTR_VALUE) @@ -1138,19 +951,19 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 015: Left Console Level Timers if (1) { if (event_data->id == 4) { - aAddGameMessage(Message_strings[7], Message_strings[8]); + aAddGameMessage(TXT("CEDData"), TXT("ShipMessageLog")); aRoomSetFaceTexture(Room_indexes[1], 148, Texture_indexes[1]); aObjPlayAnim(Object_handles[15], 7, 15, 3.000000f, 0); aSetLevelTimer(6.000000f, 8); } if (event_data->id == 8) { - aAddGameMessage(Message_strings[9], Message_strings[8]); + aAddGameMessage(TXT("BossData"), TXT("ShipMessageLog")); aRoomSetFaceTexture(Room_indexes[1], 148, Texture_indexes[2]); aObjPlayAnim(Object_handles[15], 15, 22, 4.000000f, 0); aSetLevelTimer(4.000000f, 9); } if (event_data->id == 9) { - aShowHUDMessage(Message_strings[10]); + aShowHUDMessage(TXT("PTMCdisconnected")); aRoomSetFaceTexture(Room_indexes[1], 148, Texture_indexes[3]); } @@ -1162,19 +975,19 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 014: Right Console Level Timers if (1) { if (event_data->id == 3) { - aAddGameMessage(Message_strings[11], Message_strings[8]); + aAddGameMessage(TXT("DravisData"), TXT("ShipMessageLog")); aRoomSetFaceTexture(Room_indexes[2], 148, Texture_indexes[4]); aObjPlayAnim(Object_handles[17], 7, 15, 3.000000f, 0); aSetLevelTimer(6.000000f, 5); } if (event_data->id == 5) { - aAddGameMessage(Message_strings[12], Message_strings[8]); + aAddGameMessage(TXT("SRADLabData"), TXT("ShipMessageLog")); aRoomSetFaceTexture(Room_indexes[2], 148, Texture_indexes[5]); aObjPlayAnim(Object_handles[17], 15, 22, 4.000000f, 0); aSetLevelTimer(4.000000f, 6); } if (event_data->id == 6) { - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("ConsoleCrash")); aRoomSetFaceTexture(Room_indexes[2], 148, Texture_indexes[6]); } @@ -1186,19 +999,19 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 007: Primary Console Timers if (1) { if (event_data->id == 0) { - aAddGameMessage(Message_strings[14], Message_strings[8]); + aAddGameMessage(TXT("SweitzerData"), TXT("ShipMessageLog")); aRoomSetFaceTexture(Room_indexes[3], 148, Texture_indexes[7]); aObjPlayAnim(Object_handles[19], 7, 15, 3.000000f, 0); aSetLevelTimer(6.000000f, 1); } if (event_data->id == 7) { - aShowHUDMessage(Message_strings[15]); + aShowHUDMessage(TXT("SecurityAlert")); aRoomSetFaceTexture(Room_indexes[3], 148, Texture_indexes[8]); aObjPlayAnim(Object_handles[19], 15, 22, 4.000000f, 0); aSetLevelTimer(4.000000f, 2); } if (event_data->id == 2) { - aShowHUDMessage(Message_strings[16]); + aShowHUDMessage(TXT("LockDown")); aRoomSetFaceTexture(Room_indexes[3], 148, Texture_indexes[9]); aMatcenSetEnableState(1, Matcen_indexes[0]); aMatcenSetState(1, Matcen_indexes[0]); @@ -1210,7 +1023,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aObjPlayAnim(Object_handles[19], 0, 7, 3.000000f, 0); aSetLevelTimer(6.000000f, 7); aRoomSetFaceTexture(Room_indexes[3], 148, Texture_indexes[10]); - aAddGameMessage(Message_strings[17], Message_strings[8]); + aAddGameMessage(TXT("MDData"), TXT("ShipMessageLog")); } // Increment the script action counter @@ -1233,7 +1046,7 @@ int16_t CustomObjectScript_3855::CallEvent(int event, tOSIRISEventInfo *data) { aGoalCompleted(Goal_indexes[0], 1); aObjPlayAnim(Object_handles[0], 0, 4, 2.000000f, 0); aPortalRenderSet(0, 1, Room_indexes[0], 1); - aShowHUDMessage(Message_strings[0]); + aShowHUDMessage(TXT("FirstForcefield")); aUserFlagSet(0, 0); } else { } @@ -1255,7 +1068,7 @@ int16_t CustomObjectScript_10DC::CallEvent(int event, tOSIRISEventInfo *data) { // Script 003: Restricted Access Passkey if (qObjIsPlayer(event_data->it_handle) == true) { aGoalCompleted(Goal_indexes[1], 1); - aObjectPlayerGiveKey(event_data->it_handle, Object_handles[13], 1, Message_strings[1], 1); + aObjectPlayerGiveKey(event_data->it_handle, Object_handles[13], 1, TXT("ClassifiedAccessPass"), 1); // Increment the script action counter if (ScriptActionCtr_003 < MAX_ACTION_CTR_VALUE) @@ -1277,7 +1090,7 @@ int16_t CustomObjectScript_10E0::CallEvent(int event, tOSIRISEventInfo *data) { aUserFlagSet(5, 1); aObjPlayAnim(Object_handles[14], 0, 7, 4.000000f, 0); aRoomSetFaceTexture(Room_indexes[1], 148, Texture_indexes[0]); - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("LeftConsoleSwitch")); aObjPlayAnim(Object_handles[15], 0, 7, 3.000000f, 0); aSetLevelTimer(6.000000f, 4); } else { @@ -1303,7 +1116,7 @@ int16_t CustomObjectScript_10DF::CallEvent(int event, tOSIRISEventInfo *data) { aUserFlagSet(4, 1); aObjPlayAnim(Object_handles[16], 0, 7, 4.000000f, 0); aRoomSetFaceTexture(Room_indexes[2], 148, Texture_indexes[0]); - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("RightConsoleSwitch")); aObjPlayAnim(Object_handles[17], 0, 7, 3.000000f, 0); aSetLevelTimer(6.000000f, 3); } else { @@ -1333,7 +1146,7 @@ int16_t CustomObjectScript_08E8::CallEvent(int event, tOSIRISEventInfo *data) { aUserFlagSet(1, 1); aObjPlayAnim(Object_handles[18], 0, 7, 4.000000f, 0); aRoomSetFaceTexture(Room_indexes[3], 148, Texture_indexes[0]); - aShowHUDMessage(Message_strings[4]); + aShowHUDMessage(TXT("PrimaryLoginSwitch")); aObjPlayAnim(Object_handles[19], 0, 7, 3.000000f, 0); aSetLevelTimer(6.000000f, 0); } else { @@ -1358,7 +1171,7 @@ int16_t CustomObjectScript_584D::CallEvent(int event, tOSIRISEventInfo *data) { ((qObjIsPlayer(event_data->it_handle) == true) && ((ScriptActionCtr_005 > 0) == false))) { aGoalCompleted(Goal_indexes[4], 1); aObjDestroy(Object_handles[20]); - aStartEndlevelSequencePath(Path_indexes[0], Path_indexes[1], 10.000000f, Message_strings[5]); + aStartEndlevelSequencePath(Path_indexes[0], Path_indexes[1], 10.000000f, TXT("EndLevel")); // Increment the script action counter if (ScriptActionCtr_031 < MAX_ACTION_CTR_VALUE) @@ -1377,7 +1190,7 @@ int16_t CustomObjectScript_0816::CallEvent(int event, tOSIRISEventInfo *data) { // Script 006: Restricted Access Door Locked if (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) { if ((ScriptActionCtr_003 > 0) == false) { - aShowHUDMessageI(Message_strings[6], 0); + aShowHUDMessageI(TXT("AccessDenied"), 0); } // Increment the script action counter @@ -1399,7 +1212,7 @@ int16_t CustomObjectScript_301B::CallEvent(int event, tOSIRISEventInfo *data) { if (qUserFlag(3) == false) { aObjPlayAnim(Object_handles[22], 0, 4, 2.000000f, 0); aUserFlagSet(3, 1); - aShowHUDMessage(Message_strings[18]); + aShowHUDMessage(TXT("SingleFireSwitch")); } if ((qUserFlag(2) == true) && (qUserFlag(3) == true)) { aTurnOffSpew(6); @@ -1410,7 +1223,7 @@ int16_t CustomObjectScript_301B::CallEvent(int event, tOSIRISEventInfo *data) { aRoomChangeFog(Room_indexes[8], 1.000000f, 0.700000f, 0.400000f, 1000.000000f, 20.000000f); aRoomSetDamage(Room_indexes[7], 0.000000f, 0); aRoomSetDamage(Room_indexes[8], 0.000000f, 0); - aShowHUDMessage(Message_strings[19]); + aShowHUDMessage(TXT("BothFireSwitches")); } else { } @@ -1433,7 +1246,7 @@ int16_t CustomObjectScript_18DB::CallEvent(int event, tOSIRISEventInfo *data) { if (qUserFlag(2) == false) { aObjPlayAnim(Object_handles[23], 0, 4, 2.000000f, 0); aUserFlagSet(2, 1); - aShowHUDMessage(Message_strings[18]); + aShowHUDMessage(TXT("SingleFireSwitch")); } if ((qUserFlag(2) == true) && (qUserFlag(3) == true)) { aTurnOffSpew(6); @@ -1443,7 +1256,7 @@ int16_t CustomObjectScript_18DB::CallEvent(int event, tOSIRISEventInfo *data) { aRoomChangeFog(Room_indexes[7], 1.000000f, 0.700000f, 0.400000f, 1000.000000f, 20.000000f); aRoomChangeFog(Room_indexes[8], 1.000000f, 0.700000f, 0.400000f, 1000.000000f, 20.000000f); aRoomSetDamage(Room_indexes[7], 0.000000f, 0); - aShowHUDMessage(Message_strings[19]); + aShowHUDMessage(TXT("BothFireSwitches")); aRoomSetDamage(Room_indexes[8], 0.000000f, 0); } else { } @@ -1467,7 +1280,7 @@ int16_t TriggerScript_000C::CallEvent(int event, tOSIRISEventInfo *data) { ((qObjIsPlayer(event_data->it_handle) == true) && ((ScriptActionCtr_031 > 0) == false))) { aGoalCompleted(Goal_indexes[4], 1); aObjDestroy(Object_handles[20]); - aStartEndlevelSequencePath(Path_indexes[0], Path_indexes[1], 10.000000f, Message_strings[5]); + aStartEndlevelSequencePath(Path_indexes[0], Path_indexes[1], 10.000000f, TXT("EndLevel")); // Increment the script action counter if (ScriptActionCtr_005 < MAX_ACTION_CTR_VALUE) diff --git a/scripts/LEVEL15.cpp b/scripts/LEVEL15.cpp index a16fe9859..3b3fcc8e6 100644 --- a/scripts/LEVEL15.cpp +++ b/scripts/LEVEL15.cpp @@ -22,10 +22,10 @@ // Filename: Level15.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -769,7 +769,8 @@ void RestoreGlobalActionCtrs(void *file_ptr) { $$END */ -const char *GetMessage(const char *name); +void aUserFlagSet(int flagnum, bool state); +bool qUserFlag(int flagnum); #define MatCenSwitchAON 0 #define MatCenSwitchBON 1 @@ -863,6 +864,17 @@ tMyMessage MyMessages[] = {{"MagicMatCenSwitches", NULL}, {"MatCenSwitchDOn", NU {"MatCenSwitchBOn", NULL}, {"MatCenSwitchBOff", NULL}, {"MatCenSwitchFOn", NULL}, {"MatCenSwitchFOff", NULL}, {"MatCenSwitchAOn", NULL}, {"MatCenSwitchAOff", NULL}}; +// ================= +// Message File Data +// ================= + +// Global storage for level script messages +std::map Messages; + +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) + int GetMyMatCen(int id) { if (MyMatcens[id].handle == -1) MyMatcens[id].handle = Scrpt_FindMatcenName(MyMatcens[id].name); @@ -886,7 +898,7 @@ int GetMyRoom(int id) { const char *GetMyMessage(int id) { if (MyMessages[id].mem == NULL) - MyMessages[id].mem = GetMessage(MyMessages[id].name); + MyMessages[id].mem = TXT(MyMessages[id].name); return MyMessages[id].mem; } @@ -1447,185 +1459,6 @@ void aMatCenPuzzleSwitchG(int Player) { // End of Custom Script Block - DO NOT EDIT ANYTHING AFTER THIS // ============================================================ -// ================= -// Message File Data -// ================= - -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - -// Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} - -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} - //====================== // Name List Arrays //====================== @@ -1726,31 +1559,6 @@ const char *Goal_names[NUM_GOAL_NAMES] = {"Locate the Inner Stronghold Passkey", "Locate Dravis' secret stronghold"}; int Goal_indexes[NUM_GOAL_NAMES]; -#define NUM_MESSAGE_NAMES 22 -const char *Message_names[NUM_MESSAGE_NAMES] = {"InnerDoorsUnlock", - "InnerStrongholdKey", - "LeftLavaCrank", - "CenterLavaCrank", - "RightLavaCrank", - "EnergyCentersOnline", - "PowerRestored", - "FuseFound", - "ReactorBroken", - "EnergyCenterBroken", - "InnerDoorsDenied", - "TNTDispenserCenter", - "TNTDispenserRight", - "TNTDispenserLeft", - "TNTDispenserLeftBroken", - "TNTRockwalldestroyed", - "TNTRockWall", - "DravisDoor", - "End", - "IntroCameraText", - "BLANK", - "HellionIntroduction"}; -const char *Message_strings[NUM_MESSAGE_NAMES]; - // =============== // InitializeDLL() // =============== @@ -1766,26 +1574,16 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(uservars_as_int); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "Level15.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { mprintf(0, "ERROR: Could not load message file - %s\n", filename); @@ -1832,10 +1630,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } @@ -2612,7 +2406,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 052: Intro Camera if (1) { - aCinematicIntro(Path_indexes[7], Message_strings[19], Object_handles[32], Path_indexes[8], 8.000000f); + aCinematicIntro(Path_indexes[7], TXT("IntroCameraText"), Object_handles[32], Path_indexes[8], 8.000000f); aSoundPlaySteaming("VoxL15StartLevel.osf", 1.000000f); // Increment the script action counter @@ -2664,7 +2458,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 053: Energy Centers Repaired Timer if (event_data->id == 2) { - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("EnergyCentersOnline")); // Increment the script action counter if (ScriptActionCtr_053 < MAX_ACTION_CTR_VALUE) @@ -2708,7 +2502,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 079: Pre-Boss Cinematic Finished if (qUserFlag(19) == true) { aUserFlagSet(19, 0); - aCinematicSimple(Path_indexes[11], Message_strings[21], Object_handles[32], 12.000000f, 1); + aCinematicSimple(Path_indexes[11], TXT("HellionIntroduction"), Object_handles[32], 12.000000f, 1); // Increment the script action counter if (ScriptActionCtr_079 < MAX_ACTION_CTR_VALUE) @@ -2726,9 +2520,9 @@ int16_t CustomObjectScript_10FD::CallEvent(int event, tOSIRISEventInfo *data) { // Script 000: Inner Stronghold Passkey if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[0]); + aShowHUDMessage(TXT("InnerDoorsUnlock")); aCreatePopupView(0, Object_handles[1], 10.000000f, 1.000000f); - aObjectPlayerGiveKey(event_data->it_handle, Object_handles[0], 1, Message_strings[1], 0); + aObjectPlayerGiveKey(event_data->it_handle, Object_handles[0], 1, TXT("InnerStrongholdKey"), 0); aGoalCompleted(Goal_indexes[0], 1); // Increment the script action counter @@ -2749,7 +2543,7 @@ int16_t CustomObjectScript_084D::CallEvent(int event, tOSIRISEventInfo *data) { if ((qObjIsPlayerWeapon(event_data->it_handle) == true) && (qUserFlag(7) == false)) { aAIGoalFollowPath(Object_handles[2], Path_indexes[0], 1, 2, 1, 3, 19005696, -1); aObjPlayAnim(Object_handles[5], 0, 20, 2.000000f, 0); - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("LeftLavaCrank")); aUserFlagSet(7, 1); aDoorSetPos(Door_handles[1], 1.000000f); @@ -2771,7 +2565,7 @@ int16_t CustomObjectScript_084E::CallEvent(int event, tOSIRISEventInfo *data) { if ((qObjIsPlayerWeapon(event_data->it_handle) == true) && (qUserFlag(8) == false)) { aAIGoalFollowPath(Object_handles[4], Path_indexes[2], 1, 2, 1, 3, 19005696, -1); aObjPlayAnim(Object_handles[6], 0, 20, 2.000000f, 0); - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("CenterLavaCrank")); aUserFlagSet(8, 1); aDoorSetPos(Door_handles[2], 1.000000f); @@ -2793,7 +2587,7 @@ int16_t CustomObjectScript_084F::CallEvent(int event, tOSIRISEventInfo *data) { if ((qObjIsPlayerWeapon(event_data->it_handle) == true) && (qUserFlag(9) == false)) { aAIGoalFollowPath(Object_handles[3], Path_indexes[1], 1, 2, 1, 3, 19005696, -1); aObjPlayAnim(Object_handles[7], 0, 20, 2.000000f, 0); - aShowHUDMessage(Message_strings[4]); + aShowHUDMessage(TXT("RightLavaCrank")); aUserFlagSet(9, 1); aDoorSetPos(Door_handles[0], 1.000000f); @@ -2815,7 +2609,7 @@ int16_t CustomObjectScript_084C::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_003 < 1) && ((qObjIsPlayerWeapon(event_data->it_handle) == true) && (qObjExists(Object_handles[9]) == false))) { aObjPlayAnim(Object_handles[8], 0, 20, 2.000000f, 0); - aShowHUDMessage(Message_strings[6]); + aShowHUDMessage(TXT("PowerRestored")); aRoomSetLightingStrobe(0, Room_indexes[0]); aRoomSetFuelcen(1, Room_indexes[0]); aRoomSetLightingFlicker(0, Room_indexes[1]); @@ -2839,7 +2633,7 @@ int16_t CustomObjectScript_084C::CallEvent(int event, tOSIRISEventInfo *data) { // Script 005: Backup Reactor Broken if ((qObjIsPlayerWeapon(event_data->it_handle) == true) && (qObjExists(Object_handles[9]) == true)) { - aShowHUDMessage(Message_strings[8]); + aShowHUDMessage(TXT("ReactorBroken")); aGoalEnableDisable(1, Goal_indexes[3]); aGoalEnableDisable(1, Goal_indexes[1]); @@ -2861,7 +2655,7 @@ int16_t CustomObjectScript_1913::CallEvent(int event, tOSIRISEventInfo *data) { if (qObjIsPlayer(event_data->it_handle) == true) { aObjDelete(Object_handles[9]); aGoalEnableDisable(1, Goal_indexes[2]); - aShowHUDMessage(Message_strings[7]); + aShowHUDMessage(TXT("FuseFound")); aGoalCompleted(Goal_indexes[3], 1); // Increment the script action counter @@ -3103,7 +2897,7 @@ int16_t CustomObjectScript_2801::CallEvent(int event, tOSIRISEventInfo *data) { // Script 033: Inner Stronghold Door E if ((qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) && (qDoorOpenable(data->me_handle, event_data->it_handle) == false)) { - aShowHUDMessage(Message_strings[10]); + aShowHUDMessage(TXT("InnerDoorsDenied")); if (qUserFlag(13) == false) { aUserFlagSet(13, 1); aGoalEnableDisable(1, Goal_indexes[0]); @@ -3126,7 +2920,7 @@ int16_t CustomObjectScript_1828::CallEvent(int event, tOSIRISEventInfo *data) { // Script 032: Inner Stronghold Door D if ((qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) && (qDoorOpenable(data->me_handle, event_data->it_handle) == false)) { - aShowHUDMessage(Message_strings[10]); + aShowHUDMessage(TXT("InnerDoorsDenied")); if (qUserFlag(13) == false) { aUserFlagSet(13, 1); aGoalEnableDisable(1, Goal_indexes[0]); @@ -3149,7 +2943,7 @@ int16_t CustomObjectScript_1015::CallEvent(int event, tOSIRISEventInfo *data) { // Script 031: Inner Stronghold Door C if ((qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) && (qDoorOpenable(data->me_handle, event_data->it_handle) == false)) { - aShowHUDMessage(Message_strings[10]); + aShowHUDMessage(TXT("InnerDoorsDenied")); if (qUserFlag(13) == false) { aUserFlagSet(13, 1); aGoalEnableDisable(1, Goal_indexes[0]); @@ -3173,7 +2967,7 @@ int16_t CustomObjectScript_0848::CallEvent(int event, tOSIRISEventInfo *data) { if (qObjIsPlayerWeapon(event_data->it_handle) == true) { if (qUserFlag(16) == false) { aObjPlayAnim(Object_handles[27], 0, 10, 1.000000f, 0); - aShowHUDMessage(Message_strings[11]); + aShowHUDMessage(TXT("TNTDispenserCenter")); aMatcenSetState(1, Matcen_indexes[0]); aUserFlagSet(16, 1); aSetObjectTimer(Object_handles[27], 1.000000f, 1); @@ -3212,7 +3006,7 @@ int16_t CustomObjectScript_0849::CallEvent(int event, tOSIRISEventInfo *data) { if (qObjIsPlayerWeapon(event_data->it_handle) == true) { if (qUserFlag(17) == false) { aObjPlayAnim(Object_handles[28], 0, 10, 1.000000f, 0); - aShowHUDMessage(Message_strings[12]); + aShowHUDMessage(TXT("TNTDispenserRight")); aMatcenSetState(1, Matcen_indexes[1]); aUserFlagSet(17, 1); aSetObjectTimer(Object_handles[28], 1.000000f, 0); @@ -3250,7 +3044,7 @@ int16_t CustomObjectScript_0847::CallEvent(int event, tOSIRISEventInfo *data) { // Script 037: Left TNT Dispenser Switch if (qObjIsPlayerWeapon(event_data->it_handle) == true) { if (qUserFlag(15) == false) { - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("TNTDispenserLeft")); aTurnOnSpew(Object_handles[30], -1, 8, 0.000000f, 0.000000f, 65536, 0, 0.750000f, 0.100000f, -1.000000f, 2.000000f, 10.000000f, 1, 5); aUserFlagSet(15, 1); @@ -3258,7 +3052,7 @@ int16_t CustomObjectScript_0847::CallEvent(int event, tOSIRISEventInfo *data) { aMiscViewerShake(40.000000f); aSoundPlayObject(Sound_indexes[1], Object_handles[30], 1.000000f); } else { - aShowHUDMessage(Message_strings[14]); + aShowHUDMessage(TXT("TNTDispenserLeftBroken")); } // Increment the script action counter @@ -3277,7 +3071,7 @@ int16_t CustomObjectScript_3831::CallEvent(int event, tOSIRISEventInfo *data) { // Script 041: TNT Rock Wall hit with player weapon if (qObjIsPlayerWeapon(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[16], event_data->it_handle); + aShowHUDMessageObj(TXT("TNTRockWall"), event_data->it_handle); // Increment the script action counter if (ScriptActionCtr_041 < MAX_ACTION_CTR_VALUE) @@ -3293,7 +3087,7 @@ int16_t CustomObjectScript_3831::CallEvent(int event, tOSIRISEventInfo *data) { // Script 051: TNT Rock wall destroyed if (1) { - aShowHUDMessage(Message_strings[15]); + aShowHUDMessage(TXT("TNTRockwalldestroyed")); // Increment the script action counter if (ScriptActionCtr_051 < MAX_ACTION_CTR_VALUE) @@ -3316,7 +3110,7 @@ int16_t CustomObjectScript_2111::CallEvent(int event, tOSIRISEventInfo *data) { // Script 045: Boss Death Dravis Door if (1) { aDoorSetPos(Door_handles[9], 1.000000f); - aShowHUDMessage(Message_strings[17]); + aShowHUDMessage(TXT("DravisDoor")); aGoalCompleted(Goal_indexes[4], 1); // Increment the script action counter @@ -3369,7 +3163,7 @@ int16_t TriggerScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 015: Backup Energy Center Broken if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[9]); + aShowHUDMessage(TXT("EnergyCenterBroken")); // Increment the script action counter if (ScriptActionCtr_015 < MAX_ACTION_CTR_VALUE) @@ -3387,7 +3181,7 @@ int16_t TriggerScript_0001::CallEvent(int event, tOSIRISEventInfo *data) { // Script 016: C Shaped Energy Center Broken if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[9]); + aShowHUDMessage(TXT("EnergyCenterBroken")); aGoalEnableDisable(1, Goal_indexes[2]); // Increment the script action counter @@ -3406,7 +3200,7 @@ int16_t TriggerScript_0002::CallEvent(int event, tOSIRISEventInfo *data) { // Script 017: Secret Energy Center Broken if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[9]); + aShowHUDMessage(TXT("EnergyCenterBroken")); aGoalEnableDisable(1, Goal_indexes[2]); // Increment the script action counter @@ -3564,7 +3358,7 @@ int16_t TriggerScript_000B::CallEvent(int event, tOSIRISEventInfo *data) { // Script 046: End Level Sequence if (qObjIsPlayer(event_data->it_handle) == true) { - aStartEndlevelSequence(Object_handles[33], Path_indexes[6], 10.000000f, Message_strings[18]); + aStartEndlevelSequence(Object_handles[33], Path_indexes[6], 10.000000f, TXT("End")); // Increment the script action counter if (ScriptActionCtr_046 < MAX_ACTION_CTR_VALUE) @@ -3907,7 +3701,7 @@ int16_t TriggerScript_000A::CallEvent(int event, tOSIRISEventInfo *data) { // Script 078: Pre-Boss Player Cinematic if (qObjIsPlayer(event_data->it_handle) == true) { aUserFlagSet(19, 1); - aCinematicIntro(Path_indexes[9], Message_strings[20], Object_handles[0], Path_indexes[10], 15.000000f); + aCinematicIntro(Path_indexes[9], TXT("BLANK"), Object_handles[0], Path_indexes[10], 15.000000f); // Increment the script action counter if (ScriptActionCtr_078 < MAX_ACTION_CTR_VALUE) diff --git a/scripts/Level15_FRN.msg b/scripts/LEVEL15_FRN.msg similarity index 100% rename from scripts/Level15_FRN.msg rename to scripts/LEVEL15_FRN.msg diff --git a/scripts/LEVEL15_Ger.msg b/scripts/LEVEL15_GER.msg similarity index 100% rename from scripts/LEVEL15_Ger.msg rename to scripts/LEVEL15_GER.msg diff --git a/scripts/Level15_ITN.msg b/scripts/LEVEL15_ITN.msg similarity index 100% rename from scripts/Level15_ITN.msg rename to scripts/LEVEL15_ITN.msg diff --git a/scripts/level15_SPN.msg b/scripts/LEVEL15_SPN.msg similarity index 100% rename from scripts/level15_SPN.msg rename to scripts/LEVEL15_SPN.msg diff --git a/scripts/Level12.cpp b/scripts/Level12.cpp index 264f193d7..74c6691b6 100644 --- a/scripts/Level12.cpp +++ b/scripts/Level12.cpp @@ -22,10 +22,10 @@ // Filename: level12.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -1495,180 +1495,12 @@ void RestoreGlobalActionCtrs(void *file_ptr) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} +std::map Messages; -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -1921,53 +1753,6 @@ const char *Goal_names[NUM_GOAL_NAMES] = {"Escape from the firetrap", "Eliminate Championship Competitors"}; int Goal_indexes[NUM_GOAL_NAMES]; -#define NUM_MESSAGE_NAMES 44 -const char *Message_names[NUM_MESSAGE_NAMES] = {"IntroMessage", - "EscapedTorture", - "EscapeTorture2", - "EscapedDestroyed2", - "EscapedDestroyed", - "LevelStarted", - "ActivatedMatcen", - "EmergencyOverride", - "Arena4Enter", - "Arena4Enter2", - "Arena3Enter", - "Arena2Enter", - "Arena1Enter", - "EndLevel", - "DoorUnlocked", - "RepairActivated", - "RepairDeactivated", - "RepairingShip", - "CowFFDisable", - "GonnaClean", - "RedUnitsArmed", - "SRepairInit", - "Arena4Defeated2", - "Arena4Defeated", - "Arena3Defeated", - "Arena2Defeated", - "Arena1Defeated", - "ArenaChamp", - "MainGuards", - "MainFFDeactivated", - "EndBossBegin", - "Guards1", - "Guards2", - "Guards3", - "SecretData", - "RecoveredSecret", - "Level4Key", - "Level3Key", - "Level2Key", - "Level1Key", - "L4Door", - "L3Door", - "L2Door", - "L1Door"}; -const char *Message_strings[NUM_MESSAGE_NAMES]; - // =============== // InitializeDLL() // =============== @@ -1981,26 +1766,16 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "level12.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { mprintf(0, "ERROR: Could not load message file - %s\n", filename); @@ -2047,10 +1822,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } @@ -3190,7 +2961,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aTurnOnSpew(Object_handles[18], 0, 16, 0.000000f, 0.000000f, 65536, 0, 1.200000f, 0.100000f, -1.000000f, 3.800000f, 19.000000f, 0, 0); aSetLevelTimer(10.500000f, 6); - aCinematicIntro(Path_indexes[0], Message_strings[0], Object_handles[19], Path_indexes[1], 10.000000f); + aCinematicIntro(Path_indexes[0], TXT("IntroMessage"), Object_handles[19], Path_indexes[1], 10.000000f); // Increment the script action counter if (ScriptActionCtr_061 < MAX_ACTION_CTR_VALUE) @@ -3261,7 +3032,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aRoomChangeFog(Room_indexes[5], 0.750000f, 0.500000f, 0.100000f, 200.000000f, 5.000000f); aRoomChangeFog(Room_indexes[6], 0.750000f, 0.500000f, 0.100000f, 200.000000f, 5.000000f); aSetLevelTimer(3.000000f, 9); - aShowHUDMessage(Message_strings[19]); + aShowHUDMessage(TXT("GonnaClean")); aSoundPlayObject(Sound_indexes[0], Object_handles[79], 1.000000f); aSoundPlayObject(Sound_indexes[0], Object_handles[80], 1.000000f); aSoundPlayObject(Sound_indexes[0], Object_handles[81], 1.000000f); @@ -3355,7 +3126,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { if (event_data->id == 7) { aGoalCompleted(Goal_indexes[8], 1); aPortalRenderSet(0, 4, Room_indexes[11], 1); - aShowHUDMessage(Message_strings[29]); + aShowHUDMessage(TXT("MainFFDeactivated")); // Increment the script action counter if (ScriptActionCtr_142 < MAX_ACTION_CTR_VALUE) @@ -3534,8 +3305,8 @@ int16_t CustomObjectScript_09DB::CallEvent(int event, tOSIRISEventInfo *data) { // Script 151: FlameMain Destroyed if (1) { aRoomSetDamage(Room_indexes[0], 0.000000f, 4); - aShowHUDMessage(Message_strings[1]); - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("EscapedTorture")); + aShowHUDMessage(TXT("EscapeTorture2")); aObjSetLightingDist(Object_handles[10], 45.000000f); aObjSetLightingDist(Object_handles[11], 45.000000f); aObjMakeVulnerable(Object_handles[10]); @@ -3608,11 +3379,11 @@ int16_t CustomObjectScript_1090::CallEvent(int event, tOSIRISEventInfo *data) { if (qObjExists(Object_handles[11]) == false) { aGoalCompleted(Goal_indexes[0], 1); aMusicSetRegionAll(1); - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("EscapedDestroyed2")); aPhysFlags(0, 58720256, qObjSavedHandle(0)); aTogglePlayerObjAllControls(1, qObjSavedHandle(0)); } else { - aShowHUDMessage(Message_strings[4]); + aShowHUDMessage(TXT("EscapedDestroyed")); } // Increment the script action counter @@ -3640,11 +3411,11 @@ int16_t CustomObjectScript_1173::CallEvent(int event, tOSIRISEventInfo *data) { if (qObjExists(Object_handles[10]) == false) { aGoalCompleted(Goal_indexes[0], 1); aMusicSetRegionAll(1); - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("EscapedDestroyed2")); aPhysFlags(0, 58720256, qObjSavedHandle(0)); aTogglePlayerObjAllControls(1, qObjSavedHandle(0)); } else { - aShowHUDMessage(Message_strings[4]); + aShowHUDMessage(TXT("EscapedDestroyed")); } // Increment the script action counter @@ -3663,7 +3434,7 @@ int16_t CustomObjectScript_087C::CallEvent(int event, tOSIRISEventInfo *data) { // Script 030: Switch Enables Matcen (6) if ((ScriptActionCtr_030 < 1) && (qObjIsPlayerWeapon(event_data->it_handle) == true)) { - aShowHUDMessage(Message_strings[6]); + aShowHUDMessage(TXT("ActivatedMatcen")); aMatcenSetState(1, Matcen_indexes[2]); aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); aObjPlayAnim(data->me_handle, 0, 4, 2.000000f, 0); @@ -3684,7 +3455,7 @@ int16_t CustomObjectScript_087B::CallEvent(int event, tOSIRISEventInfo *data) { // Script 029: Switch Enables Matcen (5) if ((ScriptActionCtr_029 < 1) && (qObjIsPlayerWeapon(event_data->it_handle) == true)) { - aShowHUDMessage(Message_strings[6]); + aShowHUDMessage(TXT("ActivatedMatcen")); aMatcenSetState(1, Matcen_indexes[3]); aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); aObjPlayAnim(data->me_handle, 0, 4, 2.000000f, 0); @@ -3705,7 +3476,7 @@ int16_t CustomObjectScript_087A::CallEvent(int event, tOSIRISEventInfo *data) { // Script 028: Switch Enables Matcen (4) if ((ScriptActionCtr_028 < 1) && (qObjIsPlayerWeapon(event_data->it_handle) == true)) { - aShowHUDMessage(Message_strings[6]); + aShowHUDMessage(TXT("ActivatedMatcen")); aMatcenSetState(1, Matcen_indexes[4]); aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); aObjPlayAnim(data->me_handle, 0, 4, 2.000000f, 0); @@ -3726,7 +3497,7 @@ int16_t CustomObjectScript_0879::CallEvent(int event, tOSIRISEventInfo *data) { // Script 027: Switch Enables Matcen (3) if ((ScriptActionCtr_027 < 1) && (qObjIsPlayerWeapon(event_data->it_handle) == true)) { - aShowHUDMessage(Message_strings[6]); + aShowHUDMessage(TXT("ActivatedMatcen")); aMatcenSetState(1, Matcen_indexes[5]); aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); aObjPlayAnim(data->me_handle, 0, 4, 2.000000f, 0); @@ -3747,7 +3518,7 @@ int16_t CustomObjectScript_0878::CallEvent(int event, tOSIRISEventInfo *data) { // Script 026: Switch Enables Matcen (2) if ((ScriptActionCtr_026 < 1) && (qObjIsPlayerWeapon(event_data->it_handle) == true)) { - aShowHUDMessage(Message_strings[6]); + aShowHUDMessage(TXT("ActivatedMatcen")); aMatcenSetState(1, Matcen_indexes[6]); aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); aObjPlayAnim(data->me_handle, 0, 4, 2.000000f, 0); @@ -3769,7 +3540,7 @@ int16_t CustomObjectScript_204D::CallEvent(int event, tOSIRISEventInfo *data) { // Script 001: Switch Enables Matcen (1) if ((ScriptActionCtr_001 < 1) && (qObjIsPlayerWeapon(event_data->it_handle) == true)) { aObjPlayAnim(data->me_handle, 0, 4, 2.000000f, 0); - aShowHUDMessage(Message_strings[6]); + aShowHUDMessage(TXT("ActivatedMatcen")); aMatcenSetState(1, Matcen_indexes[7]); aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); @@ -3794,7 +3565,7 @@ int16_t CustomObjectScript_0880::CallEvent(int event, tOSIRISEventInfo *data) { aMatcenSetState(1, Matcen_indexes[8]); aObjPlayAnim(data->me_handle, 0, 4, 2.000000f, 0); aPortalRenderSet(0, 0, Room_indexes[1], 1); - aShowHUDMessage(Message_strings[7]); + aShowHUDMessage(TXT("EmergencyOverride")); aGoalCompleted(Goal_indexes[1], 1); aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); @@ -3985,11 +3756,11 @@ int16_t CustomObjectScript_107D::CallEvent(int event, tOSIRISEventInfo *data) { aGoalCompleted(Goal_indexes[3], 1); aPortalRenderToggle(0, Room_indexes[9], 1); if (qObjExists(Object_handles[5]) == false) { - aShowHUDMessage(Message_strings[22]); + aShowHUDMessage(TXT("Arena4Defeated2")); aPortalRenderSet(0, 2, Room_indexes[10], 1); aPortalRenderSet(0, 2, Room_indexes[9], 1); } else { - aShowHUDMessage(Message_strings[23]); + aShowHUDMessage(TXT("Arena4Defeated")); } // Increment the script action counter @@ -4031,11 +3802,11 @@ int16_t CustomObjectScript_117F::CallEvent(int event, tOSIRISEventInfo *data) { aGoalCompleted(Goal_indexes[3], 1); aPortalRenderToggle(0, Room_indexes[10], 1); if (qObjExists(Object_handles[4]) == false) { - aShowHUDMessage(Message_strings[22]); + aShowHUDMessage(TXT("Arena4Defeated2")); aPortalRenderSet(0, 2, Room_indexes[10], 1); aPortalRenderSet(0, 2, Room_indexes[9], 1); } else { - aShowHUDMessage(Message_strings[23]); + aShowHUDMessage(TXT("Arena4Defeated")); } // Increment the script action counter @@ -4075,7 +3846,7 @@ int16_t CustomObjectScript_1180::CallEvent(int event, tOSIRISEventInfo *data) { aDoorLockUnlock(0, Door_handles[1]); aDoorLockUnlock(0, Door_handles[7]); aSoundPlaySteaming("VoxL12SpecificB.osf", 1.000000f); - aShowHUDMessage(Message_strings[24]); + aShowHUDMessage(TXT("Arena3Defeated")); aSetObjectTimer(Object_handles[114], 2.000000f, -1); aGoalCompleted(Goal_indexes[4], 1); @@ -4116,7 +3887,7 @@ int16_t CustomObjectScript_1168::CallEvent(int event, tOSIRISEventInfo *data) { aDoorLockUnlock(0, Door_handles[2]); aDoorLockUnlock(0, Door_handles[8]); aSoundPlaySteaming("VoxL12SpecificA.osf", 1.000000f); - aShowHUDMessage(Message_strings[25]); + aShowHUDMessage(TXT("Arena2Defeated")); aSetObjectTimer(Object_handles[115], 2.000000f, -1); aGoalCompleted(Goal_indexes[5], 1); @@ -4181,7 +3952,7 @@ int16_t CustomObjectScript_1081::CallEvent(int event, tOSIRISEventInfo *data) { aDoorLockUnlock(0, Door_handles[3]); aSoundPlaySteaming("VoxL12SpecificB.osf", 1.000000f); aSetObjectTimer(Object_handles[116], 2.000000f, -1); - aShowHUDMessage(Message_strings[26]); + aShowHUDMessage(TXT("Arena1Defeated")); // Increment the script action counter if (ScriptActionCtr_088 < MAX_ACTION_CTR_VALUE) @@ -4242,7 +4013,7 @@ int16_t CustomObjectScript_08B5::CallEvent(int event, tOSIRISEventInfo *data) { aDoorLockUnlock(0, Door_handles[6]); aObjPlayAnim(data->me_handle, 0, 2, 2.000000f, 0); aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); - aShowHUDMessage(Message_strings[14]); + aShowHUDMessage(TXT("DoorUnlocked")); // Increment the script action counter if (ScriptActionCtr_024 < MAX_ACTION_CTR_VALUE) @@ -4430,7 +4201,7 @@ int16_t CustomObjectScript_08C2::CallEvent(int event, tOSIRISEventInfo *data) { // Script 037: ToggleRepar-22 if ((ScriptActionCtr_037 < 1) && ((qObjIsPlayerWeapon(event_data->it_handle) == true) && (qUserVarValue(3) == 1.000000f))) { - aShowHUDMessage(Message_strings[15]); + aShowHUDMessage(TXT("RepairActivated")); aObjPlayAnim(Object_handles[68], 0, 1, 0.100000f, 0); aObjPlayAnim(Object_handles[67], 0, 1, 0.100000f, 0); aObjSetLightingDist(Object_handles[68], 40.000000f); @@ -4448,7 +4219,7 @@ int16_t CustomObjectScript_08C2::CallEvent(int event, tOSIRISEventInfo *data) { // Script 036: ToggleRepair-21 if ((ScriptActionCtr_036 < 1) && (qObjIsPlayerWeapon(event_data->it_handle) == true)) { if (qUserVarValue(3) == 0.000000f) { - aShowHUDMessage(Message_strings[16]); + aShowHUDMessage(TXT("RepairDeactivated")); aObjSetLightingDist(Object_handles[68], 0.000000f); aObjSetLightingDist(Object_handles[67], 0.000000f); aAISetState(0, Object_handles[68]); @@ -4489,7 +4260,7 @@ int16_t CustomObjectScript_18C3::CallEvent(int event, tOSIRISEventInfo *data) { // Script 034: ToggleRepar-12 if ((ScriptActionCtr_034 < 1) && ((qObjIsPlayerWeapon(event_data->it_handle) == true) && (qUserVarValue(2) == 1.000000f))) { - aShowHUDMessage(Message_strings[15]); + aShowHUDMessage(TXT("RepairActivated")); aObjPlayAnim(Object_handles[62], 0, 1, 0.100000f, 0); aObjPlayAnim(Object_handles[69], 0, 1, 0.100000f, 0); aObjSetLightingDist(Object_handles[62], 40.000000f); @@ -4507,7 +4278,7 @@ int16_t CustomObjectScript_18C3::CallEvent(int event, tOSIRISEventInfo *data) { // Script 033: ToggleRepair-11 if ((ScriptActionCtr_033 < 1) && (qObjIsPlayerWeapon(event_data->it_handle) == true)) { if (qUserVarValue(2) == 0.000000f) { - aShowHUDMessage(Message_strings[16]); + aShowHUDMessage(TXT("RepairDeactivated")); aObjSetLightingDist(Object_handles[62], 0.000000f); aObjSetLightingDist(Object_handles[69], 0.000000f); aAISetState(0, Object_handles[62]); @@ -4553,7 +4324,7 @@ int16_t CustomObjectScript_0952::CallEvent(int event, tOSIRISEventInfo *data) { aObjSetShields(event_data->it_handle, 100.000000f); aObjPlayAnim(Object_handles[67], 0, 14, 5.000000f, 0); aSoundPlayObject(Sound_indexes[6], data->me_handle, 1.000000f); - aCinematicSimple(Path_indexes[9], Message_strings[17], data->me_handle, 6.000000f, 1); + aCinematicSimple(Path_indexes[9], TXT("RepairingShip"), data->me_handle, 6.000000f, 1); aObjSetVelocity(event_data->it_handle, 0.000000f, 0.000000f, 0.000000f, 1.000000f); aLightningCreate(event_data->it_handle, data->me_handle, 6.000000f, 3.000000f, 1, Texture_indexes[0], 0.400000f, 1, 100, 255, 50, 0); @@ -4581,7 +4352,7 @@ int16_t CustomObjectScript_0953::CallEvent(int event, tOSIRISEventInfo *data) { aObjSetShields(event_data->it_handle, 100.000000f); aObjPlayAnim(Object_handles[68], 0, 14, 5.000000f, 0); aSoundPlayObject(Sound_indexes[6], data->me_handle, 1.000000f); - aCinematicSimple(Path_indexes[10], Message_strings[17], data->me_handle, 6.000000f, 1); + aCinematicSimple(Path_indexes[10], TXT("RepairingShip"), data->me_handle, 6.000000f, 1); aObjSetVelocity(event_data->it_handle, 0.000000f, 0.000000f, 0.000000f, 1.000000f); aLightningCreate(event_data->it_handle, data->me_handle, 6.000000f, 3.000000f, 1, Texture_indexes[0], 0.400000f, 1, 100, 255, 50, 0); @@ -4609,7 +4380,7 @@ int16_t CustomObjectScript_0950::CallEvent(int event, tOSIRISEventInfo *data) { aObjSetShields(event_data->it_handle, 100.000000f); aObjPlayAnim(Object_handles[69], 0, 14, 5.000000f, 0); aSoundPlayObject(Sound_indexes[6], data->me_handle, 1.000000f); - aCinematicSimple(Path_indexes[11], Message_strings[17], data->me_handle, 6.000000f, 1); + aCinematicSimple(Path_indexes[11], TXT("RepairingShip"), data->me_handle, 6.000000f, 1); aObjSetVelocity(event_data->it_handle, 0.000000f, 0.000000f, 0.000000f, 1.000000f); aLightningCreate(event_data->it_handle, data->me_handle, 6.000000f, 3.000000f, 1, Texture_indexes[0], 0.400000f, 1, 100, 255, 50, 0); @@ -4641,7 +4412,7 @@ int16_t CustomObjectScript_0951::CallEvent(int event, tOSIRISEventInfo *data) { aObjPlayAnim(Object_handles[62], 0, 14, 5.000000f, 0); aSoundPlayObject(Sound_indexes[6], data->me_handle, 1.000000f); aSoundPlaySteamingObj("VoxL12GeneralC.osf", event_data->it_handle, 1.000000f); - aCinematicSimple(Path_indexes[12], Message_strings[17], data->me_handle, 6.000000f, 1); + aCinematicSimple(Path_indexes[12], TXT("RepairingShip"), data->me_handle, 6.000000f, 1); // Increment the script action counter if (ScriptActionCtr_042 < MAX_ACTION_CTR_VALUE) @@ -4683,7 +4454,7 @@ int16_t CustomObjectScript_104E::CallEvent(int event, tOSIRISEventInfo *data) { if ((qUserVarValue(6) == 1.000000f) && (qUserVarValue(4) == 1.000000f)) { aPortalRenderSet(0, 0, Room_indexes[5], 1); aPortalRenderSet(0, 0, Room_indexes[6], 1); - aShowHUDMessage(Message_strings[18]); + aShowHUDMessage(TXT("CowFFDisable")); } if (qUserVarValue(6) == 2.000000f) { aUserVarSet(6, 0.000000f); @@ -4742,7 +4513,7 @@ int16_t CustomObjectScript_1969::CallEvent(int event, tOSIRISEventInfo *data) { if ((qUserVarValue(4) == 1.000000f) && (qUserVarValue(6) == 1.000000f)) { aPortalRenderSet(0, 0, Room_indexes[5], 1); aPortalRenderSet(0, 0, Room_indexes[6], 1); - aShowHUDMessage(Message_strings[18]); + aShowHUDMessage(TXT("CowFFDisable")); } if (qUserVarValue(4) == 2.000000f) { aUserVarSet(4, 0.000000f); @@ -4924,7 +4695,7 @@ int16_t CustomObjectScript_08E2::CallEvent(int event, tOSIRISEventInfo *data) { aObjSetLightingDist(Object_handles[108], 30.000000f); aObjPlayAnim(data->me_handle, 0, 4, 2.000000f, 0); aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); - aShowHUDMessage(Message_strings[20]); + aShowHUDMessage(TXT("RedUnitsArmed")); // Increment the script action counter if (ScriptActionCtr_068 < MAX_ACTION_CTR_VALUE) @@ -5052,7 +4823,7 @@ int16_t CustomObjectScript_08E9::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); aObjSetLightingDist(Object_handles[110], 0.000000f); aSetObjectTimer(data->me_handle, 2.000000f, -1); - aShowHUDMessage(Message_strings[16]); + aShowHUDMessage(TXT("RepairDeactivated")); // Increment the script action counter if (ScriptActionCtr_076 < MAX_ACTION_CTR_VALUE) @@ -5065,7 +4836,7 @@ int16_t CustomObjectScript_08E9::CallEvent(int event, tOSIRISEventInfo *data) { aObjPlayAnim(data->me_handle, 1, 2, 2.000000f, 0); aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); aObjSetLightingDist(Object_handles[110], 40.000000f); - aShowHUDMessage(Message_strings[15]); + aShowHUDMessage(TXT("RepairActivated")); // Increment the script action counter if (ScriptActionCtr_079 < MAX_ACTION_CTR_VALUE) @@ -5119,7 +4890,7 @@ int16_t CustomObjectScript_08E8::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); aObjSetLightingDist(Object_handles[111], 0.000000f); aSetObjectTimer(data->me_handle, 2.000000f, -1); - aShowHUDMessage(Message_strings[16]); + aShowHUDMessage(TXT("RepairDeactivated")); // Increment the script action counter if (ScriptActionCtr_078 < MAX_ACTION_CTR_VALUE) @@ -5132,7 +4903,7 @@ int16_t CustomObjectScript_08E8::CallEvent(int event, tOSIRISEventInfo *data) { aObjPlayAnim(data->me_handle, 1, 2, 2.000000f, 0); aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); aObjSetLightingDist(Object_handles[111], 40.000000f); - aShowHUDMessage(Message_strings[15]); + aShowHUDMessage(TXT("RepairActivated")); // Increment the script action counter if (ScriptActionCtr_081 < MAX_ACTION_CTR_VALUE) @@ -5164,7 +4935,7 @@ int16_t CustomObjectScript_105A::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_085 < 1) && ((qObjIsPlayer(event_data->it_handle) == true) && ((ScriptActionCtr_078 > 0) == false) && (qObjExists(Object_handles[111]) == true))) { - aShowHUDMessage(Message_strings[21]); + aShowHUDMessage(TXT("SRepairInit")); aMiscViewerShake(70.000000f); // Increment the script action counter @@ -5183,7 +4954,7 @@ int16_t CustomObjectScript_105A::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[6], Object_handles[111], 1.000000f); aObjSetLightingDist(Object_handles[111], 20.000000f); aObjPlayAnim(Object_handles[111], 0, 14, 5.000000f, 0); - aCinematicSimple(Path_indexes[13], Message_strings[17], data->me_handle, 6.000000f, 1); + aCinematicSimple(Path_indexes[13], TXT("RepairingShip"), data->me_handle, 6.000000f, 1); aSoundPlaySteamingObj("VoxL12GeneralC.osf", event_data->it_handle, 1.000000f); // Increment the script action counter @@ -5204,7 +4975,7 @@ int16_t CustomObjectScript_097D::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_082 < 1) && ((qObjIsPlayer(event_data->it_handle) == true) && ((ScriptActionCtr_076 > 0) == false) && (qObjExists(Object_handles[110]) == true))) { - aShowHUDMessage(Message_strings[21]); + aShowHUDMessage(TXT("SRepairInit")); aMiscViewerShake(70.000000f); // Increment the script action counter @@ -5223,7 +4994,7 @@ int16_t CustomObjectScript_097D::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[6], Object_handles[110], 1.000000f); aObjSetLightingDist(Object_handles[110], 20.000000f); aObjPlayAnim(Object_handles[110], 0, 14, 5.000000f, 0); - aCinematicSimple(Path_indexes[14], Message_strings[17], data->me_handle, 6.000000f, 1); + aCinematicSimple(Path_indexes[14], TXT("RepairingShip"), data->me_handle, 6.000000f, 1); aSoundPlaySteamingObj("VoxL12GeneralC.osf", event_data->it_handle, 1.000000f); // Increment the script action counter @@ -5252,7 +5023,7 @@ int16_t CustomObjectScript_1801::CallEvent(int event, tOSIRISEventInfo *data) { aDoorLockUnlock(0, Door_handles[11]); aDoorLockUnlock(0, Door_handles[12]); aDoorLockUnlock(0, Door_handles[13]); - aShowHUDMessage(Message_strings[27]); + aShowHUDMessage(TXT("ArenaChamp")); // Increment the script action counter if (ScriptActionCtr_096 < MAX_ACTION_CTR_VALUE) @@ -5711,13 +5482,13 @@ int16_t CustomObjectScript_18F0::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_137 < 1) && (1)) { aUserVarInc(11); if (qUserVarValue(11) == 1.000000f) { - aShowHUDMessage(Message_strings[31]); + aShowHUDMessage(TXT("Guards1")); } else { if (qUserVarValue(11) == 2.000000f) { - aShowHUDMessage(Message_strings[32]); + aShowHUDMessage(TXT("Guards2")); } else { if (qUserVarValue(11) == 3.000000f) { - aShowHUDMessage(Message_strings[33]); + aShowHUDMessage(TXT("Guards3")); } } } @@ -5767,13 +5538,13 @@ int16_t CustomObjectScript_19BE::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_136 < 1) && (1)) { aUserVarInc(11); if (qUserVarValue(11) == 1.000000f) { - aShowHUDMessage(Message_strings[31]); + aShowHUDMessage(TXT("Guards1")); } else { if (qUserVarValue(11) == 2.000000f) { - aShowHUDMessage(Message_strings[32]); + aShowHUDMessage(TXT("Guards2")); } else { if (qUserVarValue(11) == 3.000000f) { - aShowHUDMessage(Message_strings[33]); + aShowHUDMessage(TXT("Guards3")); } } } @@ -5823,13 +5594,13 @@ int16_t CustomObjectScript_18F1::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_135 < 1) && (1)) { aUserVarInc(11); if (qUserVarValue(11) == 1.000000f) { - aShowHUDMessage(Message_strings[31]); + aShowHUDMessage(TXT("Guards1")); } else { if (qUserVarValue(11) == 2.000000f) { - aShowHUDMessage(Message_strings[32]); + aShowHUDMessage(TXT("Guards2")); } else { if (qUserVarValue(11) == 3.000000f) { - aShowHUDMessage(Message_strings[33]); + aShowHUDMessage(TXT("Guards3")); } } } @@ -5879,13 +5650,13 @@ int16_t CustomObjectScript_19C0::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_134 < 1) && (1)) { aUserVarInc(11); if (qUserVarValue(11) == 1.000000f) { - aShowHUDMessage(Message_strings[31]); + aShowHUDMessage(TXT("Guards1")); } else { if (qUserVarValue(11) == 2.000000f) { - aShowHUDMessage(Message_strings[32]); + aShowHUDMessage(TXT("Guards2")); } else { if (qUserVarValue(11) == 3.000000f) { - aShowHUDMessage(Message_strings[33]); + aShowHUDMessage(TXT("Guards3")); } } } @@ -5907,7 +5678,7 @@ int16_t CustomObjectScript_18EE::CallEvent(int event, tOSIRISEventInfo *data) { // Script 168: Secret Data Cartridge if ((ScriptActionCtr_168 < 1) && (qObjIsPlayer(event_data->it_handle) == true)) { aSoundPlayObject(Sound_indexes[8], data->me_handle, 1.000000f); - aAddGameMessage(Message_strings[34], Message_strings[35]); + aAddGameMessage(TXT("SecretData"), TXT("RecoveredSecret")); aMissionSetSecretFlag(1); aObjDelete(data->me_handle); @@ -5929,8 +5700,8 @@ int16_t CustomObjectScript_20CD::CallEvent(int event, tOSIRISEventInfo *data) { if (qObjIsPlayer(event_data->it_handle) == true) { aGoalEnableDisable(1, Goal_indexes[3]); aSoundPlayObject(Sound_indexes[8], event_data->it_handle, 1.000000f); - aObjectPlayerGiveKey(event_data->it_handle, data->me_handle, 4, Message_strings[36], 0); - aAddGameMessage(Message_strings[36], Message_strings[36]); + aObjectPlayerGiveKey(event_data->it_handle, data->me_handle, 4, TXT("Level4Key"), 0); + aAddGameMessage(TXT("Level4Key"), TXT("Level4Key")); // Increment the script action counter if (ScriptActionCtr_058 < MAX_ACTION_CTR_VALUE) @@ -5950,8 +5721,8 @@ int16_t CustomObjectScript_28CC::CallEvent(int event, tOSIRISEventInfo *data) { if (qObjIsPlayer(event_data->it_handle) == true) { aGoalEnableDisable(1, Goal_indexes[4]); aSoundPlayObject(Sound_indexes[8], event_data->it_handle, 1.000000f); - aObjectPlayerGiveKey(event_data->it_handle, data->me_handle, 3, Message_strings[37], 0); - aAddGameMessage(Message_strings[37], Message_strings[37]); + aObjectPlayerGiveKey(event_data->it_handle, data->me_handle, 3, TXT("Level3Key"), 0); + aAddGameMessage(TXT("Level3Key"), TXT("Level3Key")); // Increment the script action counter if (ScriptActionCtr_057 < MAX_ACTION_CTR_VALUE) @@ -5971,8 +5742,8 @@ int16_t CustomObjectScript_10B2::CallEvent(int event, tOSIRISEventInfo *data) { if (qObjIsPlayer(event_data->it_handle) == true) { aGoalEnableDisable(1, Goal_indexes[5]); aSoundPlayObject(Sound_indexes[8], event_data->it_handle, 1.000000f); - aObjectPlayerGiveKey(event_data->it_handle, data->me_handle, 2, Message_strings[38], 0); - aAddGameMessage(Message_strings[38], Message_strings[38]); + aObjectPlayerGiveKey(event_data->it_handle, data->me_handle, 2, TXT("Level2Key"), 0); + aAddGameMessage(TXT("Level2Key"), TXT("Level2Key")); // Increment the script action counter if (ScriptActionCtr_056 < MAX_ACTION_CTR_VALUE) @@ -5992,8 +5763,8 @@ int16_t CustomObjectScript_18C1::CallEvent(int event, tOSIRISEventInfo *data) { if (qObjIsPlayer(event_data->it_handle) == true) { aGoalEnableDisable(1, Goal_indexes[6]); aSoundPlayObject(Sound_indexes[8], event_data->it_handle, 1.000000f); - aObjectPlayerGiveKey(event_data->it_handle, data->me_handle, 1, Message_strings[39], 0); - aAddGameMessage(Message_strings[39], Message_strings[39]); + aObjectPlayerGiveKey(event_data->it_handle, data->me_handle, 1, TXT("Level1Key"), 0); + aAddGameMessage(TXT("Level1Key"), TXT("Level1Key")); // Increment the script action counter if (ScriptActionCtr_055 < MAX_ACTION_CTR_VALUE) @@ -6012,9 +5783,9 @@ int16_t CustomObjectScript_21B8::CallEvent(int event, tOSIRISEventInfo *data) { // Script 093: Arena Door 42 if ((qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) && ((ScriptActionCtr_058 > 0) == false)) { if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[40], event_data->it_handle); + aShowHUDMessageObj(TXT("L4Door"), event_data->it_handle); } else { - aShowHUDMessageObj(Message_strings[40], qObjParent(event_data->it_handle)); + aShowHUDMessageObj(TXT("L4Door"), qObjParent(event_data->it_handle)); } // Increment the script action counter @@ -6034,9 +5805,9 @@ int16_t CustomObjectScript_21B9::CallEvent(int event, tOSIRISEventInfo *data) { // Script 092: Arena Door 41 if ((qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) && ((ScriptActionCtr_058 > 0) == false)) { if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[40], event_data->it_handle); + aShowHUDMessageObj(TXT("L4Door"), event_data->it_handle); } else { - aShowHUDMessageObj(Message_strings[40], qObjParent(event_data->it_handle)); + aShowHUDMessageObj(TXT("L4Door"), qObjParent(event_data->it_handle)); } // Increment the script action counter @@ -6056,9 +5827,9 @@ int16_t CustomObjectScript_080A::CallEvent(int event, tOSIRISEventInfo *data) { // Script 059: Arena Door 3 if ((qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) && ((ScriptActionCtr_057 > 0) == false)) { if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[41], event_data->it_handle); + aShowHUDMessageObj(TXT("L3Door"), event_data->it_handle); } else { - aShowHUDMessageObj(Message_strings[41], qObjParent(event_data->it_handle)); + aShowHUDMessageObj(TXT("L3Door"), qObjParent(event_data->it_handle)); } // Increment the script action counter @@ -6078,9 +5849,9 @@ int16_t CustomObjectScript_080C::CallEvent(int event, tOSIRISEventInfo *data) { // Script 023: Arena Door 2 if ((qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) && ((ScriptActionCtr_056 > 0) == false)) { if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[42], event_data->it_handle); + aShowHUDMessageObj(TXT("L2Door"), event_data->it_handle); } else { - aShowHUDMessageObj(Message_strings[42], qObjParent(event_data->it_handle)); + aShowHUDMessageObj(TXT("L2Door"), qObjParent(event_data->it_handle)); } // Increment the script action counter @@ -6100,9 +5871,9 @@ int16_t CustomObjectScript_0811::CallEvent(int event, tOSIRISEventInfo *data) { // Script 010: Arena Door 1 if ((qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) && ((ScriptActionCtr_055 > 0) == false)) { if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[43], event_data->it_handle); + aShowHUDMessageObj(TXT("L1Door"), event_data->it_handle); } else { - aShowHUDMessageObj(Message_strings[43], qObjParent(event_data->it_handle)); + aShowHUDMessageObj(TXT("L1Door"), qObjParent(event_data->it_handle)); } // Increment the script action counter @@ -6125,7 +5896,7 @@ int16_t TriggerScript_0012::CallEvent(int event, tOSIRISEventInfo *data) { aSetWaypoint(10); aSetObjectTimer(Object_handles[20], 12.000000f, -1); aSetObjectTimer(Object_handles[21], 12.000000f, -1); - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("LevelStarted")); aMatcenSetState(1, Matcen_indexes[0]); aMatcenSetState(1, Matcen_indexes[1]); @@ -6212,7 +5983,7 @@ int16_t TriggerScript_0005::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_110 < 1) && (1)) { aAISetState(1, Object_handles[6]); aAISetTeam(196608, Object_handles[6]); - aCinematicSimple(Path_indexes[4], Message_strings[10], Object_handles[6], 10.000000f, 1); + aCinematicSimple(Path_indexes[4], TXT("Arena3Enter"), Object_handles[6], 10.000000f, 1); // Increment the script action counter if (ScriptActionCtr_110 < MAX_ACTION_CTR_VALUE) @@ -6260,7 +6031,7 @@ int16_t TriggerScript_0003::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_108 < 1) && (1)) { aAISetState(1, Object_handles[7]); aAISetTeam(196608, Object_handles[7]); - aCinematicSimple(Path_indexes[5], Message_strings[11], Object_handles[7], 10.000000f, 1); + aCinematicSimple(Path_indexes[5], TXT("Arena2Enter"), Object_handles[7], 10.000000f, 1); // Increment the script action counter if (ScriptActionCtr_108 < MAX_ACTION_CTR_VALUE) @@ -6299,7 +6070,7 @@ int16_t TriggerScript_0008::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_107 < 1) && (1)) { aAISetState(1, Object_handles[8]); aAISetTeam(196608, Object_handles[8]); - aCinematicSimple(Path_indexes[6], Message_strings[12], Object_handles[8], 10.000000f, 1); + aCinematicSimple(Path_indexes[6], TXT("Arena1Enter"), Object_handles[8], 10.000000f, 1); // Increment the script action counter if (ScriptActionCtr_107 < MAX_ACTION_CTR_VALUE) @@ -6331,9 +6102,9 @@ int16_t TriggerScript_001E::CallEvent(int event, tOSIRISEventInfo *data) { aAISetState(1, Object_handles[4]); aAISetTeam(196608, Object_handles[4]); if (qObjExists(Object_handles[5]) == true) { - aCinematicSimple(Path_indexes[2], Message_strings[8], Object_handles[4], 10.000000f, 1); + aCinematicSimple(Path_indexes[2], TXT("Arena4Enter"), Object_handles[4], 10.000000f, 1); } else { - aCinematicSimple(Path_indexes[2], Message_strings[9], Object_handles[4], 10.000000f, 1); + aCinematicSimple(Path_indexes[2], TXT("Arena4Enter2"), Object_handles[4], 10.000000f, 1); } // Increment the script action counter @@ -6357,9 +6128,9 @@ int16_t TriggerScript_001F::CallEvent(int event, tOSIRISEventInfo *data) { aAISetState(1, Object_handles[5]); aAISetTeam(196608, Object_handles[5]); if (qObjExists(Object_handles[4]) == true) { - aCinematicSimple(Path_indexes[3], Message_strings[8], Object_handles[5], 10.000000f, 1); + aCinematicSimple(Path_indexes[3], TXT("Arena4Enter"), Object_handles[5], 10.000000f, 1); } else { - aCinematicSimple(Path_indexes[3], Message_strings[9], Object_handles[5], 10.000000f, 1); + aCinematicSimple(Path_indexes[3], TXT("Arena4Enter2"), Object_handles[5], 10.000000f, 1); } // Increment the script action counter @@ -6379,7 +6150,7 @@ int16_t TriggerScript_0001::CallEvent(int event, tOSIRISEventInfo *data) { // Script 014: ExitSequenceTest if (1) { aGoalCompleted(Goal_indexes[2], 1); - aStartEndlevelSequencePath(Path_indexes[7], Path_indexes[8], 7.000000f, Message_strings[13]); + aStartEndlevelSequencePath(Path_indexes[7], Path_indexes[8], 7.000000f, TXT("EndLevel")); // Increment the script action counter if (ScriptActionCtr_014 < MAX_ACTION_CTR_VALUE) @@ -6480,7 +6251,7 @@ int16_t TriggerScript_0021::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_133 < 1) && ((ScriptActionCtr_095 > 0) == false)) { aDoorLockUnlock(1, Door_handles[4]); aDoorLockUnlock(1, Door_handles[5]); - aShowHUDMessage(Message_strings[28]); + aShowHUDMessage(TXT("MainGuards")); // Increment the script action counter if (ScriptActionCtr_133 < MAX_ACTION_CTR_VALUE) @@ -6500,7 +6271,7 @@ int16_t TriggerScript_0020::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_095 < 1) && ((ScriptActionCtr_133 > 0) == false)) { aDoorLockUnlock(1, Door_handles[4]); aDoorLockUnlock(1, Door_handles[5]); - aShowHUDMessage(Message_strings[28]); + aShowHUDMessage(TXT("MainGuards")); // Increment the script action counter if (ScriptActionCtr_095 < MAX_ACTION_CTR_VALUE) @@ -6520,7 +6291,7 @@ int16_t TriggerScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_102 < 1) && ((ScriptActionCtr_142 > 0) == true)) { aSetWaypoint(12); aMusicSetRegion(8, event_data->it_handle); - aCinematicSimple(Path_indexes[30], Message_strings[30], Object_handles[27], 15.000000f, 1); + aCinematicSimple(Path_indexes[30], TXT("EndBossBegin"), Object_handles[27], 15.000000f, 1); aPortalRenderSet(1, 0, Room_indexes[9], 1); aPortalRenderSet(1, 0, Room_indexes[10], 1); diff --git a/scripts/Level12_Ger.msg b/scripts/Level12_GER.msg similarity index 100% rename from scripts/Level12_Ger.msg rename to scripts/Level12_GER.msg diff --git a/scripts/level12_SPN.msg b/scripts/Level12_SPN.msg similarity index 100% rename from scripts/level12_SPN.msg rename to scripts/Level12_SPN.msg diff --git a/scripts/Level16.cpp b/scripts/Level16.cpp index c3e9edd9f..6ed8c892d 100644 --- a/scripts/Level16.cpp +++ b/scripts/Level16.cpp @@ -22,10 +22,10 @@ // Filename: Level16.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -200,180 +200,12 @@ void RestoreGlobalActionCtrs(void *file_ptr) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} +std::map Messages; -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -423,12 +255,6 @@ int *Matcen_indexes = NULL; const char *Goal_names[NUM_GOAL_NAMES] = {"Explore the hidden base"}; int Goal_indexes[NUM_GOAL_NAMES]; -#define NUM_MESSAGE_NAMES 8 -const char *Message_names[NUM_MESSAGE_NAMES] = { - "IntroHUDmessage", "IntroBriefingMessage", "Area1Active", "EntranceDoorMessage", "Area1", "Area3", - "Area2", "EndLevelMessage"}; -const char *Message_strings[NUM_MESSAGE_NAMES]; - // =============== // InitializeDLL() // =============== @@ -442,26 +268,16 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "Level16.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { mprintf(0, "ERROR: Could not load message file - %s\n", filename); @@ -508,10 +324,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } @@ -701,7 +513,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 001: LevelStart if ((ScriptActionCtr_001 < 1) && (1)) { aRoomSetWind(Room_indexes[0], 0.400000f, 0.000000f, 0.100000f, 45.000000f); - aAddGameMessage(Message_strings[0], Message_strings[1]); + aAddGameMessage(TXT("IntroHUDmessage"), TXT("IntroBriefingMessage")); aUserVarSet(0, 0.000000f); aUserVarSet(1, 0.000000f); aUserVarSet(2, 0.000000f); @@ -719,7 +531,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 012: EndTheLevel if (event_data->id == 3) { - aShowHUDMessage(Message_strings[7]); + aShowHUDMessage(TXT("EndLevelMessage")); aEndLevel(); // Increment the script action counter @@ -786,7 +598,7 @@ int16_t CustomObjectScript_0804::CallEvent(int event, tOSIRISEventInfo *data) { // Script 004: EntranceDoorMessage if (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == 1) { - aShowHUDMessageObj(Message_strings[3], event_data->it_handle); + aShowHUDMessageObj(TXT("EntranceDoorMessage"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[1], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -845,7 +657,7 @@ int16_t TriggerScript_0001::CallEvent(int event, tOSIRISEventInfo *data) { // Script 002: Area1Wind if ((qUserVarValueInt(1) == 1) && (qObjIsPlayer(event_data->it_handle) == true) && (0 == true)) { - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("Area1Active")); aRoomSetWind(Room_indexes[2], 0.000000f, 0.000000f, 1.000000f, 20.000000f); aRoomSetWind(Room_indexes[3], 0.000000f, 0.000000f, 1.000000f, 20.000000f); aRoomSetWind(Room_indexes[4], 0.000000f, 0.000000f, 1.000000f, 20.000000f); @@ -897,7 +709,7 @@ int16_t TriggerScript_0002::CallEvent(int event, tOSIRISEventInfo *data) { // Script 007: MainRoom1Entered if ((ScriptActionCtr_007 < 1) && (qObjIsPlayer(event_data->it_handle) == 1)) { aUserVarInc(4); - aShowHUDMessageObj(Message_strings[4], event_data->it_handle); + aShowHUDMessageObj(TXT("Area1"), event_data->it_handle); // Increment the script action counter if (ScriptActionCtr_007 < MAX_ACTION_CTR_VALUE) @@ -960,7 +772,7 @@ int16_t TriggerScript_0004::CallEvent(int event, tOSIRISEventInfo *data) { // Script 010: MainRoom3Entered if ((ScriptActionCtr_010 < 1) && (qObjIsPlayer(event_data->it_handle) == 1)) { aUserVarInc(4); - aShowHUDMessageObj(Message_strings[5], event_data->it_handle); + aShowHUDMessageObj(TXT("Area3"), event_data->it_handle); // Increment the script action counter if (ScriptActionCtr_010 < MAX_ACTION_CTR_VALUE) @@ -979,7 +791,7 @@ int16_t TriggerScript_0003::CallEvent(int event, tOSIRISEventInfo *data) { // Script 009: MainRoom2Entered if ((ScriptActionCtr_009 < 1) && (qObjIsPlayer(event_data->it_handle) == 1)) { aUserVarInc(4); - aShowHUDMessageObj(Message_strings[6], event_data->it_handle); + aShowHUDMessageObj(TXT("Area2"), event_data->it_handle); // Increment the script action counter if (ScriptActionCtr_009 < MAX_ACTION_CTR_VALUE) diff --git a/scripts/Level6.cpp b/scripts/Level6.cpp index d3d1735d3..3d7e7762e 100644 --- a/scripts/Level6.cpp +++ b/scripts/Level6.cpp @@ -22,10 +22,10 @@ // Filename: level6.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -1338,180 +1338,12 @@ void PriestPlaySoundAtNode(int node) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} +std::map Messages; -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -1684,7 +1516,6 @@ const char *Message_names[NUM_MESSAGE_NAMES] = {"FirstPickupBuilder", "BLANK", "Test", "BuildersPuzzhint"}; -const char *Message_strings[NUM_MESSAGE_NAMES]; // =============== // InitializeDLL() @@ -1701,26 +1532,16 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(uservars_as_int); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "level6.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { mprintf(0, "ERROR: Could not load message file - %s\n", filename); @@ -1767,10 +1588,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } @@ -2413,7 +2230,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 009: Collectors & Builders Key Correctly Placed if ((ScriptActionCtr_009 < 1) && ((qObjRoom(Object_handles[10]) == Room_indexes[2]) && (qObjRoom(Object_handles[7]) == Room_indexes[3]))) { - aShowHUDMessage(Message_strings[9]); + aShowHUDMessage(TXT("BuilderCollectorsCorrectlyPlaced")); aUserVarSet(1, 1.000000f); aGoalCompleted(Goal_indexes[3], 1); aObjSetMovementType(Object_handles[7], 0); @@ -2427,7 +2244,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 014: Priest Key Correctly Placed if ((ScriptActionCtr_014 < 1) && (qObjRoom(Object_handles[9]) == Room_indexes[1])) { - aShowHUDMessage(Message_strings[15]); + aShowHUDMessage(TXT("PriestKeyCorrectlyPlaced")); aGoalCompleted(Goal_indexes[4], 1); // Increment the script action counter @@ -2446,7 +2263,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 049: PriestPuzzleSolved if ((ScriptActionCtr_049 < 1) && (qUserVarValue(11) == 1.000000f)) { - aShowHUDMessage(Message_strings[25]); + aShowHUDMessage(TXT("PriestPuzzleSolved")); aSoundPlay2D(Sound_indexes[5], 1.000000f); // Increment the script action counter @@ -2457,7 +2274,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 050: Priest Puzzle, Player Goofed if (qUserVarValue(12) == 1.000000f) { aUserVarSet(12, 0.000000f); - aShowHUDMessage(Message_strings[26]); + aShowHUDMessage(TXT("PriestPuzzleGoofed")); aSoundPlay2D(Sound_indexes[6], 1.000000f); // Increment the script action counter @@ -2547,7 +2364,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 025: IntroCamera if (1) { aMusicSetRegionAll(1); - aCinematicIntro(Path_indexes[1], Message_strings[18], Object_handles[18], Path_indexes[2], 15.000000f); + aCinematicIntro(Path_indexes[1], TXT("IntroLevelMessage"), Object_handles[18], Path_indexes[2], 15.000000f); aSetLevelTimer(40.000000f, 5); // Increment the script action counter @@ -2595,7 +2412,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 088: Inventory Reminder Timer Goes Off if ((ScriptActionCtr_088 < 1) && (event_data->id == 10)) { - aAddGameMessage(Message_strings[3], Message_strings[4]); + aAddGameMessage(TXT("InvGame"), TXT("InvHUD")); // Increment the script action counter if (ScriptActionCtr_088 < MAX_ACTION_CTR_VALUE) @@ -2632,7 +2449,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 024: BossCameraMove if (event_data->id == 1) { - aCinematicSimple(Path_indexes[0], Message_strings[17], Object_handles[24], 14.000000f, 1); + aCinematicSimple(Path_indexes[0], TXT("BossIntroductionText"), Object_handles[24], 14.000000f, 1); aDoorSetPos(Door_handles[0], 1.000000f); // Increment the script action counter @@ -2644,7 +2461,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 044: BuildersWarningBeep if ((event_data->id == 4) && (qUserVarValue(3) != 1.000000f)) { - aShowHUDMessageObj(Message_strings[22], qObjSavedHandle(0)); + aShowHUDMessageObj(TXT("Builders3secondsleft"), qObjSavedHandle(0)); aSoundPlay2DObj(Sound_indexes[4], qObjSavedHandle(0), 1.000000f); // Increment the script action counter @@ -2656,7 +2473,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { if (event_data->id == 3) { aUserVarSet(5, 0.000000f); if (qHasObjectInInventory(qObjSavedHandle(0), Object_handles[7]) == 0) { - aShowHUDMessageObj(Message_strings[23], qObjSavedHandle(0)); + aShowHUDMessageObj(TXT("BuildersTimerExpired"), qObjSavedHandle(0)); aPortalRenderSet(0, 0, Room_indexes[8], 1); aPortalRenderSet(0, 1, Room_indexes[8], 1); aPortalRenderSet(1, 0, Room_indexes[9], 1); @@ -2712,8 +2529,8 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 055: MessageTugWarnsPlayer if ((ScriptActionCtr_055 < 1) && (event_data->id == 6)) { aSoundPlaySteaming("VoxL06SpecificC.osf", 1.000000f); - aShowHUDMessage(Message_strings[27]); - aShowHUDMessage(Message_strings[28]); + aShowHUDMessage(TXT("TugMessage1")); + aShowHUDMessage(TXT("TugMessage2")); aGoalCompleted(Goal_indexes[5], 1); aMatcenSetEnableState(1, Matcen_indexes[0]); aMatcenSetEnableState(1, Matcen_indexes[1]); @@ -2726,8 +2543,8 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 054: StartTugMessage if ((ScriptActionCtr_054 < 1) && (event_data->id == 5)) { aSoundPlaySteaming("VoxL06SpecificA.osf", 1.000000f); - aShowHUDMessage(Message_strings[29]); - aShowHUDMessage(Message_strings[30]); + aShowHUDMessage(TXT("TugMessageStart")); + aShowHUDMessage(TXT("TugStartMessage2")); // Increment the script action counter if (ScriptActionCtr_054 < MAX_ACTION_CTR_VALUE) @@ -2739,7 +2556,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aPortalRenderSet(0, 0, Room_indexes[16], 1); aPortalRenderSet(0, 0, Room_indexes[17], 1); aSoundPlaySteaming("VoxL06SpecificE.osf", 1.000000f); - aShowHUDMessage(Message_strings[31]); + aShowHUDMessage(TXT("TugMessageShipPickUp")); aAIGoalFollowPathSimple(Object_handles[27], Path_indexes[3], 4352, 0, 3); // Increment the script action counter @@ -2751,7 +2568,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_067 < 1) && ((event_data->id == 9) && ((ScriptActionCtr_085 > 0) == true))) { aAIGoalFollowPathSimple(Object_handles[27], Path_indexes[5], 1048832, 3, 3); aEnableShip("Phoenix"); - aCinematicSimple(Path_indexes[6], Message_strings[35], Object_handles[27], 18.000000f, 1); + aCinematicSimple(Path_indexes[6], TXT("BLANK"), Object_handles[27], 18.000000f, 1); aRoomSetWind(Room_indexes[0], 0.000000f, 0.000000f, 0.000000f, 0.000000f); // Increment the script action counter @@ -2861,7 +2678,7 @@ int16_t CustomObjectScript_208F::CallEvent(int event, tOSIRISEventInfo *data) { if ((qObjIsPlayer(event_data->it_handle) == 1) && ((qUserVarValue(0) == 1.000000f) && (qUserVarValue(1) != 1.000000f))) { if (qUserVarValue(3) == 0.000000f) { - aShowHUDMessage(Message_strings[0]); + aShowHUDMessage(TXT("FirstPickupBuilder")); aGoalCompleted(Goal_indexes[0], 1); aCancelTimer(3); } @@ -2895,11 +2712,11 @@ int16_t CustomObjectScript_208F::CallEvent(int event, tOSIRISEventInfo *data) { aMoveObjectToPositionClipboard(data->me_handle); aUserVarSet(0, 0.000000f); aSetLevelTimer(3.000000f, 0); - aShowHUDMessageObj(Message_strings[8], event_data->it_handle); + aShowHUDMessageObj(TXT("PlaceBuildersKey"), event_data->it_handle); } else { aObjGhostSet(0, data->me_handle); aAddObjectToInventory(data->me_handle, event_data->it_handle, 0); - aShowHUDMessageObj(Message_strings[6], event_data->it_handle); + aShowHUDMessageObj(TXT("KeyAlreadyThere"), event_data->it_handle); aStoreObjectInPositionClipboard(Object_handles[8]); aMoveObjectToPositionClipboard(data->me_handle); } @@ -2910,11 +2727,11 @@ int16_t CustomObjectScript_208F::CallEvent(int event, tOSIRISEventInfo *data) { aMoveObjectToPositionClipboard(data->me_handle); aUserVarSet(0, 0.000000f); aSetLevelTimer(3.000000f, 0); - aShowHUDMessageObj(Message_strings[8], event_data->it_handle); + aShowHUDMessageObj(TXT("PlaceBuildersKey"), event_data->it_handle); } else { aObjGhostSet(0, data->me_handle); aAddObjectToInventory(data->me_handle, event_data->it_handle, 0); - aShowHUDMessageObj(Message_strings[6], event_data->it_handle); + aShowHUDMessageObj(TXT("KeyAlreadyThere"), event_data->it_handle); aStoreObjectInPositionClipboard(Object_handles[8]); aMoveObjectToPositionClipboard(data->me_handle); } @@ -2922,7 +2739,7 @@ int16_t CustomObjectScript_208F::CallEvent(int event, tOSIRISEventInfo *data) { } else { aObjGhostSet(0, data->me_handle); aAddObjectToInventory(data->me_handle, event_data->it_handle, 0); - aShowHUDMessageObj(Message_strings[7], event_data->it_handle); + aShowHUDMessageObj(TXT("YoucantUseKeyHere"), event_data->it_handle); aStoreObjectInPositionClipboard(Object_handles[8]); aMoveObjectToPositionClipboard(data->me_handle); } @@ -2947,7 +2764,7 @@ int16_t CustomObjectScript_20BE::CallEvent(int event, tOSIRISEventInfo *data) { aStoreObjectInPositionClipboard(Object_handles[8]); aMoveObjectToPositionClipboard(data->me_handle); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); - aShowHUDMessage(Message_strings[1]); + aShowHUDMessage(TXT("FirstPickupPriest")); aGoalCompleted(Goal_indexes[1], 1); // Increment the script action counter @@ -2964,12 +2781,12 @@ int16_t CustomObjectScript_20BE::CallEvent(int event, tOSIRISEventInfo *data) { aObjGhostSet(0, data->me_handle); aStoreObjectInPositionClipboard(Object_handles[23]); aMoveObjectToPositionClipboard(data->me_handle); - aShowHUDMessageObj(Message_strings[16], event_data->it_handle); + aShowHUDMessageObj(TXT("PlacePriestKey"), event_data->it_handle); aDoorLockUnlock(0, Door_handles[4]); } else { aObjGhostSet(0, data->me_handle); aAddObjectToInventory(data->me_handle, event_data->it_handle, 0); - aShowHUDMessageObj(Message_strings[7], event_data->it_handle); + aShowHUDMessageObj(TXT("YoucantUseKeyHere"), event_data->it_handle); aStoreObjectInPositionClipboard(Object_handles[8]); aMoveObjectToPositionClipboard(data->me_handle); } @@ -2992,7 +2809,7 @@ int16_t CustomObjectScript_206F::CallEvent(int event, tOSIRISEventInfo *data) { if ((qObjIsPlayer(event_data->it_handle) == 1) && ((qUserVarValue(0) == 1.000000f) && (qUserVarValue(1) != 1.000000f))) { if (qUserVarValueInt(2) == 0) { - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("FirstPickupCollector")); aGoalCompleted(Goal_indexes[2], 1); } aAddObjectToInventory(data->me_handle, event_data->it_handle, 0); @@ -3027,11 +2844,11 @@ int16_t CustomObjectScript_206F::CallEvent(int event, tOSIRISEventInfo *data) { aMoveObjectToPositionClipboard(data->me_handle); aUserVarSet(0, 0.000000f); aSetLevelTimer(3.000000f, 0); - aShowHUDMessageObj(Message_strings[5], event_data->it_handle); + aShowHUDMessageObj(TXT("PlaceCollectorsKey"), event_data->it_handle); } else { aObjGhostSet(0, data->me_handle); aAddObjectToInventory(data->me_handle, event_data->it_handle, 0); - aShowHUDMessageObj(Message_strings[6], event_data->it_handle); + aShowHUDMessageObj(TXT("KeyAlreadyThere"), event_data->it_handle); aStoreObjectInPositionClipboard(Object_handles[8]); aMoveObjectToPositionClipboard(data->me_handle); } @@ -3042,11 +2859,11 @@ int16_t CustomObjectScript_206F::CallEvent(int event, tOSIRISEventInfo *data) { aMoveObjectToPositionClipboard(data->me_handle); aUserVarSet(0, 0.000000f); aSetLevelTimer(3.000000f, 0); - aShowHUDMessageObj(Message_strings[5], event_data->it_handle); + aShowHUDMessageObj(TXT("PlaceCollectorsKey"), event_data->it_handle); } else { aObjGhostSet(0, data->me_handle); aAddObjectToInventory(data->me_handle, event_data->it_handle, 0); - aShowHUDMessageObj(Message_strings[6], event_data->it_handle); + aShowHUDMessageObj(TXT("KeyAlreadyThere"), event_data->it_handle); aStoreObjectInPositionClipboard(Object_handles[8]); aMoveObjectToPositionClipboard(data->me_handle); } @@ -3054,7 +2871,7 @@ int16_t CustomObjectScript_206F::CallEvent(int event, tOSIRISEventInfo *data) { } else { aObjGhostSet(0, data->me_handle); aAddObjectToInventory(data->me_handle, event_data->it_handle, 0); - aShowHUDMessageObj(Message_strings[7], event_data->it_handle); + aShowHUDMessageObj(TXT("YoucantUseKeyHere"), event_data->it_handle); aStoreObjectInPositionClipboard(Object_handles[8]); aMoveObjectToPositionClipboard(data->me_handle); } @@ -3097,7 +2914,7 @@ int16_t CustomObjectScript_081D::CallEvent(int event, tOSIRISEventInfo *data) { if ((qObjRoom(Object_handles[10]) == Room_indexes[2]) && (qObjRoom(Object_handles[7]) == Room_indexes[3])) { aDoorActivate(Door_handles[3]); } else { - aShowHUDMessageObj(Message_strings[10], event_data->it_handle); + aShowHUDMessageObj(TXT("PriestHallDoorLocked"), event_data->it_handle); } // Increment the script action counter @@ -3121,7 +2938,7 @@ int16_t CustomObjectScript_081E::CallEvent(int event, tOSIRISEventInfo *data) { if (qObjRoom(Object_handles[9]) == Room_indexes[1]) { aDoorActivate(Door_handles[4]); } else { - aShowHUDMessageObj(Message_strings[11], event_data->it_handle); + aShowHUDMessageObj(TXT("PriestGalleryDoorLocked"), event_data->it_handle); } // Increment the script action counter @@ -3175,10 +2992,10 @@ int16_t CustomObjectScript_081C::CallEvent(int event, tOSIRISEventInfo *data) { if (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == 1) { if ((ScriptActionCtr_000 > 0) == 1) { aDoorLockUnlock(0, Door_handles[2]); - aShowHUDMessageObj(Message_strings[12], event_data->it_handle); + aShowHUDMessageObj(TXT("BuildersDoorMessage"), event_data->it_handle); aDoorActivate(data->me_handle); } else { - aShowHUDMessageObj(Message_strings[13], event_data->it_handle); + aShowHUDMessageObj(TXT("ThisDoorDoesNotAnswer"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[1], event_data->it_handle, 1.000000f); } @@ -3202,10 +3019,10 @@ int16_t CustomObjectScript_081B::CallEvent(int event, tOSIRISEventInfo *data) { if (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == 1) { if ((ScriptActionCtr_003 > 0) == 1) { aDoorLockUnlock(0, Door_handles[1]); - aShowHUDMessageObj(Message_strings[14], event_data->it_handle); + aShowHUDMessageObj(TXT("CollectorsDoorMessage"), event_data->it_handle); aDoorActivate(data->me_handle); } else { - aShowHUDMessageObj(Message_strings[13], event_data->it_handle); + aShowHUDMessageObj(TXT("ThisDoorDoesNotAnswer"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[1], event_data->it_handle, 1.000000f); } @@ -3339,7 +3156,7 @@ int16_t CustomObjectScript_1826::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_066 < 1) && ((qObjAnimFrame(Object_handles[24]) != 210.000000f) && (qUserVarValueInt(13) == 1))) { aSoundPlaySteaming("VoxL06SpecificF.osf", 1.000000f); - aShowHUDMessage(Message_strings[33]); + aShowHUDMessage(TXT("TugMessage4")); // Increment the script action counter if (ScriptActionCtr_066 < MAX_ACTION_CTR_VALUE) @@ -3350,7 +3167,7 @@ int16_t CustomObjectScript_1826::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_058 < 1) && (qObjAnimFrame(Object_handles[24]) == 350.000000f)) { aSoundPlaySteaming("VoxL06EndLevel.osf", 1.000000f); aSetLevelTimer(4.000000f, 9); - aShowHUDMessage(Message_strings[34]); + aShowHUDMessage(TXT("TugMessage6")); // Increment the script action counter if (ScriptActionCtr_058 < MAX_ACTION_CTR_VALUE) @@ -3391,7 +3208,7 @@ int16_t CustomObjectScript_08FD::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_085 < 1) && (event_data->goal_uid == 5)) { aAIGoalPickUpObject(data->me_handle, 0, Object_handles[28], 0, 1, 3, 4352, 1); aSoundPlaySteaming("VoxL06SpecificG.osf", 1.000000f); - aShowHUDMessage(Message_strings[32]); + aShowHUDMessage(TXT("TugMessage5")); // Increment the script action counter if (ScriptActionCtr_085 < MAX_ACTION_CTR_VALUE) @@ -3413,11 +3230,11 @@ int16_t CustomObjectScript_08FD::CallEvent(int event, tOSIRISEventInfo *data) { // Script 068: Start2ndPartCinematicAlt if ((ScriptActionCtr_068 < 2) && (1)) { if (ScriptActionCtr_068 == 0) { - aCinematicSimple(Path_indexes[8], Message_strings[35], data->me_handle, 10.000000f, 1); + aCinematicSimple(Path_indexes[8], TXT("BLANK"), data->me_handle, 10.000000f, 1); } if (ScriptActionCtr_068 == 1) { - aStartEndlevelSequencePath(Path_indexes[9], Path_indexes[10], 14.000000f, Message_strings[35]); - aShowHUDMessage(Message_strings[36]); + aStartEndlevelSequencePath(Path_indexes[9], Path_indexes[10], 14.000000f, TXT("BLANK")); + aShowHUDMessage(TXT("Test")); } // Increment the script action counter @@ -3436,7 +3253,7 @@ int16_t CustomObjectScript_180A::CallEvent(int event, tOSIRISEventInfo *data) { // Script 095: BossDoorLocked if (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == 1) { - aShowHUDMessage(Message_strings[35]); + aShowHUDMessage(TXT("BLANK")); // Increment the script action counter if (ScriptActionCtr_095 < MAX_ACTION_CTR_VALUE) @@ -3735,7 +3552,7 @@ int16_t TriggerScript_0001::CallEvent(int event, tOSIRISEventInfo *data) { aUserVarSet(15, qMathSubFloat(60.000000f, qMathMulFloat(qMathIntToFloat(qGetDifficulty()), 10.000000f))); aSetLevelTimer(qUserVarValue(15), 3); aTimerShow(3); - aShowHUDMessageObjF(Message_strings[19], event_data->it_handle, qUserVarValue(15)); + aShowHUDMessageObjF(TXT("XsecsOntheClock"), event_data->it_handle, qUserVarValue(15)); aSetLevelTimer(qMathSubFloat(qUserVarValue(15), 3.000000f), 4); aObjSaveHandle(event_data->it_handle, 0); @@ -3763,7 +3580,7 @@ int16_t TriggerScript_0002::CallEvent(int event, tOSIRISEventInfo *data) { aUserVarSet(15, qMathSubFloat(60.000000f, qMathMulFloat(qMathIntToFloat(qGetDifficulty()), 10.000000f))); aSetLevelTimer(qUserVarValue(15), 3); aTimerShow(3); - aShowHUDMessageObjF(Message_strings[19], event_data->it_handle, qUserVarValue(15)); + aShowHUDMessageObjF(TXT("XsecsOntheClock"), event_data->it_handle, qUserVarValue(15)); aSetLevelTimer(qMathSubFloat(qUserVarValue(15), 3.000000f), 4); aObjSaveHandle(event_data->it_handle, 0); @@ -4035,8 +3852,8 @@ int16_t TriggerScript_000F::CallEvent(int event, tOSIRISEventInfo *data) { // Script 043: BuildersPuzzleMessage if ((ScriptActionCtr_003 > 0) != 1) { - aShowHUDMessageObj(Message_strings[20], event_data->it_handle); - aShowHUDMessageObj(Message_strings[21], event_data->it_handle); + aShowHUDMessageObj(TXT("BuildersPuzzMessage"), event_data->it_handle); + aShowHUDMessageObj(TXT("BuildersPuzzMessage2"), event_data->it_handle); // Increment the script action counter if (ScriptActionCtr_043 < MAX_ACTION_CTR_VALUE) @@ -4085,7 +3902,7 @@ int16_t TriggerScript_0010::CallEvent(int event, tOSIRISEventInfo *data) { if (qObjIsPlayer(event_data->it_handle) == 1) { aPriestKeyEnter(event_data->it_handle); if (qUserVarValueInt(11) == 0) { - aShowHUDMessageObj(Message_strings[24], event_data->it_handle); + aShowHUDMessageObj(TXT("PriestPuzzleEnter"), event_data->it_handle); } // Increment the script action counter @@ -4304,7 +4121,7 @@ int16_t TriggerScript_0021::CallEvent(int event, tOSIRISEventInfo *data) { // Script 089: builders puzzle hint if ((ScriptActionCtr_089 < 1) && ((qObjIsPlayer(event_data->it_handle) == 1) && (qUserVarValueInt(14) == 0))) { - aShowHUDMessageObj(Message_strings[37], event_data->it_handle); + aShowHUDMessageObj(TXT("BuildersPuzzhint"), event_data->it_handle); aUserVarSet(14, 1.000000f); // Increment the script action counter @@ -4323,7 +4140,7 @@ int16_t TriggerScript_0022::CallEvent(int event, tOSIRISEventInfo *data) { // Script 090: builders puzzle hint 2 if ((ScriptActionCtr_090 < 1) && ((qObjIsPlayer(event_data->it_handle) == 1) && (qUserVarValueInt(14) == 0))) { - aShowHUDMessageObj(Message_strings[37], event_data->it_handle); + aShowHUDMessageObj(TXT("BuildersPuzzhint"), event_data->it_handle); aUserVarSet(14, 1.000000f); // Increment the script action counter diff --git a/scripts/Level6_Ger.msg b/scripts/Level6_GER.msg similarity index 100% rename from scripts/Level6_Ger.msg rename to scripts/Level6_GER.msg diff --git a/scripts/level6_SPN.msg b/scripts/Level6_SPN.msg similarity index 100% rename from scripts/level6_SPN.msg rename to scripts/Level6_SPN.msg diff --git a/scripts/Level9.cpp b/scripts/Level9.cpp index fc69d0e40..70a5dfb77 100644 --- a/scripts/Level9.cpp +++ b/scripts/Level9.cpp @@ -22,10 +22,10 @@ // Filename: level9.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -750,180 +750,12 @@ void RestoreGlobalActionCtrs(void *file_ptr) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} +std::map Messages; -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -1014,7 +846,6 @@ const char *Message_names[NUM_MESSAGE_NAMES] = { "CovLeaveMeAlone", "Testing2", "Testing", "CovRepaired", "CovGettingPummeled", "CovShutDown", "CovInClear", "CovDamaged", "CovDanger", "DestroyedRadar", "DestroyedAnt", "Transmitter"}; -const char *Message_strings[NUM_MESSAGE_NAMES]; // =============== // InitializeDLL() @@ -1029,26 +860,16 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "level9.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { mprintf(0, "ERROR: Could not load message file - %s\n", filename); @@ -1095,10 +916,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } @@ -1640,7 +1457,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 005: Intro Cam 2 if ((ScriptActionCtr_005 < 1) && (qUserFlag(2) == false)) { aSoundPlaySteaming("VoxL09StartLevel.osf", 1.000000f); - aCinematicIntro(Path_indexes[0], Message_strings[0], Object_handles[2], Path_indexes[1], 15.000000f); + aCinematicIntro(Path_indexes[0], TXT("IntroCam"), Object_handles[2], Path_indexes[1], 15.000000f); // Increment the script action counter if (ScriptActionCtr_005 < MAX_ACTION_CTR_VALUE) @@ -1696,7 +1513,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aUserVarAdd(40.000000f, 2); aGoalCompleted(Goal_indexes[5], 1); aUserFlagSet(3, 1); - aShowHUDMessage(Message_strings[19]); + aShowHUDMessage(TXT("AllStabsDone")); } aUserVarAdd(135.000000f, 2); @@ -1728,7 +1545,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 048: Are you done? if (event_data->id == 13) { - aCinematicSimple(Path_indexes[21], Message_strings[8], Object_handles[3], 10.000000f, 1); + aCinematicSimple(Path_indexes[21], TXT("EndLevel"), Object_handles[3], 10.000000f, 1); aEnableShip("Magnum-AHT"); // Increment the script action counter @@ -1754,7 +1571,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 034: Message for Transmitter if (1) { - aShowHUDMessage(Message_strings[1]); + aShowHUDMessage(TXT("TransmitterHave")); // Increment the script action counter if (ScriptActionCtr_034 < MAX_ACTION_CTR_VALUE) @@ -1775,7 +1592,7 @@ int16_t CustomObjectScript_081B::CallEvent(int event, tOSIRISEventInfo *data) { if (qRandomChance(0.100000f) == true) { aSoundPlaySteaming("VoxL09CargoH.osf", 1.000000f); } - aShowHUDMessage(Message_strings[20]); + aShowHUDMessage(TXT("CovLeaveMeAlone")); // Increment the script action counter if (ScriptActionCtr_079 < MAX_ACTION_CTR_VALUE) @@ -1812,7 +1629,7 @@ int16_t CustomObjectScript_081B::CallEvent(int event, tOSIRISEventInfo *data) { if (event_data->id == 16) { aSetObjectTimer(data->me_handle, 60.000000f, 16); aSoundPlaySteaming("VoxL09CargoM.osf", 1.000000f); - aShowHUDMessage(Message_strings[6]); + aShowHUDMessage(TXT("CovStillStuckFF")); // Increment the script action counter if (ScriptActionCtr_082 < MAX_ACTION_CTR_VALUE) @@ -1822,8 +1639,8 @@ int16_t CustomObjectScript_081B::CallEvent(int event, tOSIRISEventInfo *data) { // Script 078: MEGA State Timer Recycle if (event_data->id == 15) { if (1 == false) { - aShowHUDMessageF(Message_strings[21], qObjShields(Object_handles[3])); - aShowHUDMessageF(Message_strings[22], qUserVarValue(2)); + aShowHUDMessageF(TXT("Testing2"), qObjShields(Object_handles[3])); + aShowHUDMessageF(TXT("Testing"), qUserVarValue(2)); } if (qUserVarValue(3) > qObjShields(data->me_handle)) { aUserVarSet(1, 0.000000f); @@ -1840,7 +1657,7 @@ int16_t CustomObjectScript_081B::CallEvent(int event, tOSIRISEventInfo *data) { if ((15 == event_data->id) && (qUserVarValue(4) == 4.000000f)) { if ((qUserVarValue(2) > 320.000000f) || (qUserVarValue(1) > 30.000000f)) { aSoundPlaySteaming("VoxL09CargoK.osf", 1.000000f); - aShowHUDMessage(Message_strings[23]); + aShowHUDMessage(TXT("CovRepaired")); aObjSetShields(data->me_handle, qUserVarValue(5)); aUserVarSet(1, 0.000000f); aUserVarAdd(45.000000f, 2); @@ -1850,7 +1667,7 @@ int16_t CustomObjectScript_081B::CallEvent(int event, tOSIRISEventInfo *data) { if (qObjShields(data->me_handle) < 10.000000f) { aObjSetShields(data->me_handle, qUserVarValue(7)); aSoundPlaySteaming("VoxL09CargoF.osf", 1.000000f); - aShowHUDMessage(Message_strings[24]); + aShowHUDMessage(TXT("CovGettingPummeled")); } aUserVarInc(1); } @@ -1866,7 +1683,7 @@ int16_t CustomObjectScript_081B::CallEvent(int event, tOSIRISEventInfo *data) { if ((15 == event_data->id) && (qUserVarValue(4) == 3.000000f)) { if ((qUserVarValue(2) > 290.000000f) || (qUserVarValue(1) > 45.000000f)) { aSoundPlaySteaming("VoxL09CargoK.osf", 1.000000f); - aShowHUDMessage(Message_strings[23]); + aShowHUDMessage(TXT("CovRepaired")); aObjSetShields(data->me_handle, qUserVarValue(5)); aUserVarSet(1, 0.000000f); aUserVarAdd(40.000000f, 2); @@ -1875,7 +1692,7 @@ int16_t CustomObjectScript_081B::CallEvent(int event, tOSIRISEventInfo *data) { } else { if (qObjShields(data->me_handle) < qUserVarValue(7)) { aSoundPlaySteaming("VoxL09CargoL.osf", 1.000000f); - aShowHUDMessage(Message_strings[25]); + aShowHUDMessage(TXT("CovShutDown")); aUserVarSet(1, 0.000000f); aAISetTeam(65536, data->me_handle); aUserVarSet(4, 4.000000f); @@ -1895,7 +1712,7 @@ int16_t CustomObjectScript_081B::CallEvent(int event, tOSIRISEventInfo *data) { if ((15 == event_data->id) && (qUserVarValue(4) == 2.000000f)) { if ((qUserVarValue(2) > 200.000000f) || (qUserVarValue(1) > 60.000000f)) { aSoundPlaySteaming("VoxL09CargoG.osf", 1.000000f); - aShowHUDMessage(Message_strings[26]); + aShowHUDMessage(TXT("CovInClear")); aObjSetShields(data->me_handle, qUserVarValue(5)); aUserVarSet(1, 0.000000f); aUserVarAdd(35.000000f, 2); @@ -1904,7 +1721,7 @@ int16_t CustomObjectScript_081B::CallEvent(int event, tOSIRISEventInfo *data) { } else { if (qObjShields(data->me_handle) < qUserVarValue(6)) { aSoundPlaySteaming("VoxL09CargoA.osf", 1.000000f); - aShowHUDMessage(Message_strings[27]); + aShowHUDMessage(TXT("CovDamaged")); aUserVarSet(1, 0.000000f); aAISetTeam(65536, data->me_handle); aUserVarSet(4, 3.000000f); @@ -1923,7 +1740,7 @@ int16_t CustomObjectScript_081B::CallEvent(int event, tOSIRISEventInfo *data) { if ((15 == event_data->id) && (qUserVarValue(4) == 1.000000f)) { if (qUserVarValue(2) < 0.000000f) { aSoundPlaySteaming("VoxL09CargoB.osf", 1.000000f); - aShowHUDMessage(Message_strings[28]); + aShowHUDMessage(TXT("CovDanger")); aUserVarSet(1, 0.000000f); aUserVarSet(2, 0.000000f); aAISetTeam(65536, data->me_handle); @@ -1934,7 +1751,7 @@ int16_t CustomObjectScript_081B::CallEvent(int event, tOSIRISEventInfo *data) { aUserVarSet(2, 200.000000f); } aSoundPlaySteaming("VoxL09CargoA.osf", 1.000000f); - aShowHUDMessage(Message_strings[27]); + aShowHUDMessage(TXT("CovDamaged")); aUserVarSet(1, 0.000000f); aAISetTeam(65536, data->me_handle); aUserVarSet(4, 3.000000f); @@ -1963,7 +1780,7 @@ int16_t CustomObjectScript_081B::CallEvent(int event, tOSIRISEventInfo *data) { if (event_data->goal_uid == 0) { aObjMakeVulnerable(data->me_handle); aSoundPlaySteaming("VoxL09CargoD.osf", 1.000000f); - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("CovEntering")); aAIGoalFollowPathSimple(data->me_handle, Path_indexes[3], 1048832, 1, 3); // Increment the script action counter @@ -1974,7 +1791,7 @@ int16_t CustomObjectScript_081B::CallEvent(int event, tOSIRISEventInfo *data) { // Script 008: Covert Path-2 Pickup if (event_data->goal_uid == 1) { aSoundPlaySteaming("VoxL09CargoJ.osf", 1.000000f); - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("CovPickup")); aUserVarSub(3.000000f, 2); aAIGoalPickUpObject(data->me_handle, 0, Object_handles[8], 0, 1, 3, 256, 4); @@ -1995,7 +1812,7 @@ int16_t CustomObjectScript_081B::CallEvent(int event, tOSIRISEventInfo *data) { // Script 061: Covert Path-3 if (event_data->goal_uid == 3) { aSoundPlaySteaming("VoxL09CargoC.osf", 1.000000f); - aShowHUDMessage(Message_strings[4]); + aShowHUDMessage(TXT("CovDropOff")); aUnCloakObject(Object_handles[0]); aAIGoalPickUpObject(Object_handles[0], 0, Object_handles[8], 0, 1, 3, 256, -1); aDropObjects(data->me_handle); @@ -2014,7 +1831,7 @@ int16_t CustomObjectScript_081B::CallEvent(int event, tOSIRISEventInfo *data) { aSetObjectTimer(data->me_handle, 60.000000f, 16); aSoundPlaySteaming("VoxL09CargoE.osf", 1.000000f); aUserFlagSet(0, 1); - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("CovFFHelp")); } // Increment the script action counter @@ -2030,7 +1847,7 @@ int16_t CustomObjectScript_081B::CallEvent(int event, tOSIRISEventInfo *data) { aSetObjectTimer(data->me_handle, 60.000000f, 16); aUserFlagSet(1, 1); aSoundPlaySteaming("VoxL09CargoE.osf", 1.000000f); - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("CovFFHelp")); } // Increment the script action counter @@ -2041,7 +1858,7 @@ int16_t CustomObjectScript_081B::CallEvent(int event, tOSIRISEventInfo *data) { // Script 068: Covert Path-3 Pickup if (event_data->goal_uid == 6) { aSoundPlaySteaming("VoxL09CargoJ.osf", 1.000000f); - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("CovPickup")); aUserVarSub(3.000000f, 2); aAIGoalPickUpObject(data->me_handle, 0, Object_handles[9], 0, 1, 3, 256, 7); @@ -2062,7 +1879,7 @@ int16_t CustomObjectScript_081B::CallEvent(int event, tOSIRISEventInfo *data) { // Script 038: Covert Path-4 if (event_data->goal_uid == 8) { aSoundPlaySteaming("VoxL09CargoC.osf", 1.000000f); - aShowHUDMessage(Message_strings[4]); + aShowHUDMessage(TXT("CovDropOff")); aUnCloakObject(Object_handles[1]); aAIGoalPickUpObject(Object_handles[1], 0, Object_handles[9], 0, 1, 3, 256, -1); aDropObjects(data->me_handle); @@ -2076,7 +1893,7 @@ int16_t CustomObjectScript_081B::CallEvent(int event, tOSIRISEventInfo *data) { // Script 072: Covert Path-4 Pickup if (event_data->goal_uid == 9) { aSoundPlaySteaming("VoxL09CargoJ.osf", 1.000000f); - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("CovPickup")); aUserVarSub(3.000000f, 2); aAIGoalPickUpObject(data->me_handle, 0, Object_handles[10], 0, 1, 3, 256, 10); @@ -2097,7 +1914,7 @@ int16_t CustomObjectScript_081B::CallEvent(int event, tOSIRISEventInfo *data) { // Script 074: Covert Path-4 Done if (event_data->goal_uid == 11) { aSoundPlaySteaming("VoxL09CargoI.osf", 1.000000f); - aShowHUDMessage(Message_strings[7]); + aShowHUDMessage(TXT("CovLeaving")); aGoalCompleted(Goal_indexes[0], 1); aUserFlagSet(2, 1); aAIGoalFollowPathSimple(data->me_handle, Path_indexes[11], 1048832, -1, 3); @@ -2179,7 +1996,7 @@ int16_t CustomObjectScript_1030::CallEvent(int event, tOSIRISEventInfo *data) { aAIGoalFollowPathSimple(Object_handles[3], Path_indexes[6], 1048832, 5, 3); aCancelTimer(16); aSoundPlaySteaming("VoxL09CargoN.osf", 1.000000f); - aShowHUDMessage(Message_strings[9]); + aShowHUDMessage(TXT("CovThanksFF")); } aPortalRenderSet(0, 0, Room_indexes[0], 1); } @@ -2208,7 +2025,7 @@ int16_t CustomObjectScript_1038::CallEvent(int event, tOSIRISEventInfo *data) { aAIGoalFollowPathSimple(Object_handles[3], Path_indexes[6], 1048832, 5, 3); aCancelTimer(16); aSoundPlaySteaming("VoxL09CargoN.osf", 1.000000f); - aShowHUDMessage(Message_strings[9]); + aShowHUDMessage(TXT("CovThanksFF")); } aPortalRenderSet(0, 0, Room_indexes[0], 1); } @@ -2237,7 +2054,7 @@ int16_t CustomObjectScript_0869::CallEvent(int event, tOSIRISEventInfo *data) { aAIGoalFollowPathSimple(Object_handles[3], Path_indexes[7], 1048832, 6, 3); aSoundPlaySteaming("VoxL09CargoN.osf", 1.000000f); aCancelTimer(16); - aShowHUDMessage(Message_strings[9]); + aShowHUDMessage(TXT("CovThanksFF")); } aPortalRenderSet(0, 0, Room_indexes[1], 1); } @@ -2266,7 +2083,7 @@ int16_t CustomObjectScript_086A::CallEvent(int event, tOSIRISEventInfo *data) { aAIGoalFollowPathSimple(Object_handles[3], Path_indexes[7], 1048832, 6, 3); aCancelTimer(16); aSoundPlaySteaming("VoxL09CargoN.osf", 1.000000f); - aShowHUDMessage(Message_strings[9]); + aShowHUDMessage(TXT("CovThanksFF")); } aPortalRenderSet(0, 0, Room_indexes[1], 1); } @@ -2288,7 +2105,7 @@ int16_t CustomObjectScript_106E::CallEvent(int event, tOSIRISEventInfo *data) { // Script 044: Disruptor Powerup 4 if (qObjIsPlayer(event_data->it_handle) == true) { aSetLevelTimer(0.000000f, 14); - aShowHUDMessage(Message_strings[10]); + aShowHUDMessage(TXT("Disruptor")); aAddObjectToInventory(data->me_handle, event_data->it_handle, 0); aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); @@ -2345,7 +2162,7 @@ int16_t CustomObjectScript_106F::CallEvent(int event, tOSIRISEventInfo *data) { // Script 043: Disruptor Powerup 3 if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[10]); + aShowHUDMessage(TXT("Disruptor")); aAddObjectToInventory(data->me_handle, event_data->it_handle, 0); aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); aSetLevelTimer(0.000000f, 14); @@ -2403,7 +2220,7 @@ int16_t CustomObjectScript_106D::CallEvent(int event, tOSIRISEventInfo *data) { // Script 042: Disruptor Powerup 2 if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[10]); + aShowHUDMessage(TXT("Disruptor")); aAddObjectToInventory(data->me_handle, event_data->it_handle, 0); aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); aSetLevelTimer(0.000000f, 14); @@ -2461,7 +2278,7 @@ int16_t CustomObjectScript_106C::CallEvent(int event, tOSIRISEventInfo *data) { // Script 040: Disruptor Powerup 1 if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[10]); + aShowHUDMessage(TXT("Disruptor")); aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); aAddObjectToInventory(data->me_handle, event_data->it_handle, 0); aSetLevelTimer(0.000000f, 14); @@ -2524,7 +2341,7 @@ int16_t CustomObjectScript_100F::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[2], data->me_handle, 1.000000f); aAttachObject("seismicdisruptor", 0, Object_handles[7], 1); aObjSpark(data->me_handle, 40.000000f, 999999.000000f); - aCinematicSimple(Path_indexes[17], Message_strings[11], Object_handles[7], 6.000000f, 0); + aCinematicSimple(Path_indexes[17], TXT("StabControlDone"), Object_handles[7], 6.000000f, 0); // Increment the script action counter if (ScriptActionCtr_045 < MAX_ACTION_CTR_VALUE) @@ -2561,7 +2378,7 @@ int16_t CustomObjectScript_0871::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[3], data->me_handle, 1.000000f); aObjPlayAnim(data->me_handle, 0, 4, 2.000000f, 0); aObjPlayAnim(Object_handles[7], 2, 5, 2.000000f, 0); - aShowHUDMessage(Message_strings[12]); + aShowHUDMessage(TXT("StabControlPower")); // Increment the script action counter if (ScriptActionCtr_049 < MAX_ACTION_CTR_VALUE) @@ -2583,7 +2400,7 @@ int16_t CustomObjectScript_0811::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[2], data->me_handle, 1.000000f); aAttachObject("seismicdisruptor", 0, data->me_handle, 1); aObjSpark(data->me_handle, 40.000000f, 999999.000000f); - aCinematicSimple(Path_indexes[18], Message_strings[13], data->me_handle, 6.000000f, 0); + aCinematicSimple(Path_indexes[18], TXT("StabStoreDone"), data->me_handle, 6.000000f, 0); aSetLevelTimer(0.000000f, 11); // Increment the script action counter @@ -2620,7 +2437,7 @@ int16_t CustomObjectScript_0810::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[2], data->me_handle, 1.000000f); aAttachObject("seismicdisruptor", 0, data->me_handle, 1); aObjSpark(data->me_handle, 40.000000f, 999999.000000f); - aCinematicSimple(Path_indexes[19], Message_strings[14], data->me_handle, 6.000000f, 0); + aCinematicSimple(Path_indexes[19], TXT("StabAssemblyDone"), data->me_handle, 6.000000f, 0); aSetLevelTimer(0.000000f, 11); // Increment the script action counter @@ -2657,7 +2474,7 @@ int16_t CustomObjectScript_080E::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[2], data->me_handle, 1.000000f); aAttachObject("seismicdisruptor", 0, data->me_handle, 1); aObjSpark(data->me_handle, 40.000000f, 999999.000000f); - aCinematicSimple(Path_indexes[20], Message_strings[15], data->me_handle, 6.000000f, 0); + aCinematicSimple(Path_indexes[20], TXT("StabFactoryDone"), data->me_handle, 6.000000f, 0); aSetLevelTimer(0.000000f, 11); // Increment the script action counter @@ -2695,7 +2512,7 @@ int16_t CustomObjectScript_0873::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[3], data->me_handle, 1.000000f); aObjPlayAnim(data->me_handle, 0, 4, 2.000000f, 0); aObjPlayAnim(Object_handles[4], 2, 5, 2.000000f, 0); - aShowHUDMessage(Message_strings[16]); + aShowHUDMessage(TXT("StabStorePower")); // Increment the script action counter if (ScriptActionCtr_067 < MAX_ACTION_CTR_VALUE) @@ -2718,7 +2535,7 @@ int16_t CustomObjectScript_0872::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[3], data->me_handle, 1.000000f); aObjPlayAnim(data->me_handle, 0, 4, 2.000000f, 0); aObjPlayAnim(Object_handles[5], 2, 5, 2.000000f, 0); - aShowHUDMessage(Message_strings[17]); + aShowHUDMessage(TXT("StabAssemblyPower")); // Increment the script action counter if (ScriptActionCtr_066 < MAX_ACTION_CTR_VALUE) @@ -2741,7 +2558,7 @@ int16_t CustomObjectScript_2070::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[3], data->me_handle, 1.000000f); aObjPlayAnim(data->me_handle, 0, 4, 2.000000f, 0); aObjPlayAnim(Object_handles[6], 2, 5, 2.000000f, 0); - aShowHUDMessage(Message_strings[18]); + aShowHUDMessage(TXT("StabFactoryPower")); // Increment the script action counter if (ScriptActionCtr_065 < MAX_ACTION_CTR_VALUE) @@ -2763,7 +2580,7 @@ int16_t CustomObjectScript_18AA::CallEvent(int event, tOSIRISEventInfo *data) { // Script 081: Radar-2 Destroyed if (1) { - aShowHUDMessage(Message_strings[29]); + aShowHUDMessage(TXT("DestroyedRadar")); aUserVarAdd(25.000000f, 2); // Increment the script action counter @@ -2786,7 +2603,7 @@ int16_t CustomObjectScript_18C1::CallEvent(int event, tOSIRISEventInfo *data) { // Script 004: Radar-1 Destroyed if (1) { - aShowHUDMessage(Message_strings[29]); + aShowHUDMessage(TXT("DestroyedRadar")); aUserVarAdd(25.000000f, 2); // Increment the script action counter @@ -2809,7 +2626,7 @@ int16_t CustomObjectScript_0948::CallEvent(int event, tOSIRISEventInfo *data) { // Script 003: Ant-3 Destroyed if (1) { - aShowHUDMessage(Message_strings[30]); + aShowHUDMessage(TXT("DestroyedAnt")); aUserVarAdd(20.000000f, 2); // Increment the script action counter @@ -2832,7 +2649,7 @@ int16_t CustomObjectScript_0949::CallEvent(int event, tOSIRISEventInfo *data) { // Script 002: Ant-2 Destroyed if (1) { - aShowHUDMessage(Message_strings[30]); + aShowHUDMessage(TXT("DestroyedAnt")); aUserVarAdd(20.000000f, 2); // Increment the script action counter @@ -2855,7 +2672,7 @@ int16_t CustomObjectScript_18AC::CallEvent(int event, tOSIRISEventInfo *data) { // Script 001: Ant-1 Destroyed if (1) { - aShowHUDMessage(Message_strings[30]); + aShowHUDMessage(TXT("DestroyedAnt")); aUserVarAdd(20.000000f, 2); // Increment the script action counter @@ -2899,7 +2716,7 @@ int16_t CustomObjectScript_094E::CallEvent(int event, tOSIRISEventInfo *data) { // Script 086: Transmitter USE if (1) { - aShowHUDMessageObj(Message_strings[31], event_data->it_handle); + aShowHUDMessageObj(TXT("Transmitter"), event_data->it_handle); aSoundPlay2D(Sound_indexes[5], 1.000000f); aCreatePopupView(0, Object_handles[3], 10.000000f, 1.000000f); aObjGhostSet(0, data->me_handle); @@ -2921,7 +2738,7 @@ int16_t TriggerScript_0001::CallEvent(int event, tOSIRISEventInfo *data) { // Script 010: EndLevel-Factory if ((ScriptActionCtr_010 < 1) && (qUserFlag(4) == true)) { - aStartEndlevelSequencePath(Path_indexes[13], Path_indexes[14], 12.000000f, Message_strings[8]); + aStartEndlevelSequencePath(Path_indexes[13], Path_indexes[14], 12.000000f, TXT("EndLevel")); // Increment the script action counter if (ScriptActionCtr_010 < MAX_ACTION_CTR_VALUE) @@ -2930,7 +2747,7 @@ int16_t TriggerScript_0001::CallEvent(int event, tOSIRISEventInfo *data) { // Script 053: EndLevel-Storage if ((ScriptActionCtr_053 < 1) && (qUserFlag(4) == true)) { - aStartEndlevelSequencePath(Path_indexes[15], Path_indexes[16], 12.000000f, Message_strings[8]); + aStartEndlevelSequencePath(Path_indexes[15], Path_indexes[16], 12.000000f, TXT("EndLevel")); // Increment the script action counter if (ScriptActionCtr_053 < MAX_ACTION_CTR_VALUE) diff --git a/scripts/Level9_Ger.msg b/scripts/Level9_GER.msg similarity index 100% rename from scripts/Level9_Ger.msg rename to scripts/Level9_GER.msg diff --git a/scripts/level9_SPN.msg b/scripts/Level9_SPN.msg similarity index 100% rename from scripts/level9_SPN.msg rename to scripts/Level9_SPN.msg diff --git a/scripts/LevelS1.cpp b/scripts/LevelS1.cpp index 25ab0f0e0..191ad0ec8 100644 --- a/scripts/LevelS1.cpp +++ b/scripts/LevelS1.cpp @@ -22,10 +22,10 @@ // Filename: levels1.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -235,180 +235,12 @@ void RestoreGlobalActionCtrs(void *file_ptr) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} +std::map Messages; -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -454,12 +286,6 @@ int *Matcen_indexes = NULL; const char *Goal_names[NUM_GOAL_NAMES] = {"Find Area 1", "Find Area 3", "Find Area 2", "Explore the hidden facility"}; int Goal_indexes[NUM_GOAL_NAMES]; -#define NUM_MESSAGE_NAMES 8 -const char *Message_names[NUM_MESSAGE_NAMES] = { - "IntroBriefingMessage", "IntroHUDmessage", "EntranceDoorMessage", "Area1", "Area3", "Area2", - "EndLevelMessage", "Nothing"}; -const char *Message_strings[NUM_MESSAGE_NAMES]; - // =============== // InitializeDLL() // =============== @@ -473,26 +299,16 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "levels1.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { mprintf(0, "ERROR: Could not load message file - %s\n", filename); @@ -539,10 +355,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } @@ -739,7 +551,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aRoomSetWind(Room_indexes[7], 0.000000f, -1.000000f, 0.000000f, 20.000000f); aSetLevelTimer(20.000000f, 6); aSetLevelTimer(19.250000f, 7); - aShowHUDMessage(Message_strings[6]); + aShowHUDMessage(TXT("EndLevelMessage")); // Increment the script action counter if (ScriptActionCtr_016 < MAX_ACTION_CTR_VALUE) @@ -767,7 +579,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aRoomSetWind(Room_indexes[1], 1.000000f, 0.000000f, 0.000000f, 30.000000f); aRoomSetWind(Room_indexes[2], -1.000000f, 0.000000f, 0.000000f, 30.000000f); aRoomSetWind(Room_indexes[3], -1.000000f, 0.000000f, 0.000000f, 30.000000f); - aAddGameMessage(Message_strings[0], Message_strings[1]); + aAddGameMessage(TXT("IntroBriefingMessage"), TXT("IntroHUDmessage")); aUserVarSet(0, 0.000000f); aUserVarSet(1, 0.000000f); aUserVarSet(2, 0.000000f); @@ -874,7 +686,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 017: EndLevelSequencePart2 if ((ScriptActionCtr_017 < 1) && (event_data->id == 6)) { aSoundPlayObject(Sound_indexes[1], Object_handles[6], 1.000000f); - aStartEndlevelSequencePath(Path_indexes[0], Path_indexes[1], 8.000000f, Message_strings[7]); + aStartEndlevelSequencePath(Path_indexes[0], Path_indexes[1], 8.000000f, TXT("Nothing")); aTurnOnSpew(Object_handles[7], -1, 7, 0.000000f, 0.000000f, 65536, 0, 1.500000f, 0.150000f, 30.000000f, 4.000000f, 20.000000f, 1, -1); aLightningCreate(Object_handles[7], Object_handles[6], 999999995904.000000f, 6.000000f, 1, Texture_indexes[2], @@ -910,7 +722,7 @@ int16_t CustomObjectScript_0804::CallEvent(int event, tOSIRISEventInfo *data) { // Script 004: EntranceDoorMessage if (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == 1) { - aShowHUDMessageObj(Message_strings[2], event_data->it_handle); + aShowHUDMessageObj(TXT("EntranceDoorMessage"), event_data->it_handle); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -930,7 +742,7 @@ int16_t TriggerScript_0002::CallEvent(int event, tOSIRISEventInfo *data) { // Script 007: MainRoom1Entered if ((ScriptActionCtr_007 < 1) && (qObjIsPlayer(event_data->it_handle) == 1)) { aUserVarInc(4); - aShowHUDMessageObj(Message_strings[3], event_data->it_handle); + aShowHUDMessageObj(TXT("Area1"), event_data->it_handle); aGoalCompleted(Goal_indexes[0], 1); // Increment the script action counter @@ -950,7 +762,7 @@ int16_t TriggerScript_0004::CallEvent(int event, tOSIRISEventInfo *data) { // Script 010: MainRoom3Entered if ((ScriptActionCtr_010 < 1) && (qObjIsPlayer(event_data->it_handle) == 1)) { aUserVarInc(4); - aShowHUDMessageObj(Message_strings[4], event_data->it_handle); + aShowHUDMessageObj(TXT("Area3"), event_data->it_handle); aRoomSetWind(Room_indexes[1], -1.000000f, 0.000000f, 0.000000f, 30.000000f); aRoomSetWind(Room_indexes[3], -1.000000f, 0.000000f, 0.000000f, 30.000000f); aRoomSetWind(Room_indexes[2], 1.000000f, 0.000000f, 0.000000f, 30.000000f); @@ -975,7 +787,7 @@ int16_t TriggerScript_0003::CallEvent(int event, tOSIRISEventInfo *data) { // Script 009: MainRoom2Entered if ((ScriptActionCtr_009 < 1) && (qObjIsPlayer(event_data->it_handle) == 1)) { aUserVarInc(4); - aShowHUDMessageObj(Message_strings[5], event_data->it_handle); + aShowHUDMessageObj(TXT("Area2"), event_data->it_handle); aRoomSetWind(Room_indexes[3], 1.000000f, 0.000000f, 0.000000f, 30.000000f); aRoomSetWind(Room_indexes[1], -1.000000f, 0.000000f, 0.000000f, 30.000000f); aRoomSetWind(Room_indexes[2], -1.000000f, 0.000000f, 0.000000f, 30.000000f); diff --git a/scripts/LEVELS1_FRN.msg b/scripts/LevelS1_FRN.msg similarity index 100% rename from scripts/LEVELS1_FRN.msg rename to scripts/LevelS1_FRN.msg diff --git a/scripts/LevelS1_Ger.msg b/scripts/LevelS1_GER.msg similarity index 100% rename from scripts/LevelS1_Ger.msg rename to scripts/LevelS1_GER.msg diff --git a/scripts/levels1_SPN.msg b/scripts/LevelS1_SPN.msg similarity index 100% rename from scripts/levels1_SPN.msg rename to scripts/LevelS1_SPN.msg diff --git a/scripts/Merc02.cpp b/scripts/Merc02.cpp index bed94d7d2..4de9070d4 100644 --- a/scripts/Merc02.cpp +++ b/scripts/Merc02.cpp @@ -22,10 +22,10 @@ // Filename: Merc02.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -1173,180 +1173,12 @@ int qConvertFloatToTextureID(float value) { return ((int)value); } // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} +std::map Messages; -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} - -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -1639,40 +1471,6 @@ const char *Goal_names[NUM_GOAL_NAMES] = {"Disable Forcefields in Laser Room A", "Deactivate Central Forcefield"}; int Goal_indexes[NUM_GOAL_NAMES]; -#define NUM_MESSAGE_NAMES 31 -const char *Message_names[NUM_MESSAGE_NAMES] = {"IntroText", - "InfectedDataCartridgeName", - "LaserBeamTriggered", - "ScanTowerEntered", - "MainGateOpening", - "ScanStarted", - "GateSecurityAlerted", - "WpnCheckEntered", - "WeaponCheckAborted", - "WpnCheckStarted", - "WeaponsRemoved", - "WeaponsChecked", - "WeaponGuardHit", - "FoundBackDoor", - "TurretControlDown", - "WorkerMessage", - "Empty", - "GeneralDead", - "DataCartridgeName", - "DataCartridgeUsed", - "InfectedDataPlaced", - "DataCartridgeStillThere", - "TooFarFromDataPosition", - "EscapeTime", - "EndGuards", - "ExitDoor", - "ArmoryDoorUnlocked", - "CentralFFDown", - "SecCamSpottedUs", - "ResAreaEntrance", - "NeedAWeapon"}; -const char *Message_strings[NUM_MESSAGE_NAMES]; - // =============== // InitializeDLL() // =============== @@ -1686,37 +1484,19 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - char english_filename[(_MAX_PATH + 32) * 2]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - snprintf(english_filename, sizeof(english_filename), "%s.msg", filename); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); - else if (lang_type == LANGUAGE_POLISH) - strcat(filename, "_POL"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "Merc02.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { - if (lang_type == LANGUAGE_ENGLISH) { - mprintf(0, "ERROR: Could not load message file - %s\n", filename); - } else if (!ReadMessageFile(english_filename)) { - mprintf(0, "ERROR: Could not load message file - %s\n", english_filename); - } + mprintf(0, "ERROR: Could not load message file - %s\n", filename); } int j; @@ -1760,10 +1540,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } @@ -2434,7 +2210,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { (qBeamHittingPlayer(Object_handles[35], Object_handles[36]) == true) || (qBeamHittingPlayer(Object_handles[29], Object_handles[30]) == true) || (qBeamHittingPlayer(Object_handles[37], Object_handles[38]) == true)) { - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("LaserBeamTriggered")); aUserFlagSet(14, 1); aPortalRenderSet(1, 0, Room_indexes[1], 0); aPortalRenderSet(1, 1, Room_indexes[2], 0); @@ -2460,7 +2236,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { (qBeamHittingPlayer(Object_handles[21], Object_handles[22]) == true) || (qBeamHittingPlayer(Object_handles[23], Object_handles[24]) == true) || (qBeamHittingPlayer(Object_handles[25], Object_handles[26]) == true)) { - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("LaserBeamTriggered")); aUserFlagSet(13, 1); aPortalRenderSet(1, 0, Room_indexes[3], 0); aPortalRenderSet(1, 1, Room_indexes[4], 0); @@ -2667,7 +2443,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 002: Level Start - Intro Cinematic if (1 == true) { - aCinematicIntro(Path_indexes[0], Message_strings[0], Object_handles[17], Path_indexes[1], 15.000000f); + aCinematicIntro(Path_indexes[0], TXT("IntroText"), Object_handles[17], Path_indexes[1], 15.000000f); aMusicSetRegionAll(0); aSetLevelTimer(18.000000f, 26); @@ -2833,7 +2609,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aUserFlagSet(0, 0); aDoorLockUnlock(0, Door_handles[0]); aDoorSetPos(Door_handles[0], 1.000000f); - aShowHUDMessage(Message_strings[4]); + aShowHUDMessage(TXT("MainGateOpening")); aGoalCompleted(Goal_indexes[2], 1); } else { if (qObjGetDistance(Object_handles[17], qObjSavedHandle(2)) < 20.000000f) { @@ -2855,7 +2631,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlaySteaming("VoxMerc02FCV2.osf", 1.000000f); aRoomSetFaceTexture(Room_indexes[15], 45, Texture_indexes[8]); aRoomSetFaceTexture(Room_indexes[15], 30, Texture_indexes[8]); - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ScanStarted")); aSetLevelTimer(4.000000f, 2); } } @@ -2892,7 +2668,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aDoorSetPos(Door_handles[0], 0.000000f); if (qGoalCompleted(Goal_indexes[3]) == false) { aDoorLockUnlock(1, Door_handles[0]); - aShowHUDMessage(Message_strings[6]); + aShowHUDMessage(TXT("GateSecurityAlerted")); aGoalEnableDisable(0, Goal_indexes[2]); aGoalEnableDisable(1, Goal_indexes[4]); } @@ -2933,7 +2709,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aRoomSetFaceTexture(Room_indexes[0], 1, Texture_indexes[8]); aRoomSetFaceTexture(Room_indexes[0], 2, Texture_indexes[8]); aSoundPlaySteaming("VoxMerc02FCV2.osf", 1.000000f); - aShowHUDMessage(Message_strings[8]); + aShowHUDMessage(TXT("WeaponCheckAborted")); aUserFlagSet(6, 0); aAISetMaxSpeed(qObjSavedHandle(6), 13.000000f); aPortalRenderSet(0, 0, Room_indexes[0], 1); @@ -2946,7 +2722,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aObjSaveHandle(qPlayerClosest(Object_handles[18], 3), 5); if (qUserVarValue(3) < 15.000000f) { aSoundPlaySteaming("VoxMerc02FCV1.osf", 1.000000f); - aShowHUDMessage(Message_strings[9]); + aShowHUDMessage(TXT("WpnCheckStarted")); aRoomSetFaceTexture(Room_indexes[0], 1, Texture_indexes[5]); aRoomSetFaceTexture(Room_indexes[0], 2, Texture_indexes[5]); aMatcenSetEnableState(1, Matcen_indexes[0]); @@ -2986,7 +2762,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aRoomSetFog(Room_indexes[0], 0.000000f, 1.000000f, 0.000000f, 1000.000000f); aRoomFogSetState(1, Room_indexes[0]); aRoomChangeFog(Room_indexes[0], 0.000000f, 1.000000f, 0.000000f, 200.000000f, 6.000000f); - aShowHUDMessage(Message_strings[12]); + aShowHUDMessage(TXT("WeaponGuardHit")); aSoundPlayObject(Sound_indexes[1], Object_handles[18], 1.000000f); aUserVarSet(2, 0.000000f); aSetLevelTimer(6.000000f, 7); @@ -3052,7 +2828,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aObjDestroy(Object_handles[63]); aObjSetMovementType(Object_handles[73], 1); aObjDestroy(Object_handles[3]); - aShowHUDMessage(Message_strings[15]); + aShowHUDMessage(TXT("WorkerMessage")); } if (ScriptActionCtr_063 == 2) { aObjSetMovementType(Object_handles[74], 1); @@ -3070,7 +2846,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 065: Do General Landing Sequence if (event_data->id == 15) { if (ScriptActionCtr_065 == 0) { - aCinematicSimple(Path_indexes[36], Message_strings[16], Object_handles[65], 17.000000f, 1); + aCinematicSimple(Path_indexes[36], TXT("Empty"), Object_handles[65], 17.000000f, 1); aAISetMaxSpeed(Object_handles[65], 15.000000f); aAIGoalFollowPathSimple(Object_handles[65], Path_indexes[37], 1048832, 27, 3); aSetLevelTimer(2.000000f, 15); @@ -3232,7 +3008,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aEmitSparks(30.000000f, Object_handles[81]); aGoalCompleted(Goal_indexes[14], 1); aGoalEnableDisable(1, Goal_indexes[15]); - aShowHUDMessage(Message_strings[23]); + aShowHUDMessage(TXT("EscapeTime")); aMusicSetRegionAll(3); } @@ -3353,7 +3129,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 020: Weapon Guard Entered if (event_data->goal_uid == 0) { - aShowHUDMessage(Message_strings[10]); + aShowHUDMessage(TXT("WeaponsRemoved")); aAttachExistingObject(Object_handles[48], 0, event_data->it_handle, 0); aObjGhostSet(0, Object_handles[48]); aStripWeaponsEnergyFromAll(); @@ -3380,7 +3156,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aPortalRenderSet(0, 3, Room_indexes[0], 1); aPortalRenderSet(0, 0, Room_indexes[0], 1); aPortalRenderSet(1, 0, Room_indexes[0], 0); - aShowHUDMessage(Message_strings[11]); + aShowHUDMessage(TXT("WeaponsChecked")); aGoalCompleted(Goal_indexes[5], 1); } else { aRoomSetFaceTexture(Room_indexes[0], 1, Texture_indexes[9]); @@ -3598,9 +3374,9 @@ int16_t CustomObjectScript_1119::CallEvent(int event, tOSIRISEventInfo *data) { // Script 088: Player picked up Infected Data Cartridge if (qObjIsPlayer(event_data->it_handle) == true) { if (qUserFlag(25) == false) { - aShowHUDMessage(Message_strings[1]); + aShowHUDMessage(TXT("InfectedDataCartridgeName")); aSoundPlayObject(Sound_indexes[3], event_data->it_handle, 1.000000f); - aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, Message_strings[1], 0); + aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, TXT("InfectedDataCartridgeName"), 0); } // Increment the script action counter @@ -3613,7 +3389,7 @@ int16_t CustomObjectScript_1119::CallEvent(int event, tOSIRISEventInfo *data) { // Script 086: Give Closest Player the Infected Data Cartridge if ((ScriptActionCtr_086 < 1) && (qObjType(qPlayerClosest(data->me_handle, 8)) == 4)) { - aAddObjectToInventoryNamed(data->me_handle, qPlayerClosest(data->me_handle, 8), Message_strings[1], 0); + aAddObjectToInventoryNamed(data->me_handle, qPlayerClosest(data->me_handle, 8), TXT("InfectedDataCartridgeName"), 0); // Increment the script action counter if (ScriptActionCtr_086 < MAX_ACTION_CTR_VALUE) @@ -3629,20 +3405,20 @@ int16_t CustomObjectScript_1119::CallEvent(int event, tOSIRISEventInfo *data) { if (qUserFlag(24) == true) { aGoalCompleted(Goal_indexes[13], 1); aUserFlagSet(25, 1); - aShowHUDMessage(Message_strings[20]); + aShowHUDMessage(TXT("InfectedDataPlaced")); aStoreObjectInPositionClipboard(Object_handles[104]); aMoveObjectToPositionClipboard(data->me_handle); aObjGhostSet(0, data->me_handle); aSetLevelTimer(1.000000f, 19); } else { - aShowHUDMessage(Message_strings[21]); + aShowHUDMessage(TXT("DataCartridgeStillThere")); aObjGhostSet(0, data->me_handle); - aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, Message_strings[1], 0); + aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, TXT("InfectedDataCartridgeName"), 0); } } else { - aShowHUDMessage(Message_strings[22]); + aShowHUDMessage(TXT("TooFarFromDataPosition")); aObjGhostSet(0, data->me_handle); - aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, Message_strings[1], 0); + aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, TXT("InfectedDataCartridgeName"), 0); } // Increment the script action counter @@ -4146,7 +3922,7 @@ int16_t CustomObjectScript_10CF::CallEvent(int event, tOSIRISEventInfo *data) { aRoomSetFaceTexture(Room_indexes[15], 45, Texture_indexes[5]); aRoomSetFaceTexture(Room_indexes[15], 30, Texture_indexes[5]); aUserFlagSet(0, 1); - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("ScanTowerEntered")); aSetLevelTimer(0.500000f, 1); // Increment the script action counter @@ -4244,7 +4020,7 @@ int16_t CustomObjectScript_103F::CallEvent(int event, tOSIRISEventInfo *data) { aObjMakeVulnerable(Object_handles[62]); aObjDestroy(Object_handles[62]); if (qGoalEnabled(Goal_indexes[6]) == true) { - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("FoundBackDoor")); } aGoalCompleted(Goal_indexes[6], 1); if (qGoalCompleted(Goal_indexes[7]) == false) { @@ -4273,7 +4049,7 @@ int16_t CustomObjectScript_08DE::CallEvent(int event, tOSIRISEventInfo *data) { // Script 026: Turret Control Destroyed if (1) { - aShowHUDMessage(Message_strings[14]); + aShowHUDMessage(TXT("TurretControlDown")); aSetLevelTimer(2.000000f, 16); aGoalCompleted(Goal_indexes[10], 1); @@ -4297,7 +4073,7 @@ int16_t CustomObjectScript_110E::CallEvent(int event, tOSIRISEventInfo *data) { // Script 107: General is Dead if (1) { - aShowHUDMessage(Message_strings[17]); + aShowHUDMessage(TXT("GeneralDead")); aGoalCompleted(Goal_indexes[11], 1); // Increment the script action counter @@ -4354,8 +4130,8 @@ int16_t CustomObjectScript_10CD::CallEvent(int event, tOSIRISEventInfo *data) { if (qObjIsPlayer(event_data->it_handle) == true) { aUserFlagSet(24, 1); aSoundPlayObject(Sound_indexes[3], event_data->it_handle, 1.000000f); - aShowHUDMessage(Message_strings[18]); - aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, Message_strings[18], 0); + aShowHUDMessage(TXT("DataCartridgeName")); + aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, TXT("DataCartridgeName"), 0); aGoalCompleted(Goal_indexes[12], 1); // Increment the script action counter @@ -4368,9 +4144,9 @@ int16_t CustomObjectScript_10CD::CallEvent(int event, tOSIRISEventInfo *data) { // Script 070: Player Used Data Cartridge if (1) { - aShowHUDMessage(Message_strings[19]); + aShowHUDMessage(TXT("DataCartridgeUsed")); aObjGhostSet(0, data->me_handle); - aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, Message_strings[18], 0); + aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, TXT("DataCartridgeName"), 0); // Increment the script action counter if (ScriptActionCtr_070 < MAX_ACTION_CTR_VALUE) @@ -4397,7 +4173,7 @@ int16_t CustomObjectScript_08A6::CallEvent(int event, tOSIRISEventInfo *data) { if (qUserVarValue(7) >= 2.000000f) { aDoorLockUnlock(0, Door_handles[5]); aDoorSetPos(Door_handles[5], 1.000000f); - aShowHUDMessage(Message_strings[25]); + aShowHUDMessage(TXT("ExitDoor")); aGoalCompleted(Goal_indexes[16], 1); aMusicSetRegionAll(4); } @@ -4427,7 +4203,7 @@ int16_t CustomObjectScript_08A5::CallEvent(int event, tOSIRISEventInfo *data) { if (qUserVarValue(7) >= 2.000000f) { aDoorLockUnlock(0, Door_handles[5]); aDoorSetPos(Door_handles[5], 1.000000f); - aShowHUDMessage(Message_strings[25]); + aShowHUDMessage(TXT("ExitDoor")); aGoalCompleted(Goal_indexes[16], 1); aMusicSetRegionAll(4); } @@ -4449,7 +4225,7 @@ int16_t CustomObjectScript_1112::CallEvent(int event, tOSIRISEventInfo *data) { // Script 080: Armory Door Switch Hit if ((ScriptActionCtr_080 < 1) && (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true)) { aDoorLockUnlock(0, Door_handles[6]); - aShowHUDMessage(Message_strings[26]); + aShowHUDMessage(TXT("ArmoryDoorUnlocked")); aObjPlayAnim(data->me_handle, 0, 1, 2.000000f, 0); aSoundPlayObject(Sound_indexes[5], data->me_handle, 1.000000f); @@ -4470,7 +4246,7 @@ int16_t CustomObjectScript_0913::CallEvent(int event, tOSIRISEventInfo *data) { // Script 081: Central FF Switch Hit if ((ScriptActionCtr_081 < 1) && (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true)) { aPortalRenderSet(0, 2, Room_indexes[22], 1); - aShowHUDMessage(Message_strings[27]); + aShowHUDMessage(TXT("CentralFFDown")); aObjPlayAnim(data->me_handle, 0, 3, 4.000000f, 0); aSoundPlayObject(Sound_indexes[6], data->me_handle, 1.000000f); aGoalCompleted(Goal_indexes[17], 1); @@ -4510,7 +4286,7 @@ int16_t CustomObjectScript_084A::CallEvent(int event, tOSIRISEventInfo *data) { // Script 101: Check Restricted Hall A Camera 1 if ((ScriptActionCtr_101 < 1) && (qSecurityCameraAlerted(data->me_handle) == true)) { - aShowHUDMessage(Message_strings[28]); + aShowHUDMessage(TXT("SecCamSpottedUs")); aAISetState(1, Object_handles[55]); aObjSetMovementType(Object_handles[8], 1); aObjSetLightingDist(Object_handles[8], 70.000000f); @@ -4552,7 +4328,7 @@ int16_t CustomObjectScript_1111::CallEvent(int event, tOSIRISEventInfo *data) { // Script 102: Check Restricted Hall A Camera 2 if ((ScriptActionCtr_102 < 1) && (qSecurityCameraAlerted(data->me_handle) == true)) { - aShowHUDMessage(Message_strings[28]); + aShowHUDMessage(TXT("SecCamSpottedUs")); aAISetState(1, Object_handles[56]); aObjSetMovementType(Object_handles[9], 1); aObjSetLightingDist(Object_handles[9], 70.000000f); @@ -4594,7 +4370,7 @@ int16_t CustomObjectScript_088C::CallEvent(int event, tOSIRISEventInfo *data) { // Script 103: Check Armory Camera if ((ScriptActionCtr_103 < 1) && (qSecurityCameraAlerted(data->me_handle) == true)) { - aShowHUDMessage(Message_strings[28]); + aShowHUDMessage(TXT("SecCamSpottedUs")); aAISetState(1, Object_handles[57]); aObjSetMovementType(Object_handles[10], 1); aObjSetLightingDist(Object_handles[10], 70.000000f); @@ -4636,7 +4412,7 @@ int16_t CustomObjectScript_0883::CallEvent(int event, tOSIRISEventInfo *data) { // Script 104: Check Res Hall C Camera if ((ScriptActionCtr_104 < 1) && (qSecurityCameraAlerted(data->me_handle) == true)) { - aShowHUDMessage(Message_strings[28]); + aShowHUDMessage(TXT("SecCamSpottedUs")); aAISetState(1, Object_handles[58]); aObjSetMovementType(Object_handles[11], 1); aObjSetLightingDist(Object_handles[11], 70.000000f); @@ -4678,7 +4454,7 @@ int16_t CustomObjectScript_106F::CallEvent(int event, tOSIRISEventInfo *data) { // Script 105: Check Hall C Camera 1 if ((ScriptActionCtr_105 < 1) && (qSecurityCameraAlerted(data->me_handle) == true)) { - aShowHUDMessage(Message_strings[28]); + aShowHUDMessage(TXT("SecCamSpottedUs")); aAISetState(1, Object_handles[59]); aObjSetMovementType(Object_handles[12], 1); aObjSetLightingDist(Object_handles[12], 70.000000f); @@ -4720,7 +4496,7 @@ int16_t CustomObjectScript_0894::CallEvent(int event, tOSIRISEventInfo *data) { // Script 106: Check Hall C Camera 2 if ((ScriptActionCtr_106 < 1) && (qSecurityCameraAlerted(data->me_handle) == true)) { - aShowHUDMessage(Message_strings[28]); + aShowHUDMessage(TXT("SecCamSpottedUs")); aAISetState(1, Object_handles[60]); aObjSetMovementType(Object_handles[13], 1); aObjSetLightingDist(Object_handles[13], 70.000000f); @@ -4764,7 +4540,7 @@ int16_t CustomObjectScript_0806::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_108 < 1) && (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true)) { aSoundPlaySteaming("VoxMerc02FPA1.osf", 1.000000f); if ((qGoalEnabled(Goal_indexes[6]) == false) && (qGoalCompleted(Goal_indexes[6]) == false)) { - aShowHUDMessage(Message_strings[29]); + aShowHUDMessage(TXT("ResAreaEntrance")); aGoalEnableDisable(1, Goal_indexes[6]); aGoalEnableDisable(0, Goal_indexes[8]); aGoalEnableDisable(1, Goal_indexes[9]); @@ -4918,7 +4694,7 @@ int16_t TriggerScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { if (qUserVarValue(1) == 2.000000f) { aDoorLockUnlock(0, Door_handles[0]); aDoorSetPos(Door_handles[0], 1.000000f); - aShowHUDMessage(Message_strings[4]); + aShowHUDMessage(TXT("MainGateOpening")); aGoalItemCompleted(Goal_indexes[4], 1, 1); aGoalCompleted(Goal_indexes[4], 1); } @@ -4946,7 +4722,7 @@ int16_t TriggerScript_0001::CallEvent(int event, tOSIRISEventInfo *data) { if (qUserVarValue(1) == 2.000000f) { aDoorLockUnlock(0, Door_handles[0]); aDoorSetPos(Door_handles[0], 1.000000f); - aShowHUDMessage(Message_strings[4]); + aShowHUDMessage(TXT("MainGateOpening")); aGoalItemCompleted(Goal_indexes[4], 2, 1); aGoalCompleted(Goal_indexes[4], 1); } @@ -4989,7 +4765,7 @@ int16_t TriggerScript_0003::CallEvent(int event, tOSIRISEventInfo *data) { // Script 017: Entered Weapon Check Point if ((qObjIsPlayer(event_data->it_handle) == true) && (qUserFlag(3) == 0)) { - aShowHUDMessage(Message_strings[7]); + aShowHUDMessage(TXT("WpnCheckEntered")); aUserFlagSet(3, 1); aSetLevelTimer(3.000000f, 5); @@ -5088,7 +4864,7 @@ int16_t TriggerScript_000A::CallEvent(int event, tOSIRISEventInfo *data) { // Script 072: End Trooper Trigger Hit if ((ScriptActionCtr_072 < 1) && (qObjIsPlayer(event_data->it_handle) == true)) { - aShowHUDMessage(Message_strings[24]); + aShowHUDMessage(TXT("EndGuards")); aAISetState(1, Object_handles[47]); aAIGoalFollowPathSimple(Object_handles[47], Path_indexes[48], 4352, -1, 3); aObjMakeVulnerable(Object_handles[70]); @@ -5134,7 +4910,7 @@ int16_t TriggerScript_000C::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_085 < 1) && (qObjIsPlayer(event_data->it_handle) == true)) { aEnableShip("Black Pyro"); aDisableShip("Phoenix"); - aStartEndlevelSequencePath(Path_indexes[58], Path_indexes[59], 5.000000f, Message_strings[16]); + aStartEndlevelSequencePath(Path_indexes[58], Path_indexes[59], 5.000000f, TXT("Empty")); aGoalCompleted(Goal_indexes[15], 1); // Increment the script action counter @@ -5155,7 +4931,7 @@ int16_t TriggerScript_000E::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_109 < 1) && (qObjIsPlayer(event_data->it_handle) == true)) { if ((qGoalEnabled(Goal_indexes[6]) == true) && (qGoalCompleted(Goal_indexes[6]) == false) && (qGoalCompleted(Goal_indexes[7]) == false)) { - aShowHUDMessage(Message_strings[30]); + aShowHUDMessage(TXT("NeedAWeapon")); aGoalEnableDisable(1, Goal_indexes[7]); } diff --git a/scripts/Merc1.cpp b/scripts/Merc1.cpp index aee67bd18..21d944ae3 100644 --- a/scripts/Merc1.cpp +++ b/scripts/Merc1.cpp @@ -22,10 +22,10 @@ // Filename: Merc1.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -1666,180 +1666,12 @@ void aEmitSparks(float num_sparks, int objhandle) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} - -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; +std::map Messages; - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -2213,26 +2045,6 @@ const char *Goal_names[NUM_GOAL_NAMES] = {"Locate Industrial Power Ducts", "Dis "Override Emergency Duct Doors"}; int Goal_indexes[NUM_GOAL_NAMES]; -#define NUM_MESSAGE_NAMES 17 -const char *Message_names[NUM_MESSAGE_NAMES] = {"IntroCam1", - "BlankMessage", - "BombName", - "NuclearDisruption", - "NuclearDisruptorFail", - "FCOneMinute", - "GameGetToWasteDisposal", - "FCFindBombShelter", - "FCAbandoned", - "FCNoContact", - "FCGetOut", - "CityAccessDoors", - "Trap", - "Last1", - "Last2", - "WallHint", - "GetAwayFromExit"}; -const char *Message_strings[NUM_MESSAGE_NAMES]; - // =============== // InitializeDLL() // =============== @@ -2246,37 +2058,19 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - char english_filename[(_MAX_PATH + 32) * 2]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - snprintf(english_filename, sizeof(english_filename), "%s.msg", filename); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); - else if (lang_type == LANGUAGE_POLISH) - strcat(filename, "_POL"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "Merc1.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { - if (lang_type == LANGUAGE_ENGLISH) { - mprintf(0, "ERROR: Could not load message file - %s\n", filename); - } else if (!ReadMessageFile(english_filename)) { - mprintf(0, "ERROR: Could not load message file - %s\n", english_filename); - } + mprintf(0, "ERROR: Could not load message file - %s\n", filename); } int j; @@ -2320,10 +2114,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } @@ -3409,7 +3199,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 197: WallHint (Rookie or Trainee only!) if ((ScriptActionCtr_197 < 1) && ((qRoomHasPlayer(Room_indexes[0]) == true) && (qGetDifficulty() < 2))) { - aShowHUDMessage(Message_strings[15]); + aShowHUDMessage(TXT("WallHint")); // Increment the script action counter if (ScriptActionCtr_197 < MAX_ACTION_CTR_VALUE) @@ -3504,7 +3294,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aObjGhostSet(1, Object_handles[33]); aObjGhostSet(1, Object_handles[34]); aObjGhostSet(1, Object_handles[35]); - aCinematicSimple(Path_indexes[0], Message_strings[0], Object_handles[36], 8.000000f, 1); + aCinematicSimple(Path_indexes[0], TXT("IntroCam1"), Object_handles[36], 8.000000f, 1); // Increment the script action counter if (ScriptActionCtr_016 < MAX_ACTION_CTR_VALUE) @@ -3755,7 +3545,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 054: USED Bomb Danger1 if ((ScriptActionCtr_054 < 1) && (event_data->id == 8)) { aSetLevelTimer(qRandomValue(3.000000f, 7.000000f), 14); - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("FCOneMinute")); aSoundPlayObject(Sound_indexes[9], Object_handles[81], 1.000000f); aEmitSparks(30.000000f, Object_handles[86]); aMiscViewerShake(100.000000f); @@ -3799,7 +3589,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 195: Final Countdown Complete if ((ScriptActionCtr_195 < 1) && (event_data->id == 11)) { aSetLevelTimer(3.800000f, 16); - aFadeWhiteAndEndlevel(4.000000f, Message_strings[1]); + aFadeWhiteAndEndlevel(4.000000f, TXT("BlankMessage")); // Increment the script action counter if (ScriptActionCtr_195 < MAX_ACTION_CTR_VALUE) @@ -3808,8 +3598,8 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 193: Final Countdown 4 if ((ScriptActionCtr_193 < 1) && (event_data->id == 13)) { - aAddGameMessage(Message_strings[6], Message_strings[6]); - aShowHUDMessage(Message_strings[7]); + aAddGameMessage(TXT("GameGetToWasteDisposal"), TXT("GameGetToWasteDisposal")); + aShowHUDMessage(TXT("FCFindBombShelter")); // Increment the script action counter if (ScriptActionCtr_193 < MAX_ACTION_CTR_VALUE) @@ -3822,7 +3612,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aGoalEnableDisable(1, Goal_indexes[2]); aGoalEnableDisable(0, Goal_indexes[3]); aSetLevelTimer(7.000000f, 13); - aShowColoredHUDMessage(255, 0, 0, Message_strings[8]); + aShowColoredHUDMessage(255, 0, 0, TXT("FCAbandoned")); // Increment the script action counter if (ScriptActionCtr_192 < MAX_ACTION_CTR_VALUE) @@ -3831,7 +3621,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 191: Final Countdown 2 if ((ScriptActionCtr_191 < 1) && (event_data->id == 10)) { - aShowHUDMessage(Message_strings[9]); + aShowHUDMessage(TXT("FCNoContact")); // Increment the script action counter if (ScriptActionCtr_191 < MAX_ACTION_CTR_VALUE) @@ -3840,7 +3630,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 190: Final Countdown 1 if ((ScriptActionCtr_190 < 1) && (event_data->id == 9)) { - aShowHUDMessage(Message_strings[10]); + aShowHUDMessage(TXT("FCGetOut")); // Increment the script action counter if (ScriptActionCtr_190 < MAX_ACTION_CTR_VALUE) @@ -3879,7 +3669,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aSetObjectTimer(Object_handles[77], 10.000000f, -1); aSetObjectTimer(Object_handles[79], 12.500000f, -1); aSetObjectTimer(Object_handles[81], 14.000000f, -1); - aCinematicSimple(Path_indexes[16], Message_strings[1], Object_handles[94], 18.000000f, 1); + aCinematicSimple(Path_indexes[16], TXT("BlankMessage"), Object_handles[94], 18.000000f, 1); // Increment the script action counter if (ScriptActionCtr_124 < MAX_ACTION_CTR_VALUE) @@ -4262,7 +4052,7 @@ int16_t CustomObjectScript_2027::CallEvent(int event, tOSIRISEventInfo *data) { aObjGhostSet(0, Object_handles[33]); aAISetMaxSpeed(Object_handles[33], 60.000000f); aAIGoalFollowPathSimple(Object_handles[33], Path_indexes[1], 1048832, -1, 3); - aCinematicSimple(Path_indexes[2], Message_strings[1], Object_handles[37], 9.000000f, 1); + aCinematicSimple(Path_indexes[2], TXT("BlankMessage"), Object_handles[37], 9.000000f, 1); // Increment the script action counter if (ScriptActionCtr_053 < MAX_ACTION_CTR_VALUE) @@ -4285,7 +4075,7 @@ int16_t CustomObjectScript_0820::CallEvent(int event, tOSIRISEventInfo *data) { aObjGhostSet(0, Object_handles[34]); aAIGoalFollowPathSimple(Object_handles[34], Path_indexes[3], 1048832, -1, 3); aSoundPlaySteaming("VoxMerc1Airlock.osf", 1.000000f); - aCinematicSimple(Path_indexes[4], Message_strings[1], Object_handles[38], 7.000000f, 1); + aCinematicSimple(Path_indexes[4], TXT("BlankMessage"), Object_handles[38], 7.000000f, 1); // Increment the script action counter if (ScriptActionCtr_017 < MAX_ACTION_CTR_VALUE) @@ -4317,7 +4107,7 @@ int16_t CustomObjectScript_0831::CallEvent(int event, tOSIRISEventInfo *data) { 5.000000f, 40.000000f, 0, 3); aTurnOnSpew(Object_handles[44], -1, 8, 0.000000f, 0.000000f, 65536, 0, 1.500000f, 0.100000f, 15.000000f, 5.000000f, 40.000000f, 0, 2); - aCinematicSimple(Path_indexes[5], Message_strings[1], Object_handles[45], 6.000000f, 1); + aCinematicSimple(Path_indexes[5], TXT("BlankMessage"), Object_handles[45], 6.000000f, 1); // Increment the script action counter if (ScriptActionCtr_018 < MAX_ACTION_CTR_VALUE) @@ -4348,7 +4138,7 @@ int16_t CustomObjectScript_0832::CallEvent(int event, tOSIRISEventInfo *data) { aTurnOnSpew(Object_handles[50], -1, 7, 0.000000f, 0.000000f, 65536, 0, 0.800000f, 0.100000f, 17.000000f, 2.000000f, 11.000000f, 0, 8); aSetLevelTimer(3.000000f, 2); - aCinematicSimple(Path_indexes[6], Message_strings[1], Object_handles[51], 6.500000f, 1); + aCinematicSimple(Path_indexes[6], TXT("BlankMessage"), Object_handles[51], 6.500000f, 1); // Increment the script action counter if (ScriptActionCtr_019 < MAX_ACTION_CTR_VALUE) @@ -4372,7 +4162,7 @@ int16_t CustomObjectScript_0836::CallEvent(int event, tOSIRISEventInfo *data) { aAISetMaxSpeed(Object_handles[31], 40.000000f); aAIGoalFollowPathSimple(Object_handles[32], Path_indexes[7], 4352, -1, 3); aAIGoalFollowPathSimple(Object_handles[31], Path_indexes[8], 4352, -1, 3); - aCinematicSimple(Path_indexes[9], Message_strings[1], Object_handles[52], 5.500000f, 1); + aCinematicSimple(Path_indexes[9], TXT("BlankMessage"), Object_handles[52], 5.500000f, 1); // Increment the script action counter if (ScriptActionCtr_027 < MAX_ACTION_CTR_VALUE) @@ -4392,7 +4182,7 @@ int16_t CustomObjectScript_0836::CallEvent(int event, tOSIRISEventInfo *data) { aAIGoalFollowPathSimple(Object_handles[35], Path_indexes[10], 1048832, -1, 3); aDoorLockUnlock(1, Door_handles[0]); aSetLevelTimer(4.000000f, 1); - aCinematicIntro(Path_indexes[11], Message_strings[1], Object_handles[33], Path_indexes[12], 8.000000f); + aCinematicIntro(Path_indexes[11], TXT("BlankMessage"), Object_handles[33], Path_indexes[12], 8.000000f); // Increment the script action counter if (ScriptActionCtr_028 < MAX_ACTION_CTR_VALUE) @@ -4616,7 +4406,7 @@ int16_t CustomObjectScript_188C::CallEvent(int event, tOSIRISEventInfo *data) { // Script 052: PICKUP Bomb if (qObjIsPlayer(event_data->it_handle) == true) { - aAddObjectToInventoryNamed(data->me_handle, qPlayerClosest(data->me_handle, -1), Message_strings[2], 0); + aAddObjectToInventoryNamed(data->me_handle, qPlayerClosest(data->me_handle, -1), TXT("BombName"), 0); // Increment the script action counter if (ScriptActionCtr_052 < MAX_ACTION_CTR_VALUE) @@ -4634,7 +4424,7 @@ int16_t CustomObjectScript_188C::CallEvent(int event, tOSIRISEventInfo *data) { aObjSetLightingDist(Object_handles[84], 0.000000f); aObjSetLightingDist(Object_handles[85], 0.000000f); aObjGhostSet(1, Object_handles[86]); - aAddObjectToInventoryNamed(data->me_handle, qPlayerClosest(data->me_handle, -1), Message_strings[2], 0); + aAddObjectToInventoryNamed(data->me_handle, qPlayerClosest(data->me_handle, -1), TXT("BombName"), 0); // Increment the script action counter if (ScriptActionCtr_050 < MAX_ACTION_CTR_VALUE) @@ -4671,10 +4461,10 @@ int16_t CustomObjectScript_188C::CallEvent(int event, tOSIRISEventInfo *data) { aSetLevelTimer(20.000000f, 10); aSetLevelTimer(45.000000f, 12); aSetLevelTimer(qMathAddFloat(60.000000f, qUserVarValue(2)), 8); - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("NuclearDisruption")); aSoundPlayObject(Sound_indexes[8], event_data->it_handle, 1.000000f); } else { - aShowColoredHUDMessageObj(255, 0, 0, Message_strings[4], event_data->it_handle); + aShowColoredHUDMessageObj(255, 0, 0, TXT("NuclearDisruptorFail"), event_data->it_handle); aObjGhostSet(0, data->me_handle); aAddObjectToInventory(data->me_handle, event_data->it_handle, 0); } @@ -4780,7 +4570,7 @@ int16_t CustomObjectScript_096D::CallEvent(int event, tOSIRISEventInfo *data) { aAIGoalFollowPathSimple(Object_handles[87], Path_indexes[17], 4352, -1, 3); aRoomFogSetState(1, Room_indexes[10]); aRoomChangeFog(Room_indexes[10], 0.800000f, 0.500000f, 0.200000f, 200.000000f, 10.000000f); - aCinematicSimple(Path_indexes[18], Message_strings[1], Object_handles[111], 9.000000f, 1); + aCinematicSimple(Path_indexes[18], TXT("BlankMessage"), Object_handles[111], 9.000000f, 1); // Increment the script action counter if (ScriptActionCtr_170 < MAX_ACTION_CTR_VALUE) @@ -4992,7 +4782,7 @@ int16_t CustomObjectScript_1170::CallEvent(int event, tOSIRISEventInfo *data) { 30.000000f, 150.000000f, 0, 2); aAIGoalFollowPathSimple(Object_handles[88], Path_indexes[19], 4352, -1, 3); aAIGoalFollowPathSimple(Object_handles[89], Path_indexes[20], 4352, -1, 3); - aCinematicSimple(Path_indexes[21], Message_strings[1], Object_handles[139], 9.000000f, 1); + aCinematicSimple(Path_indexes[21], TXT("BlankMessage"), Object_handles[139], 9.000000f, 1); // Increment the script action counter if (ScriptActionCtr_180 < MAX_ACTION_CTR_VALUE) @@ -5214,7 +5004,7 @@ int16_t CustomObjectScript_1984::CallEvent(int event, tOSIRISEventInfo *data) { 5.000000f, 30.000000f, 0, 2); aTurnOnSpew(Object_handles[147], -1, 7, 0.000000f, 0.000000f, 65536, 0, 1.300000f, 0.100000f, 10.000000f, 5.000000f, 30.000000f, 0, 2); - aStartEndlevelSequencePath(Path_indexes[22], Path_indexes[23], 8.000000f, Message_strings[1]); + aStartEndlevelSequencePath(Path_indexes[22], Path_indexes[23], 8.000000f, TXT("BlankMessage")); // Increment the script action counter if (ScriptActionCtr_198 < MAX_ACTION_CTR_VALUE) @@ -5598,7 +5388,7 @@ int16_t CustomObjectScript_08AE::CallEvent(int event, tOSIRISEventInfo *data) { // Script 073: HangSwitch Hit if ((ScriptActionCtr_073 < 1) && (qObjIsPlayerWeapon(event_data->it_handle) == true)) { aGoalCompleted(Goal_indexes[5], 1); - aShowHUDMessage(Message_strings[11]); + aShowHUDMessage(TXT("CityAccessDoors")); aDoorLockUnlock(0, Door_handles[6]); aDoorLockUnlock(0, Door_handles[7]); aTurnOnSpew(Object_handles[166], -1, 7, 0.000000f, 0.000000f, 65536, 0, 1.000000f, 0.100000f, 10.000000f, @@ -6868,7 +6658,7 @@ int16_t CustomObjectScript_112E::CallEvent(int event, tOSIRISEventInfo *data) { // Script 142: Ambush! if ((ScriptActionCtr_142 < 1) && (qObjCanSeePlayer(360, Object_handles[252], 140.000000f) == true)) { aGoalEnableDisable(1, Goal_indexes[7]); - aShowHUDMessage(Message_strings[12]); + aShowHUDMessage(TXT("Trap")); aLightningCreate(Object_handles[159], Object_handles[253], 99999.000000f, 3.000000f, 1, Texture_indexes[3], 0.400000f, 3, 50, 200, 220, 0); aLightningCreate(Object_handles[158], Object_handles[254], 99999.000000f, 3.000000f, 1, Texture_indexes[3], @@ -7013,7 +6803,7 @@ int16_t CustomObjectScript_0967::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_163 > 0) == true) { aSetObjectTimer(Object_handles[273], 0.000000f, -1); } else { - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("Last1")); } aTurnOnSpew(Object_handles[274], -1, 7, 0.000000f, 0.000000f, 65536, 0, 1.200000f, 0.100000f, -1.000000f, 4.000000f, 35.000000f, 0, -1); @@ -7032,7 +6822,7 @@ int16_t CustomObjectScript_0967::CallEvent(int event, tOSIRISEventInfo *data) { // Script 166: LastAmbush Part2 if ((ScriptActionCtr_166 < 1) && (1)) { aGoalCompleted(Goal_indexes[8], 1); - aShowHUDMessage(Message_strings[14]); + aShowHUDMessage(TXT("Last2")); aDoorLockUnlock(0, Door_handles[8]); aDoorLockUnlock(0, Door_handles[9]); aDoorLockUnlock(1, Door_handles[10]); @@ -7058,7 +6848,7 @@ int16_t CustomObjectScript_0966::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_164 > 0) == true) { aSetObjectTimer(Object_handles[273], 0.000000f, -1); } else { - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("Last1")); } aTurnOnSpew(Object_handles[276], -1, 7, 0.000000f, 0.000000f, 65536, 0, 1.200000f, 0.100000f, -1.000000f, 4.000000f, 35.000000f, 0, -1); @@ -7103,7 +6893,7 @@ int16_t CustomObjectScript_0809::CallEvent(int event, tOSIRISEventInfo *data) { // Script 208: HitExitDoorAfterBeingToldToGoDown if ((qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) && ((ScriptActionCtr_193 > 0) == true)) { - aShowHUDMessage(Message_strings[16]); + aShowHUDMessage(TXT("GetAwayFromExit")); // Increment the script action counter if (ScriptActionCtr_208 < MAX_ACTION_CTR_VALUE) @@ -7439,7 +7229,7 @@ int16_t TriggerScript_0013::CallEvent(int event, tOSIRISEventInfo *data) { aGoalEnableDisable(1, Goal_indexes[2]); aGoalEnableDisable(0, Goal_indexes[3]); aSetLevelTimer(7.000000f, 13); - aShowColoredHUDMessage(255, 0, 0, Message_strings[8]); + aShowColoredHUDMessage(255, 0, 0, TXT("FCAbandoned")); // Increment the script action counter if (ScriptActionCtr_199 < MAX_ACTION_CTR_VALUE) diff --git a/scripts/Merc3.cpp b/scripts/Merc3.cpp index 97b1806e8..356a827b9 100644 --- a/scripts/Merc3.cpp +++ b/scripts/Merc3.cpp @@ -22,10 +22,10 @@ // Filename: Merc3.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "osiris_vector.h" @@ -2324,180 +2324,12 @@ void dsCustomRestore(void *fileptr) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} +std::map Messages; -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} - -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -2898,77 +2730,6 @@ const char *Goal_names[NUM_GOAL_NAMES] = {"Unlock Hangar 1A Exit Door", "Escape from the station"}; int Goal_indexes[NUM_GOAL_NAMES]; -#define NUM_MESSAGE_NAMES 68 -const char *Message_names[NUM_MESSAGE_NAMES] = {"Bomb3", - "IntroCinematicMsg", - "EmptyMessage", - "HangarPrimaryLocked", - "Hangar1ADecompMsg", - "Hangar1ADecompCancelMsg", - "EnteredHangar2A", - "Hangar2ADecompMsg", - "Hangar2ADecompCancelMsg", - "Hangar2AFlamePurge", - "Hangar2AFlamePurgeStop", - "Hangar3ADecompMsg", - "Hangar3ADecompMsgCancel", - "EnteredHangar1A", - "HenchmanSays", - "HenchmanHint", - "ForcefieldDown", - "Bomb", - "Bomb2", - "BombAlreadyPlanted", - "BombPlanted", - "BombDontPlantHere", - "MaintenanceWarningLong", - "MaintenanceWarning", - "MBotSwitch", - "DoorUnlockedMaint", - "MBotDied", - "MBotSpottedUs", - "MBotSummon", - "BallMade", - "IncomingTransmit", - "HazardGadget1Line", - "HazardGadget2Line", - "HazardGadget1Line2", - "HazardousStorageHint", - "BallFanPuzzleHint", - "IntruderAlertR0", - "SecurityR0", - "IntruderAlertR1", - "SecurityR1", - "IntruderAlertR2", - "SecurityR2", - "IntruderAlertR3", - "SecuirtyR3", - "WindFanPuzzleHint", - "FanDisabled", - "DataKeyCaptain", - "GotDatalinkKey", - "CaptainText", - "EnteredBunker", - "DataKeyFirstMate", - "GotDatalinkKey2", - "FirstMateText", - "PoleDatalinkWarning", - "DataKeysVerified", - "DataKeyWrong2", - "DataKeyNoUse1", - "DataKeyWrong1", - "DataKeyNoUse2", - "PoleDatalinkLock", - "DataArmUsed", - "DataArmOff", - "GetOut", - "ExitLevelLong", - "ExitTheLevel", - "CaptainAndTrooper", - "CaptainAndTrooper2", - "EscapeDoorLocked"}; -const char *Message_strings[NUM_MESSAGE_NAMES]; - // =============== // InitializeDLL() // =============== @@ -2982,37 +2743,19 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - char english_filename[(_MAX_PATH + 32) * 2]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - snprintf(english_filename, sizeof(english_filename), "%s.msg", filename); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); - else if (lang_type == LANGUAGE_POLISH) - strcat(filename, "_POL"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "Merc3.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { - if (lang_type == LANGUAGE_ENGLISH) { - mprintf(0, "ERROR: Could not load message file - %s\n", filename); - } else if (!ReadMessageFile(english_filename)) { - mprintf(0, "ERROR: Could not load message file - %s\n", english_filename); - } + mprintf(0, "ERROR: Could not load message file - %s\n", filename); } int j; @@ -3056,10 +2799,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } @@ -4167,7 +3906,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 013: Level INIT (Inventory) if ((ScriptActionCtr_013 < 1) && (1)) { - aAddObjectToInventoryNamed(Object_handles[23], qPlayerClosest(Object_handles[23], -1), Message_strings[0], 0); + aAddObjectToInventoryNamed(Object_handles[23], qPlayerClosest(Object_handles[23], -1), TXT("Bomb3"), 0); // Increment the script action counter if (ScriptActionCtr_013 < MAX_ACTION_CTR_VALUE) @@ -4428,7 +4167,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aComplexCinematicCameraOnPath(Path_indexes[2]); aComplexCinematicTrack(Object_handles[24], 0.000000f, 1.000000f); aComplexCinematicEndTrans(3); - aComplexCinematicEnd(Message_strings[1], 10.000000f); + aComplexCinematicEnd(TXT("IntroCinematicMsg"), 10.000000f); // Increment the script action counter if (ScriptActionCtr_132 < MAX_ACTION_CTR_VALUE) @@ -4652,7 +4391,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aSetLevelTimer(2.000000f, 48); } if (ScriptActionCtr_208 == 3) { - aShowHUDMessage(Message_strings[15]); + aShowHUDMessage(TXT("HenchmanHint")); } // Increment the script action counter @@ -4667,7 +4406,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aSetLevelTimer(3.000000f, 45); } if (ScriptActionCtr_175 == 1) { - aAddGameMessage(Message_strings[22], Message_strings[23]); + aAddGameMessage(TXT("MaintenanceWarningLong"), TXT("MaintenanceWarning")); } // Increment the script action counter @@ -4767,7 +4506,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { if (event_data->id == 37) { if (qObjExists(qObjSavedHandle(0)) == false) { if (qDoorLocked(Door_handles[3]) == true) { - aShowHUDMessage(Message_strings[26]); + aShowHUDMessage(TXT("MBotDied")); aObjPlayAnim(Object_handles[76], 1, 2, 2.000000f, 0); aSoundPlayObject(Sound_indexes[0], Object_handles[76], 1.000000f); aUserFlagSet(28, 0); @@ -4778,7 +4517,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aAIGoalGotoObject(qObjSavedHandle(0), Object_handles[77], 3, 4352, 5); aAIGoalSetCircleDistance(qObjSavedHandle(0), 3, 30.000000f); aSoundPlayObject(Sound_indexes[4], qObjSavedHandle(0), 1.000000f); - aShowHUDMessage(Message_strings[27]); + aShowHUDMessage(TXT("MBotSpottedUs")); } aSetLevelTimer(0.500000f, 37); } @@ -4792,7 +4531,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { if (event_data->id == 38) { if (qObjExists(qObjSavedHandle(1)) == false) { if (qDoorLocked(Door_handles[4]) == true) { - aShowHUDMessage(Message_strings[26]); + aShowHUDMessage(TXT("MBotDied")); aObjPlayAnim(Object_handles[78], 1, 2, 2.000000f, 0); aSoundPlayObject(Sound_indexes[0], Object_handles[78], 1.000000f); aUserFlagSet(29, 0); @@ -4803,7 +4542,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aAIGoalGotoObject(qObjSavedHandle(1), Object_handles[79], 3, 4352, 4); aAIGoalSetCircleDistance(qObjSavedHandle(1), 3, 30.000000f); aSoundPlayObject(Sound_indexes[4], qObjSavedHandle(1), 1.000000f); - aShowHUDMessage(Message_strings[27]); + aShowHUDMessage(TXT("MBotSpottedUs")); } aSetLevelTimer(0.500000f, 38); } @@ -4826,7 +4565,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { if (event_data->id == 33) { if (qObjExists(qObjSavedHandle(2)) == false) { if (qDoorLocked(Door_handles[5]) == true) { - aShowHUDMessage(Message_strings[26]); + aShowHUDMessage(TXT("MBotDied")); aObjPlayAnim(Object_handles[81], 1, 2, 2.000000f, 0); aSoundPlayObject(Sound_indexes[0], Object_handles[81], 1.000000f); aUserFlagSet(30, 0); @@ -4837,7 +4576,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aAIGoalGotoObject(qObjSavedHandle(2), Object_handles[82], 3, 4352, 12); aAIGoalSetCircleDistance(qObjSavedHandle(2), 3, 30.000000f); aSoundPlayObject(Sound_indexes[4], qObjSavedHandle(2), 1.000000f); - aShowHUDMessage(Message_strings[27]); + aShowHUDMessage(TXT("MBotSpottedUs")); } aSetLevelTimer(0.500000f, 33); } @@ -4849,7 +4588,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 203: Hazardous Waste: Guidebot Hint if (event_data->id == 47) { - aShowHUDMessage(Message_strings[34]); + aShowHUDMessage(TXT("HazardousStorageHint")); // Increment the script action counter if (ScriptActionCtr_203 < MAX_ACTION_CTR_VALUE) @@ -4876,7 +4615,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 069: Shark Security 0: Sharks if (event_data->id == 10) { - aShowHUDMessage(Message_strings[37]); + aShowHUDMessage(TXT("SecurityR0")); aSoundPlay2D(Sound_indexes[5], 1.000000f); cOffAIForSharksInRoom(1, 0); if (qRoomHasPlayer(Room_indexes[33]) == false) { @@ -4890,7 +4629,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 065: Shark Security 1: Sharks if (event_data->id == 9) { - aShowHUDMessage(Message_strings[39]); + aShowHUDMessage(TXT("SecurityR1")); aSoundPlay2D(Sound_indexes[5], 1.000000f); cOffAIForSharksInRoom(1, 1); if (qRoomHasPlayer(Room_indexes[34]) == false) { @@ -4904,7 +4643,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 064: Shark Security 2: Sharks if (event_data->id == 8) { - aShowHUDMessage(Message_strings[41]); + aShowHUDMessage(TXT("SecurityR2")); aSoundPlay2D(Sound_indexes[5], 1.000000f); cOffAIForSharksInRoom(1, 2); if (qRoomHasPlayer(Room_indexes[35]) == false) { @@ -4918,7 +4657,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 054: Shark Security 3: Sharks if (event_data->id == 7) { - aShowHUDMessage(Message_strings[43]); + aShowHUDMessage(TXT("SecuirtyR3")); aSoundPlay2D(Sound_indexes[5], 1.000000f); cOffAIForSharksInRoom(1, 3); if (qRoomHasPlayer(Room_indexes[36]) == false) { @@ -5494,7 +5233,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aUserFlagSet(15, 0); } aUserFlagSet(11, 0); - aShowColoredHUDMessage(255, 0, 0, Message_strings[59]); + aShowColoredHUDMessage(255, 0, 0, TXT("PoleDatalinkLock")); aSoundPlay2D(Sound_indexes[13], 1.000000f); aRoomSetFaceTexture(Room_indexes[51], 297, Texture_indexes[9]); aRoomSetFaceTexture(Room_indexes[52], 323, Texture_indexes[9]); @@ -5510,10 +5249,10 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 176: Main Objectives Done if ((ScriptActionCtr_176 < 1) && (event_data->id == 46)) { - aShowHUDMessage(Message_strings[62]); + aShowHUDMessage(TXT("GetOut")); aGoalEnableDisable(1, Goal_indexes[25]); aDoorLockUnlock(0, Door_handles[0]); - aAddGameMessage(Message_strings[63], Message_strings[64]); + aAddGameMessage(TXT("ExitLevelLong"), TXT("ExitTheLevel")); // Increment the script action counter if (ScriptActionCtr_176 < MAX_ACTION_CTR_VALUE) @@ -5601,7 +5340,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { if (event_data->goal_uid == 2) { if (qDoorLocked(Door_handles[3]) == true) { aDoorLockUnlock(0, Door_handles[3]); - aShowHUDMessage(Message_strings[25]); + aShowHUDMessage(TXT("DoorUnlockedMaint")); aGoalCompleted(Goal_indexes[8], 1); } aAIGoalFollowPath(event_data->it_handle, Path_indexes[8], 6, 11, 5, 3, 10490112, -1); @@ -5615,7 +5354,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { if (event_data->goal_uid == 5) { aMatcenSetState(1, Matcen_indexes[5]); aAIGoalFollowPath(event_data->it_handle, Path_indexes[8], 1, 5, 1, 3, 2101504, 2); - aShowHUDMessage(Message_strings[28]); + aShowHUDMessage(TXT("MBotSummon")); // Increment the script action counter if (ScriptActionCtr_027 < MAX_ACTION_CTR_VALUE) @@ -5626,7 +5365,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { if (event_data->goal_uid == 0) { if (qDoorLocked(Door_handles[4]) == true) { aDoorLockUnlock(0, Door_handles[4]); - aShowHUDMessage(Message_strings[25]); + aShowHUDMessage(TXT("DoorUnlockedMaint")); aGoalCompleted(Goal_indexes[10], 1); } aAIGoalFollowPath(event_data->it_handle, Path_indexes[9], 7, 12, 6, 3, 10490112, -1); @@ -5640,7 +5379,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { if (event_data->goal_uid == 4) { aMatcenSetState(1, Matcen_indexes[7]); aAIGoalFollowPath(event_data->it_handle, Path_indexes[9], 1, 6, 1, 3, 2101504, 0); - aShowHUDMessage(Message_strings[28]); + aShowHUDMessage(TXT("MBotSummon")); // Increment the script action counter if (ScriptActionCtr_021 < MAX_ACTION_CTR_VALUE) @@ -5651,7 +5390,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { if (event_data->goal_uid == 11) { if (qDoorLocked(Door_handles[5]) == true) { aDoorLockUnlock(0, Door_handles[5]); - aShowHUDMessage(Message_strings[25]); + aShowHUDMessage(TXT("DoorUnlockedMaint")); aGoalCompleted(Goal_indexes[12], 1); } aAIGoalFollowPath(event_data->it_handle, Path_indexes[10], 6, 11, 5, 3, 10489856, -1); @@ -5665,7 +5404,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { if (event_data->goal_uid == 12) { aMatcenSetState(1, Matcen_indexes[11]); aAIGoalFollowPath(event_data->it_handle, Path_indexes[10], 1, 5, 1, 3, 2101504, 11); - aShowHUDMessage(Message_strings[28]); + aShowHUDMessage(TXT("MBotSummon")); // Increment the script action counter if (ScriptActionCtr_123 < MAX_ACTION_CTR_VALUE) @@ -5874,7 +5613,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 115: Junction 3: Ball Matcen Generated if (event_data->id == Matcen_indexes[8]) { aMatcenSetState(0, event_data->id); - aShowHUDMessage(Message_strings[29]); + aShowHUDMessage(TXT("BallMade")); aObjSaveHandle(event_data->it_handle, 7); aSetLevelTimer(300.000000f, 36); @@ -5958,7 +5697,7 @@ int16_t CustomObjectScript_0B83::CallEvent(int event, tOSIRISEventInfo *data) { aComplexCinematicCameraAtStoredPt(Room_indexes[21]); aComplexCinematicTrack(Object_handles[27], 0.000000f, 1.000000f); aComplexCinematicEndTrans(0); - aComplexCinematicEnd(Message_strings[2], 7.000000f); + aComplexCinematicEnd(TXT("EmptyMessage"), 7.000000f); aMusicSetRegionAll(1); // Increment the script action counter @@ -5983,7 +5722,7 @@ int16_t CustomObjectScript_0B85::CallEvent(int event, tOSIRISEventInfo *data) { aComplexCinematicCameraAtStoredPt(Room_indexes[22]); aComplexCinematicTrack(Object_handles[29], 0.000000f, 1.000000f); aComplexCinematicEndTrans(3); - aComplexCinematicEnd(Message_strings[2], 17.000000f); + aComplexCinematicEnd(TXT("EmptyMessage"), 17.000000f); // Increment the script action counter if (ScriptActionCtr_134 < MAX_ACTION_CTR_VALUE) @@ -6003,7 +5742,7 @@ int16_t CustomObjectScript_1140::CallEvent(int event, tOSIRISEventInfo *data) { if (qObjIsPlayerWeapon(event_data->it_handle) == true) { aUserFlagSet(3, 1); aRoomSetFaceTexture(Room_indexes[23], 481, Texture_indexes[0]); - aShowColoredHUDMessageObj(255, 0, 0, Message_strings[3], qObjParent(event_data->it_handle)); + aShowColoredHUDMessageObj(255, 0, 0, TXT("HangarPrimaryLocked"), qObjParent(event_data->it_handle)); // Increment the script action counter if (ScriptActionCtr_001 < MAX_ACTION_CTR_VALUE) @@ -6033,7 +5772,7 @@ int16_t CustomObjectScript_1941::CallEvent(int event, tOSIRISEventInfo *data) { aSetObjectTimer(Object_handles[32], 15.000000f, 0); aDoorLockUnlock(0, Door_handles[1]); aTimerShow(0); - aShowColoredHUDMessage(255, 0, 0, Message_strings[4]); + aShowColoredHUDMessage(255, 0, 0, TXT("Hangar1ADecompMsg")); aUserFlagSet(0, 1); aSoundPlaySteaming("VoxMerc3RPA1.osf", 1.000000f); aGoalCompleted(Goal_indexes[0], 1); @@ -6041,7 +5780,7 @@ int16_t CustomObjectScript_1941::CallEvent(int event, tOSIRISEventInfo *data) { aDoorLockUnlock(1, Door_handles[1]); aCancelTimer(0); aAISetState(0, Object_handles[5]); - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("Hangar1ADecompCancelMsg")); aUserFlagSet(0, 0); aGoalCompleted(Goal_indexes[0], 0); } @@ -6073,7 +5812,7 @@ int16_t CustomObjectScript_0943::CallEvent(int event, tOSIRISEventInfo *data) { aSetObjectTimer(Object_handles[32], 15.000000f, 0); aDoorLockUnlock(0, Door_handles[1]); aTimerShow(0); - aShowColoredHUDMessage(255, 0, 0, Message_strings[4]); + aShowColoredHUDMessage(255, 0, 0, TXT("Hangar1ADecompMsg")); aUserFlagSet(0, 1); aSoundPlaySteaming("VoxMerc3RPA1.osf", 1.000000f); aGoalCompleted(Goal_indexes[0], 1); @@ -6081,7 +5820,7 @@ int16_t CustomObjectScript_0943::CallEvent(int event, tOSIRISEventInfo *data) { aDoorLockUnlock(1, Door_handles[1]); aCancelTimer(0); aAISetState(0, Object_handles[5]); - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("Hangar1ADecompCancelMsg")); aUserFlagSet(0, 0); aGoalCompleted(Goal_indexes[0], 0); } @@ -6134,7 +5873,7 @@ int16_t CustomObjectScript_0950::CallEvent(int event, tOSIRISEventInfo *data) { // Script 004: Hangar 2A: Primary Door Switch if (qObjIsPlayerWeapon(event_data->it_handle) == true) { aRoomSetFaceTexture(Room_indexes[24], 300, Texture_indexes[0]); - aShowColoredHUDMessageObj(255, 0, 0, Message_strings[3], qObjParent(event_data->it_handle)); + aShowColoredHUDMessageObj(255, 0, 0, TXT("HangarPrimaryLocked"), qObjParent(event_data->it_handle)); // Increment the script action counter if (ScriptActionCtr_004 < MAX_ACTION_CTR_VALUE) @@ -6164,7 +5903,7 @@ int16_t CustomObjectScript_0951::CallEvent(int event, tOSIRISEventInfo *data) { aSetObjectTimer(Object_handles[36], 25.000000f, 1); aDoorLockUnlock(0, Door_handles[2]); aTimerShow(1); - aShowColoredHUDMessage(255, 0, 0, Message_strings[7]); + aShowColoredHUDMessage(255, 0, 0, TXT("Hangar2ADecompMsg")); aUserFlagSet(1, 1); aSoundPlaySteaming("VoxMerc3RPA1.osf", 1.000000f); aGoalCompleted(Goal_indexes[2], 1); @@ -6172,7 +5911,7 @@ int16_t CustomObjectScript_0951::CallEvent(int event, tOSIRISEventInfo *data) { aDoorLockUnlock(1, Door_handles[2]); aCancelTimer(1); aAISetState(0, Object_handles[6]); - aShowHUDMessage(Message_strings[8]); + aShowHUDMessage(TXT("Hangar2ADecompCancelMsg")); aUserFlagSet(1, 0); aGoalCompleted(Goal_indexes[2], 0); } @@ -6204,7 +5943,7 @@ int16_t CustomObjectScript_093A::CallEvent(int event, tOSIRISEventInfo *data) { aSetObjectTimer(Object_handles[36], 15.000000f, 1); aDoorLockUnlock(0, Door_handles[2]); aTimerShow(1); - aShowColoredHUDMessage(255, 0, 0, Message_strings[7]); + aShowColoredHUDMessage(255, 0, 0, TXT("Hangar2ADecompMsg")); aUserFlagSet(1, 1); aSoundPlaySteaming("VoxMerc3RPA1.osf", 1.000000f); aGoalCompleted(Goal_indexes[2], 1); @@ -6212,7 +5951,7 @@ int16_t CustomObjectScript_093A::CallEvent(int event, tOSIRISEventInfo *data) { aDoorLockUnlock(1, Door_handles[2]); aCancelTimer(1); aAISetState(0, Object_handles[6]); - aShowHUDMessage(Message_strings[8]); + aShowHUDMessage(TXT("Hangar2ADecompCancelMsg")); aUserFlagSet(1, 0); aGoalCompleted(Goal_indexes[2], 0); } @@ -6312,7 +6051,7 @@ int16_t CustomObjectScript_093C::CallEvent(int event, tOSIRISEventInfo *data) { ((qObjAnimFrame(data->me_handle) == 0.000000f) || (qObjAnimFrame(data->me_handle) == 2.000000f))) && (qUserFlag(3) == false)) { if (qUserFlag(2) == false) { - aShowColoredHUDMessage(255, 0, 0, Message_strings[9]); + aShowColoredHUDMessage(255, 0, 0, TXT("Hangar2AFlamePurge")); aUserVarSet(0, 0.000000f); aSetLevelTimer(0.500000f, 4); aUserFlagSet(2, 1); @@ -6320,7 +6059,7 @@ int16_t CustomObjectScript_093C::CallEvent(int event, tOSIRISEventInfo *data) { } else { if (1) { aCancelTimer(4); - aShowHUDMessage(Message_strings[10]); + aShowHUDMessage(TXT("Hangar2AFlamePurgeStop")); aTurnOffSpew(0); aTurnOffSpew(1); aTurnOffSpew(2); @@ -6358,7 +6097,7 @@ int16_t CustomObjectScript_1318::CallEvent(int event, tOSIRISEventInfo *data) { (qUserFlag(3) == false)) { aUserFlagSet(3, 1); aRoomSetFaceTexture(Room_indexes[25], 501, Texture_indexes[0]); - aShowColoredHUDMessageObj(255, 0, 0, Message_strings[3], qObjParent(event_data->it_handle)); + aShowColoredHUDMessageObj(255, 0, 0, TXT("HangarPrimaryLocked"), qObjParent(event_data->it_handle)); // Increment the script action counter if (ScriptActionCtr_143 < MAX_ACTION_CTR_VALUE) @@ -6385,12 +6124,12 @@ int16_t CustomObjectScript_1317::CallEvent(int event, tOSIRISEventInfo *data) { if (qUserFlag(19) == false) { aSetObjectTimer(Object_handles[49], 15.000000f, 39); aTimerShow(39); - aShowColoredHUDMessage(255, 0, 0, Message_strings[11]); + aShowColoredHUDMessage(255, 0, 0, TXT("Hangar3ADecompMsg")); aUserFlagSet(19, 1); aSoundPlaySteaming("VoxMerc3RPA1.osf", 1.000000f); } else { aCancelTimer(34); - aShowHUDMessage(Message_strings[12]); + aShowHUDMessage(TXT("Hangar3ADecompMsgCancel")); aUserFlagSet(19, 0); } @@ -6419,12 +6158,12 @@ int16_t CustomObjectScript_190B::CallEvent(int event, tOSIRISEventInfo *data) { if (qUserFlag(19) == false) { aSetObjectTimer(Object_handles[49], 15.000000f, 39); aTimerShow(39); - aShowColoredHUDMessage(255, 0, 0, Message_strings[11]); + aShowColoredHUDMessage(255, 0, 0, TXT("Hangar3ADecompMsg")); aUserFlagSet(19, 1); aSoundPlaySteaming("VoxMerc3RPA1.osf", 1.000000f); } else { aCancelTimer(34); - aShowHUDMessage(Message_strings[12]); + aShowHUDMessage(TXT("Hangar3ADecompMsgCancel")); aUserFlagSet(19, 0); } @@ -6552,7 +6291,7 @@ int16_t CustomObjectScript_1194::CallEvent(int event, tOSIRISEventInfo *data) { aGoalCompleted(Goal_indexes[4], 1); aGoalEnableDisable(1, Goal_indexes[0]); aGoalEnableDisable(1, Goal_indexes[1]); - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("EnteredHangar1A")); // Increment the script action counter if (ScriptActionCtr_210 < MAX_ACTION_CTR_VALUE) @@ -6576,7 +6315,7 @@ int16_t CustomObjectScript_11FA::CallEvent(int event, tOSIRISEventInfo *data) { if (1) { aPortalRenderSet(0, 11, Room_indexes[26], 0); aPortalRenderSet(0, 0, Room_indexes[26], 1); - aShowHUDMessage(Message_strings[16]); + aShowHUDMessage(TXT("ForcefieldDown")); aGoalCompleted(Goal_indexes[6], 1); // Increment the script action counter @@ -6598,15 +6337,15 @@ int16_t CustomObjectScript_0CB4::CallEvent(int event, tOSIRISEventInfo *data) { if (qUserVarValue(23) > 0.000000f) { aSoundPlayObject(Sound_indexes[1], event_data->it_handle, 1.000000f); if (qUserVarValue(23) == 1.000000f) { - aShowHUDMessageObj(Message_strings[17], event_data->it_handle); - aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, Message_strings[17], 0); + aShowHUDMessageObj(TXT("Bomb"), event_data->it_handle); + aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, TXT("Bomb"), 0); } else { if (qUserVarValue(23) == 2.000000f) { - aShowHUDMessageObj(Message_strings[18], event_data->it_handle); - aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, Message_strings[18], 0); + aShowHUDMessageObj(TXT("Bomb2"), event_data->it_handle); + aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, TXT("Bomb2"), 0); } else { - aShowHUDMessageObj(Message_strings[0], event_data->it_handle); - aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, Message_strings[0], 0); + aShowHUDMessageObj(TXT("Bomb3"), event_data->it_handle); + aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, TXT("Bomb3"), 0); } } } @@ -6623,9 +6362,9 @@ int16_t CustomObjectScript_0CB4::CallEvent(int event, tOSIRISEventInfo *data) { if (1) { if (qObjRoom(event_data->it_handle) == Room_indexes[27]) { if (qGoalCompleted(Goal_indexes[7]) == true) { - aShowHUDMessageObj(Message_strings[19], event_data->it_handle); + aShowHUDMessageObj(TXT("BombAlreadyPlanted"), event_data->it_handle); } else { - aShowHUDMessageObj(Message_strings[20], event_data->it_handle); + aShowHUDMessageObj(TXT("BombPlanted"), event_data->it_handle); aStoreObjectInPositionClipboard(Object_handles[55]); aMoveObjectToPositionClipboard(Object_handles[2]); aObjGhostSet(0, Object_handles[2]); @@ -6640,9 +6379,9 @@ int16_t CustomObjectScript_0CB4::CallEvent(int event, tOSIRISEventInfo *data) { } else { if (qObjRoom(event_data->it_handle) == Room_indexes[28]) { if (qGoalCompleted(Goal_indexes[9]) == true) { - aShowHUDMessageObj(Message_strings[19], event_data->it_handle); + aShowHUDMessageObj(TXT("BombAlreadyPlanted"), event_data->it_handle); } else { - aShowHUDMessageObj(Message_strings[20], event_data->it_handle); + aShowHUDMessageObj(TXT("BombPlanted"), event_data->it_handle); aStoreObjectInPositionClipboard(Object_handles[56]); aMoveObjectToPositionClipboard(Object_handles[3]); aObjGhostSet(0, Object_handles[3]); @@ -6657,9 +6396,9 @@ int16_t CustomObjectScript_0CB4::CallEvent(int event, tOSIRISEventInfo *data) { } else { if (qObjRoom(event_data->it_handle) == Room_indexes[29]) { if (qGoalCompleted(Goal_indexes[11]) == true) { - aShowHUDMessageObj(Message_strings[19], event_data->it_handle); + aShowHUDMessageObj(TXT("BombAlreadyPlanted"), event_data->it_handle); } else { - aShowHUDMessageObj(Message_strings[20], event_data->it_handle); + aShowHUDMessageObj(TXT("BombPlanted"), event_data->it_handle); aStoreObjectInPositionClipboard(Object_handles[57]); aMoveObjectToPositionClipboard(Object_handles[4]); aObjGhostSet(0, Object_handles[4]); @@ -6672,19 +6411,19 @@ int16_t CustomObjectScript_0CB4::CallEvent(int event, tOSIRISEventInfo *data) { aUserVarDec(23); } } else { - aShowHUDMessage(Message_strings[21]); + aShowHUDMessage(TXT("BombDontPlantHere")); } } } if (qUserVarValue(23) > 0.000000f) { aObjGhostSet(0, Object_handles[23]); if (qUserVarValue(23) == 1.000000f) { - aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, Message_strings[17], 0); + aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, TXT("Bomb"), 0); } else { if (qUserVarValue(23) == 2.000000f) { - aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, Message_strings[18], 0); + aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, TXT("Bomb2"), 0); } else { - aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, Message_strings[0], 0); + aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, TXT("Bomb3"), 0); } } } @@ -6710,7 +6449,7 @@ int16_t CustomObjectScript_20B0::CallEvent(int event, tOSIRISEventInfo *data) { aObjPlayAnim(data->me_handle, 0, 1, 2.000000f, 0); aSoundPlayObject(Sound_indexes[0], data->me_handle, 1.000000f); aMatcenSetState(1, Matcen_indexes[4]); - aShowHUDMessage(Message_strings[24]); + aShowHUDMessage(TXT("MBotSwitch")); // Increment the script action counter if (ScriptActionCtr_022 < MAX_ACTION_CTR_VALUE) @@ -6733,7 +6472,7 @@ int16_t CustomObjectScript_136F::CallEvent(int event, tOSIRISEventInfo *data) { aObjPlayAnim(data->me_handle, 0, 1, 2.000000f, 0); aSoundPlayObject(Sound_indexes[0], data->me_handle, 1.000000f); aMatcenSetState(1, Matcen_indexes[6]); - aShowHUDMessage(Message_strings[24]); + aShowHUDMessage(TXT("MBotSwitch")); // Increment the script action counter if (ScriptActionCtr_018 < MAX_ACTION_CTR_VALUE) @@ -6779,7 +6518,7 @@ int16_t CustomObjectScript_30AE::CallEvent(int event, tOSIRISEventInfo *data) { aObjPlayAnim(data->me_handle, 0, 1, 2.000000f, 0); aSoundPlayObject(Sound_indexes[0], data->me_handle, 1.000000f); aMatcenSetState(1, Matcen_indexes[10]); - aShowHUDMessage(Message_strings[24]); + aShowHUDMessage(TXT("MBotSwitch")); // Increment the script action counter if (ScriptActionCtr_119 < MAX_ACTION_CTR_VALUE) @@ -6829,7 +6568,7 @@ int16_t CustomObjectScript_50FF::CallEvent(int event, tOSIRISEventInfo *data) { aComplexCinematicTextMode(4); aComplexCinematicText(0.200000f, 0.900000f); aComplexCinematicEndTrans(0); - aComplexCinematicEnd(Message_strings[31], 6.000000f); + aComplexCinematicEnd(TXT("HazardGadget1Line"), 6.000000f); // Increment the script action counter if (ScriptActionCtr_032 < MAX_ACTION_CTR_VALUE) @@ -6858,7 +6597,7 @@ int16_t CustomObjectScript_0987::CallEvent(int event, tOSIRISEventInfo *data) { aComplexCinematicTextMode(4); if (qUserVarValueInt(1) == 3) { aComplexCinematicEndTrans(0); - aComplexCinematicEnd(Message_strings[32], 8.000000f); + aComplexCinematicEnd(TXT("HazardGadget2Line"), 8.000000f); } else { } @@ -6889,7 +6628,7 @@ int16_t CustomObjectScript_0989::CallEvent(int event, tOSIRISEventInfo *data) { aComplexCinematicTextMode(4); if (qUserVarValueInt(1) == 4) { aComplexCinematicEndTrans(0); - aComplexCinematicEnd(Message_strings[33], 9.000000f); + aComplexCinematicEnd(TXT("HazardGadget1Line2"), 9.000000f); aSetLevelTimer(11.000000f, 47); } else { } @@ -7101,7 +6840,7 @@ int16_t CustomObjectScript_09FD::CallEvent(int event, tOSIRISEventInfo *data) { if ((qUserFlag(7) == false) && (qObjIsPlayer(event_data->it_handle) == true) && (qUserFlag(24) == false)) { aUserFlagSet(7, 1); aAIGoalFollowPath(data->me_handle, Path_indexes[15], 11, 13, 11, 3, 4480, 9); - aShowHUDMessage(Message_strings[36]); + aShowHUDMessage(TXT("IntruderAlertR0")); aSoundPlayObject(Sound_indexes[4], data->me_handle, 1.000000f); // Increment the script action counter @@ -7146,7 +6885,7 @@ int16_t CustomObjectScript_09FC::CallEvent(int event, tOSIRISEventInfo *data) { if ((qUserFlag(6) == false) && (qObjIsPlayer(event_data->it_handle) == true) && (qUserFlag(25) == false)) { aUserFlagSet(6, 1); aAIGoalFollowPath(data->me_handle, Path_indexes[14], 11, 13, 11, 3, 4480, 8); - aShowHUDMessage(Message_strings[38]); + aShowHUDMessage(TXT("IntruderAlertR1")); aSoundPlayObject(Sound_indexes[4], data->me_handle, 1.000000f); // Increment the script action counter @@ -7191,7 +6930,7 @@ int16_t CustomObjectScript_09FB::CallEvent(int event, tOSIRISEventInfo *data) { if ((qUserFlag(5) == false) && (qObjIsPlayer(event_data->it_handle) == true) && (qUserFlag(26) == false)) { aUserFlagSet(5, 1); aAIGoalFollowPath(data->me_handle, Path_indexes[13], 11, 13, 11, 3, 4480, 7); - aShowHUDMessage(Message_strings[40]); + aShowHUDMessage(TXT("IntruderAlertR2")); aSoundPlayObject(Sound_indexes[4], data->me_handle, 1.000000f); // Increment the script action counter @@ -7236,7 +6975,7 @@ int16_t CustomObjectScript_105C::CallEvent(int event, tOSIRISEventInfo *data) { if ((qUserFlag(4) == false) && (qObjIsPlayer(event_data->it_handle) == true) && (qUserFlag(27) == false)) { aUserFlagSet(4, 1); aAIGoalFollowPath(data->me_handle, Path_indexes[12], 11, 13, 11, 3, 4480, 6); - aShowHUDMessage(Message_strings[42]); + aShowHUDMessage(TXT("IntruderAlertR3")); aSoundPlayObject(Sound_indexes[4], data->me_handle, 1.000000f); // Increment the script action counter @@ -7283,7 +7022,7 @@ int16_t CustomObjectScript_60EB::CallEvent(int event, tOSIRISEventInfo *data) { // Script 061: Big Fan 0: Deactivation if (1) { - aShowHUDMessage(Message_strings[45]); + aShowHUDMessage(TXT("FanDisabled")); aRoomChangeWind(Room_indexes[7], 0.000000f, 0.000000f, 0.000000f, 0.000000f, 2.000000f); aRoomChangeWind(Room_indexes[8], 0.000000f, 0.000000f, 0.000000f, 0.000000f, 2.000000f); aRoomChangeWind(Room_indexes[9], 0.000000f, 0.000000f, 0.000000f, 0.000000f, 2.000000f); @@ -7311,7 +7050,7 @@ int16_t CustomObjectScript_28EC::CallEvent(int event, tOSIRISEventInfo *data) { // Script 076: Big Fan 1: Deactivation if (1) { - aShowHUDMessage(Message_strings[45]); + aShowHUDMessage(TXT("FanDisabled")); aRoomChangeWind(Room_indexes[10], 0.000000f, 0.000000f, 0.000000f, 0.000000f, 2.000000f); aRoomChangeWind(Room_indexes[11], 0.000000f, 0.000000f, 0.000000f, 0.000000f, 2.000000f); aRoomChangeWind(Room_indexes[12], 0.000000f, 0.000000f, 0.000000f, 0.000000f, 2.000000f); @@ -7409,8 +7148,8 @@ int16_t CustomObjectScript_11F7::CallEvent(int event, tOSIRISEventInfo *data) { // Script 057: Captain Gadget: Datalink Key if ((qObjIsPlayer(event_data->it_handle) == true) && (qUserFlag(14) == false)) { - aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, Message_strings[46], 0); - aShowHUDMessageObj(Message_strings[47], event_data->it_handle); + aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, TXT("DataKeyCaptain"), 0); + aShowHUDMessageObj(TXT("GotDatalinkKey"), event_data->it_handle); aSoundPlayObject(Sound_indexes[1], event_data->it_handle, 1.000000f); aGoalCompleted(Goal_indexes[18], 1); @@ -7433,12 +7172,12 @@ int16_t CustomObjectScript_11F7::CallEvent(int event, tOSIRISEventInfo *data) { aGoalCompleted(Goal_indexes[22], 1); if (qUserFlag(11) == false) { aUserFlagSet(11, 1); - aShowHUDMessageI(Message_strings[53], qUserVarValueInt(15)); + aShowHUDMessageI(TXT("PoleDatalinkWarning"), qUserVarValueInt(15)); aRoomSetFaceTexture(Room_indexes[51], 297, Texture_indexes[5]); aSetLevelTimer(qUserVarValue(15), 30); aTimerShow(30); } else { - aShowHUDMessage(Message_strings[54]); + aShowHUDMessage(TXT("DataKeysVerified")); aUserFlagSet(23, 1); aObjSpark(Object_handles[178], 10.000000f, 5.000000f); aCancelTimer(30); @@ -7447,12 +7186,12 @@ int16_t CustomObjectScript_11F7::CallEvent(int event, tOSIRISEventInfo *data) { } } else { if (qObjGetDistance(event_data->it_handle, Object_handles[179]) <= 100.000000f) { - aShowHUDMessage(Message_strings[55]); + aShowHUDMessage(TXT("DataKeyWrong2")); } else { - aShowHUDMessage(Message_strings[56]); + aShowHUDMessage(TXT("DataKeyNoUse1")); } aObjGhostSet(0, data->me_handle); - aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, Message_strings[46], 0); + aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, TXT("DataKeyCaptain"), 0); } // Increment the script action counter @@ -7694,7 +7433,7 @@ int16_t CustomObjectScript_0A2E::CallEvent(int event, tOSIRISEventInfo *data) { aComplexCinematicTrack(Object_handles[166], 0.000000f, 1.000000f); aComplexCinematicCameraAtStoredPt(Room_indexes[49]); aComplexCinematicEndTrans(3); - aComplexCinematicEnd(Message_strings[2], 6.000000f); + aComplexCinematicEnd(TXT("EmptyMessage"), 6.000000f); aAISetMaxSpeed(Object_handles[19], 20.000000f); aAIGoalFollowPath(Object_handles[19], Path_indexes[18], 3, 7, 3, 3, 2101508, -1); aAIGoalSetCircleDistance(Object_handles[19], 3, 0.000000f); @@ -7722,7 +7461,7 @@ int16_t CustomObjectScript_0A30::CallEvent(int event, tOSIRISEventInfo *data) { aComplexCinematicTrack(Object_handles[168], 0.000000f, 1.000000f); aComplexCinematicCameraAtStoredPt(Room_indexes[50]); aComplexCinematicEndTrans(3); - aComplexCinematicEnd(Message_strings[2], 8.000000f); + aComplexCinematicEnd(TXT("EmptyMessage"), 8.000000f); aAISetMaxSpeed(Object_handles[19], 10.000000f); aAIGoalFollowPathSimple(Object_handles[19], Path_indexes[19], 3145984, 10, 3); aAIGoalSetCircleDistance(Object_handles[19], 3, 0.000000f); @@ -7760,8 +7499,8 @@ int16_t CustomObjectScript_0A33::CallEvent(int event, tOSIRISEventInfo *data) { // Script 103: First Mate: Datalink Key if ((qObjIsPlayer(event_data->it_handle) == true) && (qUserFlag(15) == false)) { - aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, Message_strings[50], 0); - aShowHUDMessageObj(Message_strings[51], event_data->it_handle); + aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, TXT("DataKeyFirstMate"), 0); + aShowHUDMessageObj(TXT("GotDatalinkKey2"), event_data->it_handle); aSoundPlayObject(Sound_indexes[1], event_data->it_handle, 1.000000f); aGoalCompleted(Goal_indexes[20], 1); @@ -7784,12 +7523,12 @@ int16_t CustomObjectScript_0A33::CallEvent(int event, tOSIRISEventInfo *data) { aGoalCompleted(Goal_indexes[23], 1); if (qUserFlag(11) == false) { aUserFlagSet(11, 1); - aShowHUDMessageI(Message_strings[53], qUserVarValueInt(15)); + aShowHUDMessageI(TXT("PoleDatalinkWarning"), qUserVarValueInt(15)); aRoomSetFaceTexture(Room_indexes[52], 323, Texture_indexes[8]); aSetLevelTimer(qUserVarValue(15), 30); aTimerShow(30); } else { - aShowHUDMessage(Message_strings[54]); + aShowHUDMessage(TXT("DataKeysVerified")); aUserFlagSet(23, 1); aObjSpark(Object_handles[184], 10.000000f, 5.000000f); aCancelTimer(30); @@ -7799,12 +7538,12 @@ int16_t CustomObjectScript_0A33::CallEvent(int event, tOSIRISEventInfo *data) { } } else { if (qObjGetDistance(event_data->it_handle, Object_handles[177]) <= 100.000000f) { - aShowHUDMessage(Message_strings[57]); + aShowHUDMessage(TXT("DataKeyWrong1")); } else { - aShowHUDMessage(Message_strings[58]); + aShowHUDMessage(TXT("DataKeyNoUse2")); } aObjGhostSet(0, data->me_handle); - aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, Message_strings[50], 0); + aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, TXT("DataKeyFirstMate"), 0); } // Increment the script action counter @@ -8216,10 +7955,10 @@ int16_t CustomObjectScript_18A0::CallEvent(int event, tOSIRISEventInfo *data) { if (qUserFlag(23) == true) { aObjPlayAnim(data->me_handle, 1, 9, 3.000000f, 0); aSoundPlayObject(Sound_indexes[14], data->me_handle, 1.000000f); - aShowHUDMessage(Message_strings[60]); + aShowHUDMessage(TXT("DataArmUsed")); aGoalCompleted(Goal_indexes[24], 1); } else { - aShowHUDMessage(Message_strings[61]); + aShowHUDMessage(TXT("DataArmOff")); } // Increment the script action counter @@ -8241,10 +7980,10 @@ int16_t CustomObjectScript_083D::CallEvent(int event, tOSIRISEventInfo *data) { if (qUserFlag(23) == true) { aObjPlayAnim(data->me_handle, 1, 9, 3.000000f, 0); aSoundPlayObject(Sound_indexes[14], data->me_handle, 1.000000f); - aShowHUDMessage(Message_strings[60]); + aShowHUDMessage(TXT("DataArmUsed")); aGoalCompleted(Goal_indexes[24], 1); } else { - aShowHUDMessage(Message_strings[61]); + aShowHUDMessage(TXT("DataArmOff")); } // Increment the script action counter @@ -8271,7 +8010,7 @@ int16_t CustomObjectScript_0B86::CallEvent(int event, tOSIRISEventInfo *data) { aComplexCinematicText(0.200000f, 0.900000f); aComplexCinematicCameraAtStoredPt(Room_indexes[53]); aComplexCinematicEndTrans(0); - aComplexCinematicEnd(Message_strings[65], 8.000000f); + aComplexCinematicEnd(TXT("CaptainAndTrooper"), 8.000000f); // Increment the script action counter if (ScriptActionCtr_130 < MAX_ACTION_CTR_VALUE) @@ -8296,7 +8035,7 @@ int16_t CustomObjectScript_0B80::CallEvent(int event, tOSIRISEventInfo *data) { aComplexCinematicText(0.400000f, 0.900000f); aComplexCinematicCameraAtStoredPt(Room_indexes[53]); aComplexCinematicEndTrans(3); - aComplexCinematicEnd(Message_strings[66], 7.000000f); + aComplexCinematicEnd(TXT("CaptainAndTrooper2"), 7.000000f); // Increment the script action counter if (ScriptActionCtr_131 < MAX_ACTION_CTR_VALUE) @@ -8336,7 +8075,7 @@ int16_t CustomObjectScript_109F::CallEvent(int event, tOSIRISEventInfo *data) { if (qGoalEnabled(Goal_indexes[25]) == false) { if (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) { aSoundPlayObject(Sound_indexes[15], Object_handles[210], 1.000000f); - aShowHUDMessage(Message_strings[67]); + aShowHUDMessage(TXT("EscapeDoorLocked")); } // Increment the script action counter @@ -8469,7 +8208,7 @@ int16_t TriggerScript_0022::CallEvent(int event, tOSIRISEventInfo *data) { aGoalEnableDisable(0, Goal_indexes[0]); aGoalEnableDisable(1, Goal_indexes[2]); aGoalEnableDisable(1, Goal_indexes[3]); - aShowHUDMessage(Message_strings[6]); + aShowHUDMessage(TXT("EnteredHangar2A")); // Increment the script action counter if (ScriptActionCtr_211 < MAX_ACTION_CTR_VALUE) @@ -8542,7 +8281,7 @@ int16_t TriggerScript_0021::CallEvent(int event, tOSIRISEventInfo *data) { // Script 207: Warehouse: Player Entered if ((ScriptActionCtr_207 < 1) && (qObjIsPlayer(event_data->it_handle) == true)) { - aCinematicSimple(Path_indexes[6], Message_strings[14], Object_handles[12], 10.000000f, 1); + aCinematicSimple(Path_indexes[6], TXT("HenchmanSays"), Object_handles[12], 10.000000f, 1); aSetLevelTimer(3.000000f, 48); aGoalCompleted(Goal_indexes[5], 1); aGoalEnableDisable(1, Goal_indexes[6]); @@ -8592,7 +8331,7 @@ int16_t TriggerScript_0002::CallEvent(int event, tOSIRISEventInfo *data) { aComplexCinematicTextLayoutMode(32); aComplexCinematicEndTrans(0); aComplexCinematicCameraOnPath(Path_indexes[11]); - aComplexCinematicEnd(Message_strings[30], 5.000000f); + aComplexCinematicEnd(TXT("IncomingTransmit"), 5.000000f); aAISetState(1, Object_handles[13]); aAISetState(1, Object_handles[14]); aAIGoalFollowPathSimple(Object_handles[13], Path_indexes[0], 3149828, -1, 3); @@ -8616,7 +8355,7 @@ int16_t TriggerScript_001E::CallEvent(int event, tOSIRISEventInfo *data) { // Script 204: Gravity Room 2: Puzzle Hint if ((ScriptActionCtr_204 < 1) && (qObjIsPlayer(event_data->it_handle) == true)) { - aShowHUDMessage(Message_strings[35]); + aShowHUDMessage(TXT("BallFanPuzzleHint")); // Increment the script action counter if (ScriptActionCtr_204 < MAX_ACTION_CTR_VALUE) @@ -8755,7 +8494,7 @@ int16_t TriggerScript_001F::CallEvent(int event, tOSIRISEventInfo *data) { // Script 205: Big Fan 0: Hint if ((ScriptActionCtr_205 < 1) && (qObjIsPlayer(event_data->it_handle) == true)) { if (qObjExists(Object_handles[10]) == true) { - aShowHUDMessage(Message_strings[44]); + aShowHUDMessage(TXT("WindFanPuzzleHint")); } // Increment the script action counter @@ -8775,7 +8514,7 @@ int16_t TriggerScript_0020::CallEvent(int event, tOSIRISEventInfo *data) { // Script 206: Big Fan 1: Hint if ((ScriptActionCtr_206 < 1) && (qObjIsPlayer(event_data->it_handle) == true)) { if (qObjExists(Object_handles[11]) == true) { - aShowHUDMessage(Message_strings[44]); + aShowHUDMessage(TXT("WindFanPuzzleHint")); } // Increment the script action counter @@ -8835,7 +8574,7 @@ int16_t TriggerScript_000C::CallEvent(int event, tOSIRISEventInfo *data) { aComplexCinematicTrack(Object_handles[153], 0.000000f, 1.000000f); aComplexCinematicCameraOnPath(Path_indexes[16]); aComplexCinematicEndTrans(0); - aComplexCinematicEnd(Message_strings[2], 4.000000f); + aComplexCinematicEnd(TXT("EmptyMessage"), 4.000000f); // Increment the script action counter if (ScriptActionCtr_094 < MAX_ACTION_CTR_VALUE) @@ -8844,7 +8583,7 @@ int16_t TriggerScript_000C::CallEvent(int event, tOSIRISEventInfo *data) { // Script 179: NewCaptain: IntroStart if ((ScriptActionCtr_179 < 1) && (1)) { - aCinematicSimple(Path_indexes[17], Message_strings[48], Object_handles[19], 6.000000f, 1); + aCinematicSimple(Path_indexes[17], TXT("CaptainText"), Object_handles[19], 6.000000f, 1); aObjPlayAnim(Object_handles[19], 0, 5, 2.000000f, 1); aDoorSetPos(Door_handles[6], 0.000000f); aDoorLockUnlock(1, Door_handles[6]); @@ -8866,7 +8605,7 @@ int16_t TriggerScript_000C::CallEvent(int event, tOSIRISEventInfo *data) { aComplexCinematicTrack(Object_handles[164], 0.000000f, 1.000000f); aComplexCinematicCameraAtStoredPt(Room_indexes[49]); aComplexCinematicEndTrans(0); - aComplexCinematicEnd(Message_strings[48], 6.000000f); + aComplexCinematicEnd(TXT("CaptainText"), 6.000000f); aAISetState(1, Object_handles[19]); aAISetMaxSpeed(Object_handles[19], 10.000000f); aAIGoalFollowPath(Object_handles[19], Path_indexes[18], 1, 3, 1, 3, 3145988, -1); @@ -8889,7 +8628,7 @@ int16_t TriggerScript_001D::CallEvent(int event, tOSIRISEventInfo *data) { // Script 174: Captain Gadget: Player Entered Bunker if ((ScriptActionCtr_174 < 1) && (qObjIsPlayer(event_data->it_handle) == true)) { - aShowHUDMessage(Message_strings[49]); + aShowHUDMessage(TXT("EnteredBunker")); aUserVarInc(21); aDoorSetPos(Door_handles[6], 0.000000f); aDoorLockUnlock(1, Door_handles[6]); @@ -8910,7 +8649,7 @@ int16_t TriggerScript_000D::CallEvent(int event, tOSIRISEventInfo *data) { // Script 180: First Mate: INTRO if ((ScriptActionCtr_180 < 1) && (1)) { - aCinematicSimple(Path_indexes[21], Message_strings[52], Object_handles[22], 6.000000f, 1); + aCinematicSimple(Path_indexes[21], TXT("FirstMateText"), Object_handles[22], 6.000000f, 1); aSetObjectTimer(Object_handles[174], 3.000000f, -1); aDoorSetPos(Door_handles[8], 0.000000f); aDoorLockUnlock(1, Door_handles[8]); @@ -8951,7 +8690,7 @@ int16_t TriggerScript_000E::CallEvent(int event, tOSIRISEventInfo *data) { aComplexCinematicCameraOnPath(Path_indexes[22]); aComplexCinematicTextLayoutMode(32); aComplexCinematicEndTrans(3); - aComplexCinematicEnd(Message_strings[30], 5.000000f); + aComplexCinematicEnd(TXT("IncomingTransmit"), 5.000000f); // Increment the script action counter if (ScriptActionCtr_135 < MAX_ACTION_CTR_VALUE) @@ -8992,7 +8731,7 @@ int16_t TriggerScript_000F::CallEvent(int event, tOSIRISEventInfo *data) { aComplexCinematicTrack(Object_handles[211], 0.000000f, 1.000000f); aComplexCinematicText(0.200000f, 0.600000f); aComplexCinematicCameraOnPath(Path_indexes[25]); - aComplexCinematicEnd(Message_strings[30], 10.300000f); + aComplexCinematicEnd(TXT("IncomingTransmit"), 10.300000f); aUserVarSet(17, 0.000000f); aSetLevelTimer(2.000000f, 44); @@ -9012,7 +8751,7 @@ int16_t TriggerScript_0014::CallEvent(int event, tOSIRISEventInfo *data) { // Script 152: Exit if ((ScriptActionCtr_152 < 1) && (1)) { - aStartEndlevelSequence(Object_handles[213], Path_indexes[26], 8.000000f, Message_strings[2]); + aStartEndlevelSequence(Object_handles[213], Path_indexes[26], 8.000000f, TXT("EmptyMessage")); aTurnOnSpew(Object_handles[214], -1, 2, 0.000000f, 0.000000f, 65536, 0, 4.000000f, 0.150000f, 30.000000f, 25.000000f, 80.000000f, 1, -1); aTurnOnSpew(Object_handles[215], -1, 2, 0.000000f, 0.000000f, 65536, 0, 3.000000f, 0.150000f, 30.000000f, diff --git a/scripts/Merc4.cpp b/scripts/Merc4.cpp index e5bab276d..41d4700f2 100644 --- a/scripts/Merc4.cpp +++ b/scripts/Merc4.cpp @@ -22,10 +22,10 @@ // Filename: Merc4.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -967,180 +967,12 @@ void aClearTeleporterArea(int desthandle, int objhandle) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} +std::map Messages; -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} - -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -1290,39 +1122,6 @@ const char *Goal_names[NUM_GOAL_NAMES] = {"Engage Airlock Power", "Investigate and Destroy Alien Planetoid"}; int Goal_indexes[NUM_GOAL_NAMES]; -#define NUM_MESSAGE_NAMES 30 -const char *Message_names[NUM_MESSAGE_NAMES] = {"IntroText", - "AirlockPowerOn", - "AirlockDecompStarted", - "AirlockActive", - "AirlockPowerNotOn", - "AirlockCompStarted", - "AirlockMalfunction", - "BadDoorBumped", - "FFMessage", - "UseThruster", - "CruiserFuseAcquired", - "CruiserFusePlaced", - "CruiserFuseNoUse", - "QueenLeft", - "NoBurnIgnited", - "NoPowerAvail", - "IgniterFailed1", - "IgniterFailed2", - "BurnIgnited", - "ThrusterBurnFailed", - "RechargeThruster1", - "RechargeThruster2", - "Empty", - "GetOuttaHere", - "FuseRoom", - "BossIntro", - "DA1Game", - "DA1Hud", - "DA2Game", - "DA2Hud"}; -const char *Message_strings[NUM_MESSAGE_NAMES]; - // =============== // InitializeDLL() // =============== @@ -1336,37 +1135,19 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - char english_filename[(_MAX_PATH + 32) * 2]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - snprintf(english_filename, sizeof(english_filename), "%s.msg", filename); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); - else if (lang_type == LANGUAGE_POLISH) - strcat(filename, "_POL"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "Merc4.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { - if (lang_type == LANGUAGE_ENGLISH) { - mprintf(0, "ERROR: Could not load message file - %s\n", filename); - } else if (!ReadMessageFile(english_filename)) { - mprintf(0, "ERROR: Could not load message file - %s\n", english_filename); - } + mprintf(0, "ERROR: Could not load message file - %s\n", filename); } int j; @@ -1410,10 +1191,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } @@ -2036,7 +1813,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 002: Level Start - Into Movie if (1) { aMusicSetRegionAll(0); - aCinematicIntro(Path_indexes[0], Message_strings[0], Object_handles[36], Path_indexes[1], 12.000000f); + aCinematicIntro(Path_indexes[0], TXT("IntroText"), Object_handles[36], Path_indexes[1], 12.000000f); // Increment the script action counter if (ScriptActionCtr_002 < MAX_ACTION_CTR_VALUE) @@ -2068,7 +1845,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[1], Object_handles[45], 1.000000f); aDoorActivate(Door_handles[0]); if (qUserVarValue(0) == 12.000000f) { - aShowHUDMessage(Message_strings[6]); + aShowHUDMessage(TXT("AirlockMalfunction")); } aSetLevelTimer(2.000000f, 1); } else { @@ -2096,7 +1873,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[1], Object_handles[42], 1.000000f); aDoorActivate(Door_handles[1]); if (qUserVarValue(0) == 12.000000f) { - aShowHUDMessage(Message_strings[6]); + aShowHUDMessage(TXT("AirlockMalfunction")); } aSetLevelTimer(2.000000f, 5); } else { @@ -2184,7 +1961,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aEmitSparks(40.000000f, Object_handles[56]); aDoorSetPos(Door_handles[2], 0.650000f); aSoundPlayObject(Sound_indexes[8], Object_handles[55], 1.000000f); - aShowHUDMessage(Message_strings[7]); + aShowHUDMessage(TXT("BadDoorBumped")); } // Increment the script action counter @@ -2273,7 +2050,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 049: Do Nest Trigger if ((ScriptActionCtr_049 < 1) && (event_data->id == 26)) { - aShowHUDMessage(Message_strings[9]); + aShowHUDMessage(TXT("UseThruster")); aGoalEnableDisable(1, Goal_indexes[5]); // Increment the script action counter @@ -2303,7 +2080,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { } else { if (qGoalCompleted(Goal_indexes[8]) == true) { aGoalCompleted(Goal_indexes[8], 0); - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("QueenLeft")); } } } @@ -2319,12 +2096,12 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { if (ScriptActionCtr_033 == 0) { aTurnOnSpew(Object_handles[63], -1, 8, 0.000000f, 0.000000f, 65536, 0, 1.000000f, 0.300000f, -1.000000f, 12.000000f, 60.000000f, 0, 0); - aShowHUDMessage(Message_strings[16]); + aShowHUDMessage(TXT("IgniterFailed1")); aRoomChangeFog(Room_indexes[3], 0.500000f, 0.500000f, 0.500000f, 5000.000000f, 20.000000f); aSetLevelTimer(6.000000f, 19); } if (ScriptActionCtr_033 == 1) { - aShowHUDMessage(Message_strings[17]); + aShowHUDMessage(TXT("IgniterFailed2")); aGoalEnableDisable(1, Goal_indexes[9]); aSetLevelTimer(2.000000f, 18); } @@ -2337,17 +2114,17 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 034: Recharge Thruster Sequence if (event_data->id == 17) { if (qUserVarValue(3) == 0.000000f) { - aShowHUDMessage(Message_strings[19]); + aShowHUDMessage(TXT("ThrusterBurnFailed")); aSetLevelTimer(6.000000f, 17); aGoalEnableDisable(1, Goal_indexes[8]); aUserFlagSet(19, 1); } if (qUserVarValue(3) == 1.000000f) { - aShowHUDMessage(Message_strings[20]); + aShowHUDMessage(TXT("RechargeThruster1")); aSetLevelTimer(10.000000f, 17); } if (qUserVarValue(3) == 2.000000f) { - aShowHUDMessage(Message_strings[21]); + aShowHUDMessage(TXT("RechargeThruster2")); aSetLevelTimer(1.000000f, 18); } aUserVarInc(3); @@ -2402,7 +2179,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 038: Boss Death Sequence if (event_data->id == 22) { if (ScriptActionCtr_038 == 0) { - aCinematicSimple(Path_indexes[2], Message_strings[22], Object_handles[36], 15.000000f, 1); + aCinematicSimple(Path_indexes[2], TXT("Empty"), Object_handles[36], 15.000000f, 1); aStoreObjectInPositionClipboard(Object_handles[72]); aMoveObjectToPositionClipboard(Object_handles[37]); aObjPlayImmAnim(Object_handles[37], 1, 10, 2.000000f, 0); @@ -2480,7 +2257,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aGoalEnableDisable(1, Goal_indexes[11]); } if (ScriptActionCtr_039 == 1) { - aShowHUDMessage(Message_strings[23]); + aShowHUDMessage(TXT("GetOuttaHere")); aRoomSetDamage(Room_indexes[8], 1.000000f, 1); } @@ -2503,7 +2280,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 040: End Level Escape Movie if ((ScriptActionCtr_040 < 1) && (event_data->id == 24)) { aGoalCompleted(Goal_indexes[12], 1); - aStartEndlevelSequencePath(Path_indexes[4], Path_indexes[5], 3.500000f, Message_strings[22]); + aStartEndlevelSequencePath(Path_indexes[4], Path_indexes[5], 3.500000f, TXT("Empty")); // Increment the script action counter if (ScriptActionCtr_040 < MAX_ACTION_CTR_VALUE) @@ -2512,7 +2289,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 053: Boss Intro Cinematic if ((ScriptActionCtr_053 < 1) && (event_data->id == 28)) { - aCinematicSimple(Path_indexes[6], Message_strings[25], Object_handles[37], 13.000000f, 1); + aCinematicSimple(Path_indexes[6], TXT("BossIntro"), Object_handles[37], 13.000000f, 1); aSetLevelTimer(9.000000f, 29); // Increment the script action counter @@ -2543,7 +2320,7 @@ int16_t CustomObjectScript_0811::CallEvent(int event, tOSIRISEventInfo *data) { aObjPlayAnim(data->me_handle, 0, 3, 4.000000f, 0); aSoundPlayObject(Sound_indexes[0], data->me_handle, 1.000000f); aUserFlagSet(0, 1); - aShowHUDMessage(Message_strings[1]); + aShowHUDMessage(TXT("AirlockPowerOn")); aGoalCompleted(Goal_indexes[0], 1); // Increment the script action counter @@ -2574,18 +2351,18 @@ int16_t CustomObjectScript_0804::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[1], Object_handles[41], 1.000000f); aSoundPlayObject(Sound_indexes[1], Object_handles[42], 1.000000f); if (qDoorGetPos(Door_handles[0]) == 0.000000f) { - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("AirlockDecompStarted")); aUserVarSet(0, 0.000000f); aSetLevelTimer(2.000000f, 0); } else { aSetLevelTimer(2.000000f, 5); } } else { - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("AirlockActive")); aSoundPlayObject(Sound_indexes[2], data->me_handle, 1.000000f); } } else { - aShowHUDMessage(Message_strings[4]); + aShowHUDMessage(TXT("AirlockPowerNotOn")); aSoundPlayObject(Sound_indexes[2], data->me_handle, 1.000000f); aGoalEnableDisable(1, Goal_indexes[0]); } @@ -2621,18 +2398,18 @@ int16_t CustomObjectScript_0803::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[1], Object_handles[44], 1.000000f); aSoundPlayObject(Sound_indexes[1], Object_handles[45], 1.000000f); if (qDoorGetPos(Door_handles[1]) == 0.000000f) { - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("AirlockCompStarted")); aUserVarSet(0, 0.000000f); aSetLevelTimer(2.000000f, 4); } else { aSetLevelTimer(2.000000f, 1); } } else { - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("AirlockActive")); aSoundPlayObject(Sound_indexes[2], data->me_handle, 1.000000f); } } else { - aShowHUDMessage(Message_strings[4]); + aShowHUDMessage(TXT("AirlockPowerNotOn")); aSoundPlayObject(Sound_indexes[2], data->me_handle, 1.000000f); } } @@ -2830,7 +2607,7 @@ int16_t CustomObjectScript_09AC::CallEvent(int event, tOSIRISEventInfo *data) { // Script 024: Player Picks Up Cruiser Fuse if ((qObjIsPlayer(event_data->it_handle) == true) && (qUserFlag(8) == false)) { aSoundPlayObject(Sound_indexes[9], event_data->it_handle, 1.000000f); - aShowHUDMessageObj(Message_strings[10], event_data->it_handle); + aShowHUDMessageObj(TXT("CruiserFuseAcquired"), event_data->it_handle); aAddObjectToInventory(data->me_handle, event_data->it_handle, 0); aGoalCompleted(Goal_indexes[6], 1); @@ -2849,7 +2626,7 @@ int16_t CustomObjectScript_09AC::CallEvent(int event, tOSIRISEventInfo *data) { aMoveObjectToPositionClipboard(data->me_handle); aObjGhostSet(1, data->me_handle); aSoundPlayObject(Sound_indexes[10], Object_handles[59], 1.000000f); - aShowHUDMessage(Message_strings[11]); + aShowHUDMessage(TXT("CruiserFusePlaced")); aUserFlagSet(8, 1); aLightningCreate(Object_handles[60], Object_handles[61], 10000.000000f, 2.000000f, 3, Texture_indexes[2], 0.600000f, 1, 255, 255, 255, 0); @@ -2857,7 +2634,7 @@ int16_t CustomObjectScript_09AC::CallEvent(int event, tOSIRISEventInfo *data) { } else { aObjGhostSet(0, data->me_handle); aAddObjectToInventory(data->me_handle, event_data->it_handle, 0); - aShowHUDMessageObj(Message_strings[12], event_data->it_handle); + aShowHUDMessageObj(TXT("CruiserFuseNoUse"), event_data->it_handle); } // Increment the script action counter @@ -2902,7 +2679,7 @@ int16_t CustomObjectScript_1138::CallEvent(int event, tOSIRISEventInfo *data) { aSetLevelTimer(5.000000f, 17); } } else { - aShowHUDMessage(Message_strings[14]); + aShowHUDMessage(TXT("NoBurnIgnited")); } } else { aMiscShakeArea(Object_handles[63], 20.000000f, 5000.000000f); @@ -2918,7 +2695,7 @@ int16_t CustomObjectScript_1138::CallEvent(int event, tOSIRISEventInfo *data) { } } } else { - aShowHUDMessage(Message_strings[15]); + aShowHUDMessage(TXT("NoPowerAvail")); aGoalEnableDisable(1, Goal_indexes[6]); aGoalEnableDisable(1, Goal_indexes[7]); } @@ -3003,7 +2780,7 @@ int16_t CustomObjectScript_11D1::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_061 < 1) && (qObjIsPlayer(event_data->it_handle) == true)) { aObjPlayAnim(data->me_handle, 0, 10, 3.000000f, 0); aSoundPlayObject(Sound_indexes[15], data->me_handle, 1.000000f); - aAddGameMessage(Message_strings[26], Message_strings[27]); + aAddGameMessage(TXT("DA1Game"), TXT("DA1Hud")); // Increment the script action counter if (ScriptActionCtr_061 < MAX_ACTION_CTR_VALUE) @@ -3023,7 +2800,7 @@ int16_t CustomObjectScript_09D2::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_062 < 1) && (qObjIsPlayer(event_data->it_handle) == true)) { aObjPlayAnim(data->me_handle, 0, 10, 3.000000f, 0); aSoundPlayObject(Sound_indexes[15], data->me_handle, 1.000000f); - aAddGameMessage(Message_strings[28], Message_strings[29]); + aAddGameMessage(TXT("DA2Game"), TXT("DA2Hud")); // Increment the script action counter if (ScriptActionCtr_062 < MAX_ACTION_CTR_VALUE) @@ -3188,7 +2965,7 @@ int16_t TriggerScript_0004::CallEvent(int event, tOSIRISEventInfo *data) { if (qObjIsPlayer(event_data->it_handle) == true) { if ((qGoalCompleted(Goal_indexes[3]) == false) && (qGoalEnabled(Goal_indexes[3]) == false)) { aGoalEnableDisable(1, Goal_indexes[3]); - aShowHUDMessage(Message_strings[8]); + aShowHUDMessage(TXT("FFMessage")); } // Increment the script action counter @@ -3267,7 +3044,7 @@ int16_t TriggerScript_0002::CallEvent(int event, tOSIRISEventInfo *data) { aTurnOnSpew(Object_handles[63], -1, 1, 0.000000f, 0.000000f, 65536, 0, 1.000000f, 0.150000f, 1.000000f, 16.000000f, 70.000000f, 0, -1); aTurnOffSpew(0); - aShowHUDMessage(Message_strings[18]); + aShowHUDMessage(TXT("BurnIgnited")); aGoalCompleted(Goal_indexes[9], 1); aABThrusterIgnited(Object_handles[37]); aRoomSetFaceTexture(Room_indexes[3], 472, Texture_indexes[3]); @@ -3363,7 +3140,7 @@ int16_t TriggerScript_0008::CallEvent(int event, tOSIRISEventInfo *data) { // Script 056: Boss Intro Trigger #1 Hit if ((ScriptActionCtr_056 < 1) && (qObjIsPlayer(event_data->it_handle) == true)) { - aShowHUDMessage(Message_strings[24]); + aShowHUDMessage(TXT("FuseRoom")); aABStartWaitEffect(Object_handles[37]); aMusicSetRegion(3, event_data->it_handle); diff --git a/scripts/Merc6.cpp b/scripts/Merc6.cpp index b36f186a2..0c23c1ded 100644 --- a/scripts/Merc6.cpp +++ b/scripts/Merc6.cpp @@ -22,10 +22,10 @@ // Filename: Merc6.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -957,180 +957,12 @@ void aSetTargeting(int objhandle, int target, int alternate1, int alternate2) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} - -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; +std::map Messages; - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -1261,49 +1093,6 @@ const char *Goal_names[NUM_GOAL_NAMES] = {"Destroy Welder Bots", "Escape"}; int Goal_indexes[NUM_GOAL_NAMES]; -#define NUM_MESSAGE_NAMES 40 -const char *Message_names[NUM_MESSAGE_NAMES] = {"IntroText", - "Killwelders", - "DravisDoor", - "PTMCminedoor", - "Maintenance", - "HangarMatcen", - "CargoLoaded", - "PTMCforcefiledDown", - "CargoNotLoaded", - "ProtectCargo", - "CargoAtTT", - "CargoOnTT", - "CargoAtBase", - "ProtectCargo2", - "ProtectCargo3", - "CargoDestroyed", - "CargoDestroyed2", - "CargoDestroyed3", - "Ambush2", - "Ambush1", - "CEDBaseFFDown", - "ControlFFDown", - "Ambush3", - "TTLoading", - "NoTTCargo", - "SwitchHitFromOutside", - "NoCargoOnTT", - "OutOfAlign", - "TTUnloading", - "WrongWheelPos", - "LetsRock", - "BackupDeployed", - "Backup1", - "Backup2", - "Backup3", - "Backup4", - "ReactorSwitchHit", - "ReactorDoorOpening", - "ReactorBlownMessage", - "Empty"}; -const char *Message_strings[NUM_MESSAGE_NAMES]; - // =============== // InitializeDLL() // =============== @@ -1317,37 +1106,19 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - char english_filename[(_MAX_PATH + 32) * 2]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - snprintf(english_filename, sizeof(english_filename), "%s.msg", filename); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); - else if (lang_type == LANGUAGE_POLISH) - strcat(filename, "_POL"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "Merc6.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { - if (lang_type == LANGUAGE_ENGLISH) { - mprintf(0, "ERROR: Could not load message file - %s\n", filename); - } else if (!ReadMessageFile(english_filename)) { - mprintf(0, "ERROR: Could not load message file - %s\n", english_filename); - } + mprintf(0, "ERROR: Could not load message file - %s\n", filename); } int j; @@ -1391,10 +1162,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } @@ -1966,7 +1733,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 005: Check Number of Cards Picked Up if ((ScriptActionCtr_005 < 1) && (qUserVarValueInt(0) == 4)) { aDoorLockUnlock(0, Door_handles[0]); - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("PTMCminedoor")); aGoalCompleted(Goal_indexes[1], 1); // Increment the script action counter @@ -1978,7 +1745,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_023 < 1) && (qUserVarValue(2) == 3.000000f)) { aPortalRenderSet(0, 0, Room_indexes[4], 1); aGoalCompleted(Goal_indexes[7], 1); - aShowHUDMessage(Message_strings[21]); + aShowHUDMessage(TXT("ControlFFDown")); aSoundPlayObject(Sound_indexes[2], Object_handles[42], 1.000000f); aSoundPlayObject(Sound_indexes[4], Object_handles[43], 1.000000f); aSoundPlayObject(Sound_indexes[5], Object_handles[44], 1.000000f); @@ -1996,7 +1763,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { } } else { if (qGoalCompleted(Goal_indexes[9]) == true) { - aShowHUDMessage(Message_strings[27]); + aShowHUDMessage(TXT("OutOfAlign")); aGoalCompleted(Goal_indexes[9], 0); } } @@ -2096,7 +1863,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 086: Level Start - Intro Cinematic if (1) { - aCinematicIntro(Path_indexes[0], Message_strings[0], Object_handles[27], Path_indexes[1], 15.000000f); + aCinematicIntro(Path_indexes[0], TXT("IntroText"), Object_handles[27], Path_indexes[1], 15.000000f); aMusicSetRegionAll(0); // Increment the script action counter @@ -2109,7 +1876,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 087: Level Start - Show Welder Hint if ((ScriptActionCtr_087 < 1) && (event_data->id == 16)) { - aShowHUDMessage(Message_strings[1]); + aShowHUDMessage(TXT("Killwelders")); // Increment the script action counter if (ScriptActionCtr_087 < MAX_ACTION_CTR_VALUE) @@ -2163,7 +1930,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aAIGoalFollowPath(Object_handles[36], Path_indexes[9], 1, 58, 1, 3, 3145984, 2); aAIGoalSetCircleDistance(Object_handles[36], 3, 0.000000f); aCCSetData(Object_handles[36], Object_handles[35], 80.000000f, 20.000000f); - aShowHUDMessage(Message_strings[9]); + aShowHUDMessage(TXT("ProtectCargo")); aObjMakeVulnerable(Object_handles[19]); aObjMakeVulnerable(Object_handles[20]); aObjMakeVulnerable(Object_handles[21]); @@ -2206,13 +1973,13 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 070: A Crate Was Destroyed if (event_data->id == 9) { if (qUserVarValue(5) == 1.000000f) { - aShowHUDMessage(Message_strings[15]); + aShowHUDMessage(TXT("CargoDestroyed")); } if (qUserVarValue(5) == 2.000000f) { - aShowHUDMessage(Message_strings[16]); + aShowHUDMessage(TXT("CargoDestroyed2")); } if (qUserVarValue(5) == 3.000000f) { - aShowHUDMessage(Message_strings[17]); + aShowHUDMessage(TXT("CargoDestroyed3")); aSetLevelTimer(8.000000f, 10); } @@ -2233,7 +2000,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 075: Do Ambush Checks if (event_data->id == 12) { if ((qUserFlag(11) == false) && (qObjGetDistance(Object_handles[34], Object_handles[38]) < 100.000000f)) { - aShowHUDMessage(Message_strings[18]); + aShowHUDMessage(TXT("Ambush2")); aObjGhostSet(0, Object_handles[0]); aObjGhostSet(0, Object_handles[1]); aSetTargeting(Object_handles[0], Object_handles[19], Object_handles[20], Object_handles[21]); @@ -2245,7 +2012,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { } if ((qUserFlag(11) == true) && (qUserFlag(12) == false) && (qObjGetDistance(Object_handles[34], Object_handles[39]) < 100.000000f)) { - aShowHUDMessage(Message_strings[19]); + aShowHUDMessage(TXT("Ambush1")); aObjGhostSet(0, Object_handles[2]); aObjGhostSet(0, Object_handles[3]); aObjGhostSet(0, Object_handles[4]); @@ -2260,7 +2027,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { } if ((qUserFlag(16) == true) && (qUserFlag(13) == false) && (qObjGetDistance(Object_handles[34], Object_handles[40]) < 100.000000f)) { - aShowHUDMessage(Message_strings[19]); + aShowHUDMessage(TXT("Ambush1")); aObjGhostSet(0, Object_handles[5]); aObjGhostSet(0, Object_handles[6]); aObjGhostSet(0, Object_handles[7]); @@ -2275,7 +2042,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { } if ((qUserFlag(13) == true) && (qUserFlag(14) == false) && (qObjGetDistance(Object_handles[34], Object_handles[41]) < 100.000000f)) { - aShowHUDMessage(Message_strings[20]); + aShowHUDMessage(TXT("CEDBaseFFDown")); aPortalRenderSet(0, 0, Room_indexes[3], 1); aPortalRenderSet(0, 1, Room_indexes[3], 1); aPortalRenderSet(0, 2, Room_indexes[3], 1); @@ -2326,7 +2093,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 090: Fighter Spotted Message if ((ScriptActionCtr_090 < 1) && (event_data->id == 19)) { - aShowHUDMessage(Message_strings[22]); + aShowHUDMessage(TXT("Ambush3")); // Increment the script action counter if (ScriptActionCtr_090 < MAX_ACTION_CTR_VALUE) @@ -2393,7 +2160,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aSetLevelTimer(40.000000f, 18); } if (ScriptActionCtr_019 == 3) { - aShowHUDMessage(Message_strings[30]); + aShowHUDMessage(TXT("LetsRock")); } // Increment the script action counter @@ -2410,7 +2177,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aDoorLockUnlock(0, Door_handles[1]); aDoorActivate(Door_handles[1]); aSetLevelTimer(1.000000f, 8); - aShowHUDMessage(Message_strings[31]); + aShowHUDMessage(TXT("BackupDeployed")); } if (ScriptActionCtr_065 == 2) { aAISetState(1, Object_handles[16]); @@ -2428,7 +2195,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 089: Turn On Fight Matcens Sequence if (event_data->id == 18) { if (ScriptActionCtr_089 == 0) { - aShowHUDMessage(Message_strings[32]); + aShowHUDMessage(TXT("Backup1")); aMatcenSetEnableState(1, Matcen_indexes[0]); aMatcenSetEnableState(1, Matcen_indexes[3]); aMatcenSetState(1, Matcen_indexes[0]); @@ -2436,7 +2203,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aSetLevelTimer(20.000000f, 18); } if (ScriptActionCtr_089 == 1) { - aShowHUDMessage(Message_strings[33]); + aShowHUDMessage(TXT("Backup2")); aMatcenSetEnableState(1, Matcen_indexes[1]); aMatcenSetEnableState(1, Matcen_indexes[4]); aMatcenSetState(1, Matcen_indexes[1]); @@ -2444,7 +2211,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aSetLevelTimer(20.000000f, 18); } if (ScriptActionCtr_089 == 2) { - aShowHUDMessage(Message_strings[34]); + aShowHUDMessage(TXT("Backup3")); aMatcenSetEnableState(1, Matcen_indexes[2]); aMatcenSetEnableState(1, Matcen_indexes[8]); aMatcenSetState(1, Matcen_indexes[2]); @@ -2452,7 +2219,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aSetLevelTimer(20.000000f, 18); } if (ScriptActionCtr_089 == 3) { - aShowHUDMessage(Message_strings[35]); + aShowHUDMessage(TXT("Backup4")); aMatcenSetEnableState(1, Matcen_indexes[5]); aMatcenSetEnableState(1, Matcen_indexes[6]); aMatcenSetState(1, Matcen_indexes[5]); @@ -2490,7 +2257,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { if (ScriptActionCtr_064 == 2) { aDoorLockUnlock(0, Door_handles[2]); aDoorSetPos(Door_handles[2], 1.000000f); - aShowHUDMessage(Message_strings[37]); + aShowHUDMessage(TXT("ReactorDoorOpening")); } // Increment the script action counter @@ -2524,7 +2291,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { 3.000000f, 10.000000f, 0, -1); aGoalCompleted(Goal_indexes[12], 1); aGoalEnableDisable(1, Goal_indexes[13]); - aShowHUDMessage(Message_strings[38]); + aShowHUDMessage(TXT("ReactorBlownMessage")); aUserFlagSet(10, 1); aMatcenSetEnableState(1, Matcen_indexes[9]); aMatcenSetState(1, Matcen_indexes[9]); @@ -2555,7 +2322,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 011: Player Escaped - End Level if ((ScriptActionCtr_011 < 1) && (event_data->id == 11)) { aGoalCompleted(Goal_indexes[13], 1); - aStartEndlevelSequencePath(Path_indexes[25], Path_indexes[26], 6.000000f, Message_strings[39]); + aStartEndlevelSequencePath(Path_indexes[25], Path_indexes[26], 6.000000f, TXT("Empty")); aSetLevelTimer(1.500000f, 15); // Increment the script action counter @@ -2639,7 +2406,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { } if (qUserVarValue(1) == 3.000000f) { aAIGoalFollowPathSimple(event_data->it_handle, Path_indexes[8], 1048832, -1, 3); - aShowHUDMessage(Message_strings[6]); + aShowHUDMessage(TXT("CargoLoaded")); aUserFlagSet(1, 1); aGoalCompleted(Goal_indexes[3], 1); } @@ -2659,7 +2426,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aCCDisable(Object_handles[36]); } if (ScriptActionCtr_018 == 2) { - aShowHUDMessage(Message_strings[10]); + aShowHUDMessage(TXT("CargoAtTT")); aUserFlagSet(2, 1); } @@ -2679,7 +2446,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { if (ScriptActionCtr_059 == 2) { aPortalRenderSet(1, 0, Room_indexes[2], 1); aPortalRenderSet(1, 1, Room_indexes[2], 1); - aShowHUDMessage(Message_strings[11]); + aShowHUDMessage(TXT("CargoOnTT")); aUserFlagSet(3, 1); aGoalCompleted(Goal_indexes[5], 1); } @@ -2698,7 +2465,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aCCDisable(Object_handles[36]); } if ((ScriptActionCtr_062 == 2) && (qUserVarValue(5) < 3.000000f)) { - aShowHUDMessage(Message_strings[12]); + aShowHUDMessage(TXT("CargoAtBase")); aUserFlagSet(8, 1); aGoalCompleted(Goal_indexes[6], 1); aObjMakeInvuln(Object_handles[19], 1000000); @@ -2738,7 +2505,7 @@ int16_t CustomObjectScript_1006::CallEvent(int event, tOSIRISEventInfo *data) { // Script 014: Start Door Message if (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("DravisDoor")); // Increment the script action counter if (ScriptActionCtr_014 < MAX_ACTION_CTR_VALUE) @@ -2865,7 +2632,7 @@ int16_t CustomObjectScript_20A3::CallEvent(int event, tOSIRISEventInfo *data) { aObjDelete(data->me_handle); aSoundPlayObject(Sound_indexes[1], event_data->it_handle, 1.000000f); aUserVarInc(0); - aShowHUDMessage(Message_strings[4]); + aShowHUDMessage(TXT("Maintenance")); aGoalItemCompleted(Goal_indexes[1], 1, 1); // Increment the script action counter @@ -2887,7 +2654,7 @@ int16_t CustomObjectScript_08A5::CallEvent(int event, tOSIRISEventInfo *data) { aObjDelete(data->me_handle); aSoundPlayObject(Sound_indexes[1], event_data->it_handle, 1.000000f); aUserVarInc(0); - aShowHUDMessage(Message_strings[4]); + aShowHUDMessage(TXT("Maintenance")); aGoalItemCompleted(Goal_indexes[1], 2, 1); // Increment the script action counter @@ -2909,7 +2676,7 @@ int16_t CustomObjectScript_08A6::CallEvent(int event, tOSIRISEventInfo *data) { aObjDelete(data->me_handle); aSoundPlayObject(Sound_indexes[1], event_data->it_handle, 1.000000f); aUserVarInc(0); - aShowHUDMessage(Message_strings[4]); + aShowHUDMessage(TXT("Maintenance")); aGoalItemCompleted(Goal_indexes[1], 3, 1); // Increment the script action counter @@ -2931,7 +2698,7 @@ int16_t CustomObjectScript_08A7::CallEvent(int event, tOSIRISEventInfo *data) { aObjDelete(data->me_handle); aSoundPlayObject(Sound_indexes[1], event_data->it_handle, 1.000000f); aUserVarInc(0); - aShowHUDMessage(Message_strings[4]); + aShowHUDMessage(TXT("Maintenance")); aGoalItemCompleted(Goal_indexes[1], 4, 1); // Increment the script action counter @@ -2953,7 +2720,7 @@ int16_t CustomObjectScript_403E::CallEvent(int event, tOSIRISEventInfo *data) { aMatcenSetState(1, Matcen_indexes[7]); aObjPlayAnim(data->me_handle, 0, 1, 2.000000f, 0); aSoundPlayObject(Sound_indexes[3], data->me_handle, 1.000000f); - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("HangarMatcen")); aRoomSetFaceTexture(Room_indexes[0], 35, Texture_indexes[0]); // Increment the script action counter @@ -2975,7 +2742,7 @@ int16_t CustomObjectScript_783F::CallEvent(int event, tOSIRISEventInfo *data) { if (qUserFlag(1) == true) { aObjPlayAnim(data->me_handle, 0, 2, 3.000000f, 0); aSoundPlayObject(Sound_indexes[3], data->me_handle, 1.000000f); - aShowHUDMessage(Message_strings[7]); + aShowHUDMessage(TXT("PTMCforcefiledDown")); aPortalRenderSet(0, 8, Room_indexes[1], 1); aPortalRenderSet(0, 9, Room_indexes[1], 1); aPortalRenderSet(0, 10, Room_indexes[1], 1); @@ -2988,7 +2755,7 @@ int16_t CustomObjectScript_783F::CallEvent(int event, tOSIRISEventInfo *data) { aRoomSetFaceTexture(Room_indexes[0], 93, Texture_indexes[1]); aRoomSetFaceTexture(Room_indexes[0], 35, Texture_indexes[2]); } else { - aShowHUDMessage(Message_strings[8]); + aShowHUDMessage(TXT("CargoNotLoaded")); } // Increment the script action counter @@ -3008,9 +2775,9 @@ int16_t CustomObjectScript_1084::CallEvent(int event, tOSIRISEventInfo *data) { // Script 077: Crate #1 Damaged if (qUserFlag(15) == true) { if (qRandomValue(1.000000f, 100.000000f) < 50.000000f) { - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("ProtectCargo2")); } else { - aShowHUDMessage(Message_strings[14]); + aShowHUDMessage(TXT("ProtectCargo3")); } aUserFlagSet(15, 0); aSetLevelTimer(qRandomValue(8.000000f, 16.000000f), 14); @@ -3049,9 +2816,9 @@ int16_t CustomObjectScript_0885::CallEvent(int event, tOSIRISEventInfo *data) { // Script 079: Crate #2 Damaged if (qUserFlag(15) == true) { if (qRandomValue(1.000000f, 100.000000f) < 50.000000f) { - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("ProtectCargo2")); } else { - aShowHUDMessage(Message_strings[14]); + aShowHUDMessage(TXT("ProtectCargo3")); } aUserFlagSet(15, 0); aSetLevelTimer(qRandomValue(8.000000f, 16.000000f), 14); @@ -3090,9 +2857,9 @@ int16_t CustomObjectScript_1086::CallEvent(int event, tOSIRISEventInfo *data) { // Script 080: Crate #3 Damaged if (qUserFlag(15) == true) { if (qRandomValue(1.000000f, 100.000000f) < 50.000000f) { - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("ProtectCargo2")); } else { - aShowHUDMessage(Message_strings[14]); + aShowHUDMessage(TXT("ProtectCargo3")); } aUserFlagSet(15, 0); aSetLevelTimer(qRandomValue(8.000000f, 16.000000f), 14); @@ -3233,7 +3000,7 @@ int16_t CustomObjectScript_5847::CallEvent(int event, tOSIRISEventInfo *data) { if (qUserFlag(2) == true) { aObjPlayAnim(data->me_handle, 0, 10, 2.000000f, 0); aSoundPlayObject(Sound_indexes[3], data->me_handle, 1.000000f); - aShowHUDMessage(Message_strings[23]); + aShowHUDMessage(TXT("TTLoading")); aPortalRenderSet(0, 0, Room_indexes[2], 1); aPortalRenderSet(0, 1, Room_indexes[2], 1); aAIGoalLandOnObject(Object_handles[34], 1, Object_handles[46], 2, 3, 131328, 7); @@ -3246,10 +3013,10 @@ int16_t CustomObjectScript_5847::CallEvent(int event, tOSIRISEventInfo *data) { aCCEnable(Object_handles[36]); aUserFlagSet(5, 1); } else { - aShowHUDMessage(Message_strings[24]); + aShowHUDMessage(TXT("NoTTCargo")); } } else { - aShowHUDMessage(Message_strings[25]); + aShowHUDMessage(TXT("SwitchHitFromOutside")); } // Increment the script action counter @@ -3300,10 +3067,10 @@ int16_t CustomObjectScript_1048::CallEvent(int event, tOSIRISEventInfo *data) { aSetLevelTimer(5.000000f, 19); } } else { - aShowHUDMessage(Message_strings[26]); + aShowHUDMessage(TXT("NoCargoOnTT")); } } else { - aShowHUDMessage(Message_strings[25]); + aShowHUDMessage(TXT("SwitchHitFromOutside")); } // Increment the script action counter @@ -3330,7 +3097,7 @@ int16_t CustomObjectScript_104A::CallEvent(int event, tOSIRISEventInfo *data) { } aObjPlayAnim(data->me_handle, 0, 10, 2.000000f, 0); aSoundPlayObject(Sound_indexes[3], data->me_handle, 1.000000f); - aShowHUDMessage(Message_strings[28]); + aShowHUDMessage(TXT("TTUnloading")); aPortalRenderSet(0, 0, Room_indexes[5], 1); aPortalRenderSet(0, 1, Room_indexes[5], 1); aUserFlagSet(7, 1); @@ -3338,13 +3105,13 @@ int16_t CustomObjectScript_104A::CallEvent(int event, tOSIRISEventInfo *data) { aSetLevelTimer(1.000000f, 4); aGoalCompleted(Goal_indexes[8], 1); } else { - aShowHUDMessage(Message_strings[29]); + aShowHUDMessage(TXT("WrongWheelPos")); } } else { - aShowHUDMessage(Message_strings[26]); + aShowHUDMessage(TXT("NoCargoOnTT")); } } else { - aShowHUDMessage(Message_strings[25]); + aShowHUDMessage(TXT("SwitchHitFromOutside")); } // Increment the script action counter @@ -3365,7 +3132,7 @@ int16_t CustomObjectScript_108E::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_063 < 1) && (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true)) { aObjPlayAnim(data->me_handle, 0, 1, 2.000000f, 0); aSoundPlayObject(Sound_indexes[3], data->me_handle, 1.000000f); - aShowHUDMessage(Message_strings[36]); + aShowHUDMessage(TXT("ReactorSwitchHit")); aSetLevelTimer(1.000000f, 7); aGoalCompleted(Goal_indexes[11], 1); diff --git a/scripts/Merc7.cpp b/scripts/Merc7.cpp index 2005562a5..f53bd0c05 100644 --- a/scripts/Merc7.cpp +++ b/scripts/Merc7.cpp @@ -22,10 +22,10 @@ // Filename: Merc7.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -2001,180 +2001,12 @@ void dsCustomRestore(void *fileptr) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; +std::map Messages; - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} - -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -2407,13 +2239,6 @@ const char *Goal_names[NUM_GOAL_NAMES] = { "Place Bomb on Delivery Pad", "Get a Safe Distance from Bomb", "Assasinate President Suzuki of PTMC"}; int Goal_indexes[NUM_GOAL_NAMES]; -#define NUM_MESSAGE_NAMES 14 -const char *Message_names[NUM_MESSAGE_NAMES] = {"IntroMessage", "EmptyMessage", "BombInventory", "FiremenSummoning", - "FiremenDone", "DroidOnlyDoor", "DeliveryReady", "BombPadFull", - "BombDropSuccess", "BombDropFail", "BossName", "SafeFromBomb", - "ActivateBomb", "SuzukiDead"}; -const char *Message_strings[NUM_MESSAGE_NAMES]; - // =============== // InitializeDLL() // =============== @@ -2427,37 +2252,19 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - char english_filename[(_MAX_PATH + 32) * 2]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - snprintf(english_filename, sizeof(english_filename), "%s.msg", filename); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); - else if (lang_type == LANGUAGE_POLISH) - strcat(filename, "_POL"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "Merc7.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { - if (lang_type == LANGUAGE_ENGLISH) { - mprintf(0, "ERROR: Could not load message file - %s\n", filename); - } else if (!ReadMessageFile(english_filename)) { - mprintf(0, "ERROR: Could not load message file - %s\n", english_filename); - } + mprintf(0, "ERROR: Could not load message file - %s\n", filename); } int j; @@ -2501,10 +2308,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } @@ -3339,7 +3142,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_037 < 1) && ((qUserFlag(7) == true) && (qRoomHasPlayer(Room_indexes[11]) == true))) { aGoalCompleted(Goal_indexes[4], 1); aDoorSetPos(Door_handles[1], 0.000000f); - aShowHUDMessage(Message_strings[12]); + aShowHUDMessage(TXT("ActivateBomb")); aSetLevelTimer(3.000000f, 12); // Increment the script action counter @@ -3363,7 +3166,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { 30.000000f, 0, -1); aTurnOnSpew(Object_handles[3], 0, 7, 0.000000f, 0.000000f, 65536, 0, 1.300000f, 0.120000f, -1.000000f, 5.000000f, 30.000000f, 0, -1); - aCinematicSimple(Path_indexes[0], Message_strings[0], Object_handles[4], 9.000000f, 1); + aCinematicSimple(Path_indexes[0], TXT("IntroMessage"), Object_handles[4], 9.000000f, 1); // Increment the script action counter if (ScriptActionCtr_074 < MAX_ACTION_CTR_VALUE) @@ -3400,7 +3203,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aUserFlagSet(7, 0); aUserFlagSet(0, 0); aUserVarSet(0, 0.000000f); - aAddObjectToInventoryNamed(Object_handles[8], qPlayerClosest(Object_handles[8], -1), Message_strings[2], 0); + aAddObjectToInventoryNamed(Object_handles[8], qPlayerClosest(Object_handles[8], -1), TXT("BombInventory"), 0); aUserFlagSet(2, 0); aUserFlagSet(3, 0); aUserFlagSet(4, 0); @@ -3525,7 +3328,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aLightningCreate(Object_handles[114], Object_handles[115], 99999.000000f, 2.000000f, 1, Texture_indexes[1], 0.400000f, 3, 200, 255, 150, 0); aObjPlayAnim(Object_handles[116], 0, 54, 6.000000f, 0); - aCinematicSimple(Path_indexes[41], Message_strings[1], Object_handles[117], 6.000000f, 1); + aCinematicSimple(Path_indexes[41], TXT("EmptyMessage"), Object_handles[117], 6.000000f, 1); // Increment the script action counter if (ScriptActionCtr_045 < MAX_ACTION_CTR_VALUE) @@ -3670,7 +3473,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { } else { if (qUserFlag(4) == true) { aUserFlagSet(7, 1); - aShowHUDMessage(Message_strings[6]); + aShowHUDMessage(TXT("DeliveryReady")); aAIGoalPickUpObjectRad(event_data->it_handle, 0, Object_handles[104], 0.600000f, 3, 256, 20); } else { aAIGoalFollowPathSimple(event_data->it_handle, Path_indexes[39], 4352, 22, 3); @@ -3887,7 +3690,7 @@ int16_t CustomObjectScript_0885::CallEvent(int event, tOSIRISEventInfo *data) { // Script 088: IntroCam-2 if ((ScriptActionCtr_088 < 1) && (1)) { - aCinematicSimple(Path_indexes[1], Message_strings[1], Object_handles[5], 9.000000f, 1); + aCinematicSimple(Path_indexes[1], TXT("EmptyMessage"), Object_handles[5], 9.000000f, 1); // Increment the script action counter if (ScriptActionCtr_088 < MAX_ACTION_CTR_VALUE) @@ -3909,7 +3712,7 @@ int16_t CustomObjectScript_0884::CallEvent(int event, tOSIRISEventInfo *data) { 25.000000f, 0, -1); aTurnOnSpew(Object_handles[7], -1, 7, 0.000000f, 0.000000f, 65536, 0, 1.100000f, 0.100000f, -1.000000f, 3.000000f, 25.000000f, 0, -1); - aCinematicIntro(Path_indexes[2], Message_strings[1], data->me_handle, Path_indexes[3], 8.000000f); + aCinematicIntro(Path_indexes[2], TXT("EmptyMessage"), data->me_handle, Path_indexes[3], 8.000000f); // Increment the script action counter if (ScriptActionCtr_089 < MAX_ACTION_CTR_VALUE) @@ -4519,7 +4322,7 @@ int16_t CustomObjectScript_0995::CallEvent(int event, tOSIRISEventInfo *data) { ((ScriptActionCtr_025 > 0) == true) && ((ScriptActionCtr_023 > 0) == true)) { aGoalCompleted(Goal_indexes[1], 1); aSoundPlayObject(Sound_indexes[0], data->me_handle, 1.000000f); - aShowColoredHUDMessage(255, 0, 0, Message_strings[3]); + aShowColoredHUDMessage(255, 0, 0, TXT("FiremenSummoning")); aAIGoalFollowPathSimple(Object_handles[66], Path_indexes[32], 4352, 11, 3); aAIGoalFollowPathSimple(Object_handles[67], Path_indexes[32], 4352, 12, 3); aObjSetMovementType(data->me_handle, 1); @@ -4733,7 +4536,7 @@ int16_t CustomObjectScript_097A::CallEvent(int event, tOSIRISEventInfo *data) { // Script 112: FireOut! if (1) { aSoundStopObj(Object_handles[68]); - aShowColoredHUDMessage(255, 0, 0, Message_strings[4]); + aShowColoredHUDMessage(255, 0, 0, TXT("FiremenDone")); aRoomChangeFog(Room_indexes[10], 0.300000f, 0.300000f, 0.300000f, 300.000000f, 10.000000f); // Increment the script action counter @@ -4883,7 +4686,7 @@ int16_t CustomObjectScript_0805::CallEvent(int event, tOSIRISEventInfo *data) { aGoalCompleted(Goal_indexes[2], 1); aDoorSetPos(data->me_handle, 1.000000f); } else { - aShowHUDMessageObj(Message_strings[5], event_data->it_handle); + aShowHUDMessageObj(TXT("DroidOnlyDoor"), event_data->it_handle); } // Increment the script action counter @@ -4908,7 +4711,7 @@ int16_t CustomObjectScript_0804::CallEvent(int event, tOSIRISEventInfo *data) { ((ScriptActionCtr_031 > 0) == true)) { aDoorSetPos(data->me_handle, 1.000000f); } else { - aShowHUDMessageObj(Message_strings[5], event_data->it_handle); + aShowHUDMessageObj(TXT("DroidOnlyDoor"), event_data->it_handle); } // Increment the script action counter @@ -5002,7 +4805,7 @@ int16_t CustomObjectScript_087E::CallEvent(int event, tOSIRISEventInfo *data) { // Script 131: PICKUP Bomb if (qObjIsPlayer(event_data->it_handle) == true) { - aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, Message_strings[2], 0); + aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, TXT("BombInventory"), 0); // Increment the script action counter if (ScriptActionCtr_131 < MAX_ACTION_CTR_VALUE) @@ -5016,8 +4819,8 @@ int16_t CustomObjectScript_087E::CallEvent(int event, tOSIRISEventInfo *data) { if (qObjIsPlayer(event_data->it_handle) == true) { if (qObjGetDistance(event_data->it_handle, Object_handles[104]) <= 50.000000f) { if (((qObjExists(qObjSavedHandle(4)) == true) && (qUserFlag(2) == false)) || (qUserFlag(8) == true)) { - aShowHUDMessageObj(Message_strings[7], event_data->it_handle); - aAddObjectToInventoryNamed(Object_handles[8], event_data->it_handle, Message_strings[2], 0); + aShowHUDMessageObj(TXT("BombPadFull"), event_data->it_handle); + aAddObjectToInventoryNamed(Object_handles[8], event_data->it_handle, TXT("BombInventory"), 0); } else { aGoalCompleted(Goal_indexes[3], 1); aMusicSetRegionAll(5); @@ -5025,12 +4828,12 @@ int16_t CustomObjectScript_087E::CallEvent(int event, tOSIRISEventInfo *data) { aObjGhostSet(0, Object_handles[104]); aObjSpark(Object_handles[104], 50.000000f, 3.000000f); aEmitSparks(70.000000f, Object_handles[104]); - aShowHUDMessageObj(Message_strings[8], event_data->it_handle); + aShowHUDMessageObj(TXT("BombDropSuccess"), event_data->it_handle); aUserFlagSet(4, 1); } } else { - aShowHUDMessageObj(Message_strings[9], event_data->it_handle); - aAddObjectToInventoryNamed(Object_handles[8], event_data->it_handle, Message_strings[2], 0); + aShowHUDMessageObj(TXT("BombDropFail"), event_data->it_handle); + aAddObjectToInventoryNamed(Object_handles[8], event_data->it_handle, TXT("BombInventory"), 0); } // Increment the script action counter @@ -5068,7 +4871,7 @@ int16_t CustomObjectScript_1834::CallEvent(int event, tOSIRISEventInfo *data) { // Script 022: End Boss - Cinematic End if ((ScriptActionCtr_022 < 1) && (1)) { - aShowHUDMessage(Message_strings[11]); + aShowHUDMessage(TXT("SafeFromBomb")); aRoomFogSetState(0, Room_indexes[0]); // Increment the script action counter @@ -5088,7 +4891,7 @@ int16_t CustomObjectScript_1877::CallEvent(int event, tOSIRISEventInfo *data) { // Script 046: Suzuki Cam 3 if ((ScriptActionCtr_046 < 1) && (1)) { aObjPlayAnim(Object_handles[116], 0, 54, 6.000000f, 0); - aCinematicSimple(Path_indexes[42], Message_strings[1], Object_handles[119], 5.000000f, 1); + aCinematicSimple(Path_indexes[42], TXT("EmptyMessage"), Object_handles[119], 5.000000f, 1); // Increment the script action counter if (ScriptActionCtr_046 < MAX_ACTION_CTR_VALUE) @@ -5109,7 +4912,7 @@ int16_t CustomObjectScript_1078::CallEvent(int event, tOSIRISEventInfo *data) { aStoreObjectInPositionClipboard(Object_handles[120]); aMoveObjectToPositionClipboard(qObjSavedHandle(11)); aAIGoalFollowPathSimple(qObjSavedHandle(11), Path_indexes[43], 4352, -1, 3); - aCinematicSimple(Path_indexes[44], Message_strings[1], Object_handles[118], 7.000000f, 1); + aCinematicSimple(Path_indexes[44], TXT("EmptyMessage"), Object_handles[118], 7.000000f, 1); // Increment the script action counter if (ScriptActionCtr_049 < MAX_ACTION_CTR_VALUE) @@ -5139,7 +4942,7 @@ int16_t CustomObjectScript_1070::CallEvent(int event, tOSIRISEventInfo *data) { aSetObjectTimer(Object_handles[114], 7.000000f, -1); aSetObjectTimer(Object_handles[122], 8.500000f, -1); aObjPlayAnim(Object_handles[116], 54, 55, 1.000000f, 0); - aCinematicSimple(Path_indexes[46], Message_strings[1], Object_handles[123], 10.000000f, 1); + aCinematicSimple(Path_indexes[46], TXT("EmptyMessage"), Object_handles[123], 10.000000f, 1); // Increment the script action counter if (ScriptActionCtr_048 < MAX_ACTION_CTR_VALUE) @@ -5293,7 +5096,7 @@ int16_t CustomObjectScript_1079::CallEvent(int event, tOSIRISEventInfo *data) { aObjSetLightingDist(Object_handles[109], 200.000000f); aObjSetLightingColor(Object_handles[109], 1.000000f, 0.500000f, 0.250000f); aObjPlayAnim(Object_handles[116], 55, 74, 3.500000f, 0); - aCinematicSimple(Path_indexes[47], Message_strings[1], Object_handles[135], 5.000000f, 1); + aCinematicSimple(Path_indexes[47], TXT("EmptyMessage"), Object_handles[135], 5.000000f, 1); // Increment the script action counter if (ScriptActionCtr_047 < MAX_ACTION_CTR_VALUE) @@ -5416,7 +5219,7 @@ int16_t CustomObjectScript_1071::CallEvent(int event, tOSIRISEventInfo *data) { aRoomChangeFog(Room_indexes[14], 0.800000f, 0.400000f, 0.100000f, 150.000000f, 9.000000f); aRoomChangeFog(Room_indexes[15], 0.800000f, 0.400000f, 0.100000f, 150.000000f, 9.000000f); aObjDelete(Object_handles[109]); - aCinematicSimple(Path_indexes[48], Message_strings[1], Object_handles[147], 9.000000f, 1); + aCinematicSimple(Path_indexes[48], TXT("EmptyMessage"), Object_handles[147], 9.000000f, 1); // Increment the script action counter if (ScriptActionCtr_051 < MAX_ACTION_CTR_VALUE) @@ -5644,7 +5447,7 @@ int16_t CustomObjectScript_286E::CallEvent(int event, tOSIRISEventInfo *data) { if (1) { aGoalCompleted(Goal_indexes[5], 1); aDoorLockUnlock(0, Door_handles[0]); - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("SuzukiDead")); aRoomSetFog(Room_indexes[16], 0.200000f, 0.150000f, 0.100000f, 400.000000f); aRoomSetFog(Room_indexes[10], 0.200000f, 0.150000f, 0.100000f, 400.000000f); aRoomSetFog(Room_indexes[17], 0.200000f, 0.150000f, 0.100000f, 400.000000f); @@ -5754,7 +5557,7 @@ int16_t TriggerScript_0004::CallEvent(int event, tOSIRISEventInfo *data) { aGoalEnableDisable(1, Goal_indexes[0]); aCancelTimer(0); aRoomChangeFog(Room_indexes[0], 0.000000f, 0.000000f, 0.000000f, 800.000000f, 9.000000f); - aCinematicSimple(Path_indexes[40], Message_strings[10], Object_handles[105], 8.000000f, 1); + aCinematicSimple(Path_indexes[40], TXT("BossName"), Object_handles[105], 8.000000f, 1); aDoorSetPos(Door_handles[0], 0.000000f); aDoorLockUnlock(1, Door_handles[0]); diff --git a/scripts/Mysterious_Isle.cpp b/scripts/Mysterious_Isle.cpp index e9e021aff..8da00346d 100644 --- a/scripts/Mysterious_Isle.cpp +++ b/scripts/Mysterious_Isle.cpp @@ -22,10 +22,10 @@ // Filename: Mysterious_Isle.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -335,180 +335,12 @@ int qCustomCreateObjectAtObject(int type, int id, int handle) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} - -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; +std::map Messages; - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -555,10 +387,6 @@ int *Matcen_indexes = NULL; const char **Goal_names = NULL; int *Goal_indexes = NULL; -#define NUM_MESSAGE_NAMES 2 -const char *Message_names[NUM_MESSAGE_NAMES] = {"HackBot", "Message1"}; -const char *Message_strings[NUM_MESSAGE_NAMES]; - // =============== // InitializeDLL() // =============== @@ -572,37 +400,19 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - char english_filename[(_MAX_PATH + 32) * 2]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - snprintf(english_filename, sizeof(english_filename), "%s.msg", filename); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); - else if (lang_type == LANGUAGE_POLISH) - strcat(filename, "_POL"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "Mysterious_Isle.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { - if (lang_type == LANGUAGE_ENGLISH) { - mprintf(0, "ERROR: Could not load message file - %s\n", filename); - } else if (!ReadMessageFile(english_filename)) { - mprintf(0, "ERROR: Could not load message file - %s\n", english_filename); - } + mprintf(0, "ERROR: Could not load message file - %s\n", filename); } int j; @@ -646,10 +456,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } @@ -868,10 +674,10 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aUserVarSet(1, 0.000000f); aUserVarSet(2, 0.000000f); aSetLevelTimer(qRandomValue(10.000000f, 30.000000f), 7); - aObjSaveHandle(qCustomCreateObjectAtObject(2, qCustomGetID(Message_strings[0]), Object_handles[0]), 0); - aObjSaveHandle(qCustomCreateObjectAtObject(2, qCustomGetID(Message_strings[0]), Object_handles[1]), 1); - aObjSaveHandle(qCustomCreateObjectAtObject(2, qCustomGetID(Message_strings[0]), Object_handles[2]), 2); - aObjSaveHandle(qCustomCreateObjectAtObject(2, qCustomGetID(Message_strings[0]), Object_handles[3]), 3); + aObjSaveHandle(qCustomCreateObjectAtObject(2, qCustomGetID(TXT("HackBot")), Object_handles[0]), 0); + aObjSaveHandle(qCustomCreateObjectAtObject(2, qCustomGetID(TXT("HackBot")), Object_handles[1]), 1); + aObjSaveHandle(qCustomCreateObjectAtObject(2, qCustomGetID(TXT("HackBot")), Object_handles[2]), 2); + aObjSaveHandle(qCustomCreateObjectAtObject(2, qCustomGetID(TXT("HackBot")), Object_handles[3]), 3); aObjHide(qObjSavedHandle(0)); aObjHide(qObjSavedHandle(1)); aObjHide(qObjSavedHandle(2)); @@ -892,7 +698,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 013: Balloon creation and init if (1) { - aAIGoalFollowPathSimple(qCustomCreateObjectAtObject(2, qCustomGetID(Message_strings[1]), Object_handles[13]), + aAIGoalFollowPathSimple(qCustomCreateObjectAtObject(2, qCustomGetID(TXT("Message1")), Object_handles[13]), Path_indexes[0], 8392965, -1, 3); // Increment the script action counter diff --git a/scripts/Paranoia.cpp b/scripts/Paranoia.cpp index 99744bf1d..8cf02ea68 100644 --- a/scripts/Paranoia.cpp +++ b/scripts/Paranoia.cpp @@ -22,10 +22,10 @@ // Filename: paranoia.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -128,160 +128,12 @@ int num_messages; // Message File Functions // ====================== -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} - -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); +// Global storage for level script messages +std::map Messages; - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -313,10 +165,6 @@ int *Sound_indexes = NULL; const char **Texture_names = NULL; int *Texture_indexes = NULL; -#define NUM_MESSAGE_NAMES 0 -const char **Message_names = NULL; -const char **Message_strings = NULL; - // =============== // InitializeDLL() // =============== @@ -330,7 +178,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); ReadMessageFile("paranoia.msg"); int j; @@ -362,10 +209,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_TEXTURE_NAMES; j++) Texture_indexes[j] = Scrpt_FindTextureName(Texture_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } diff --git a/scripts/PiccuStation.cpp b/scripts/PiccuStation.cpp index 882771773..0dfe848db 100644 --- a/scripts/PiccuStation.cpp +++ b/scripts/PiccuStation.cpp @@ -22,10 +22,10 @@ // Filename: piccustation.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -979,180 +979,12 @@ void RestoreGlobalActionCtrs(void *file_ptr) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} +std::map Messages; -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -1289,13 +1121,6 @@ int Matcen_indexes[NUM_MATCEN_NAMES]; const char *Goal_names[NUM_GOAL_NAMES] = {"Activate Datlink", "Acquire the alien virus", "Retrieve the Alien Virus"}; int Goal_indexes[NUM_GOAL_NAMES]; -#define NUM_MESSAGE_NAMES 16 -const char *Message_names[NUM_MESSAGE_NAMES] = {"IntroMessage", "ForceFieldDeactivated", "2KeyCards", "1KeyCard", - "RadioRoomUnlock", "RadioRoomFirst", "All4Radio", "All4Radio2", - "TwoSwitchUnlock", "TwoSwitchFirst", "AlienCuplinks", "HeresVirus", - "Virus", "DestroyThese", "EndLevel", "PowerCupLink"}; -const char *Message_strings[NUM_MESSAGE_NAMES]; - // =============== // InitializeDLL() // =============== @@ -1309,7 +1134,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; @@ -1362,10 +1186,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } @@ -2201,7 +2021,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 071: IntroCam if (1 == true) { - aCinematicIntro(Path_indexes[0], Message_strings[0], Object_handles[9], Path_indexes[1], 15.000000f); + aCinematicIntro(Path_indexes[0], TXT("IntroMessage"), Object_handles[9], Path_indexes[1], 15.000000f); // Increment the script action counter if (ScriptActionCtr_071 < MAX_ACTION_CTR_VALUE) @@ -2270,8 +2090,8 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aGoalCompleted(Goal_indexes[0], 1); aRoomSetFaceTexture(Room_indexes[3], 42, Texture_indexes[4]); aPortalRenderSet(0, 0, Room_indexes[4], 1); - aShowHUDMessage(Message_strings[6]); - aShowHUDMessage(Message_strings[7]); + aShowHUDMessage(TXT("All4Radio")); + aShowHUDMessage(TXT("All4Radio2")); aUserVarSet(4, 1.000000f); aSoundPlaySteaming("VoxDispatcher.osf", 1.000000f); @@ -2297,7 +2117,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 031: All 12 Cuplinks if (event_data->id == 2) { - aShowHUDMessage(Message_strings[10]); + aShowHUDMessage(TXT("AlienCuplinks")); aObjSetLightingDist(Object_handles[32], 25.000000f); aObjSetLightingDist(Object_handles[33], 25.000000f); aObjSetLightingDist(Object_handles[34], 25.000000f); @@ -2345,7 +2165,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 044: CuplinkCamTimer if ((ScriptActionCtr_044 < 1) && (event_data->id == 6)) { aAISetTeam(196608, Object_handles[50]); - aCinematicSimple(Path_indexes[3], Message_strings[13], Object_handles[51], 10.000000f); + aCinematicSimple(Path_indexes[3], TXT("DestroyThese"), Object_handles[51], 10.000000f); // Increment the script action counter if (ScriptActionCtr_044 < MAX_ACTION_CTR_VALUE) @@ -2362,7 +2182,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aAIGoalFollowPathSimple(Object_handles[13], Path_indexes[5], 4352, -1); aAIGoalFollowPathSimple(Object_handles[12], Path_indexes[6], 4352, -1); } - aStartEndlevelSequencePath(Path_indexes[7], Path_indexes[8], 8.000000f, Message_strings[14]); + aStartEndlevelSequencePath(Path_indexes[7], Path_indexes[8], 8.000000f, TXT("EndLevel")); // Increment the script action counter if (ScriptActionCtr_046 < MAX_ACTION_CTR_VALUE) @@ -2383,7 +2203,7 @@ int16_t CustomObjectScript_2109::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[7], data->me_handle, 1.000000f); aObjPlayAnim(data->me_handle, 0, 4, 2.000000f, 0); aPortalRenderSet(0, 1, Room_indexes[0], 1); - aShowHUDMessage(Message_strings[1]); + aShowHUDMessage(TXT("ForceFieldDeactivated")); // Increment the script action counter if (ScriptActionCtr_001 < MAX_ACTION_CTR_VALUE) @@ -2406,7 +2226,7 @@ int16_t CustomObjectScript_206D::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[7], data->me_handle, 1.000000f); aObjPlayAnim(data->me_handle, 0, 4, 2.000000f, 0); aPortalRenderSet(0, 0, Room_indexes[1], 1); - aShowHUDMessage(Message_strings[1]); + aShowHUDMessage(TXT("ForceFieldDeactivated")); // Increment the script action counter if (ScriptActionCtr_004 < MAX_ACTION_CTR_VALUE) @@ -2429,7 +2249,7 @@ int16_t CustomObjectScript_306C::CallEvent(int event, tOSIRISEventInfo *data) { // Script 005: Outdoor Tank Killed if (1) { aPortalRenderSet(0, 0, Room_indexes[2], 1); - aShowHUDMessage(Message_strings[1]); + aShowHUDMessage(TXT("ForceFieldDeactivated")); // Increment the script action counter if (ScriptActionCtr_005 < MAX_ACTION_CTR_VALUE) @@ -2451,9 +2271,9 @@ int16_t CustomObjectScript_1869::CallEvent(int event, tOSIRISEventInfo *data) { aDoorLockUnlock(0, Door_handles[0]); aDoorSetPos(Door_handles[0], 1.000000f); aCreatePopupView(0, Object_handles[19], 8.000000f, 1.000000f); - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("2KeyCards")); } else { - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("1KeyCard")); } aSoundPlayObject(Sound_indexes[8], data->me_handle, 1.000000f); aObjDelete(data->me_handle); @@ -2478,9 +2298,9 @@ int16_t CustomObjectScript_186A::CallEvent(int event, tOSIRISEventInfo *data) { aDoorLockUnlock(0, Door_handles[0]); aDoorSetPos(Door_handles[0], 1.000000f); aCreatePopupView(0, Object_handles[19], 8.000000f, 1.000000f); - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("2KeyCards")); } else { - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("1KeyCard")); } aSoundPlayObject(Sound_indexes[8], data->me_handle, 1.000000f); aObjDelete(data->me_handle); @@ -2506,11 +2326,11 @@ int16_t CustomObjectScript_184A::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_017 > 0) == true) { aMatcenSetState(1, Matcen_indexes[0]); aCreatePopupView(0, Object_handles[22], 8.000000f, 1.000000f); - aShowHUDMessage(Message_strings[4]); + aShowHUDMessage(TXT("RadioRoomUnlock")); aDoorLockUnlock(0, Door_handles[1]); aDoorSetPos(Door_handles[1], 1.000000f); } else { - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("RadioRoomFirst")); } // Increment the script action counter @@ -2534,11 +2354,11 @@ int16_t CustomObjectScript_4049::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_009 > 0) == true) { aMatcenSetState(1, Matcen_indexes[0]); aCreatePopupView(0, Object_handles[22], 8.000000f, 1.000000f); - aShowHUDMessage(Message_strings[4]); + aShowHUDMessage(TXT("RadioRoomUnlock")); aDoorLockUnlock(0, Door_handles[1]); aDoorSetPos(Door_handles[1], 1.000000f); } else { - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("RadioRoomFirst")); } // Increment the script action counter @@ -2770,11 +2590,11 @@ int16_t CustomObjectScript_3072::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_029 > 0) == true) { aCreatePopupView(0, Object_handles[29], 8.000000f, 1.000000f); aMatcenSetState(1, Matcen_indexes[1]); - aShowHUDMessage(Message_strings[8]); + aShowHUDMessage(TXT("TwoSwitchUnlock")); aDoorLockUnlock(0, Door_handles[2]); aDoorSetPos(Door_handles[2], 1.000000f); } else { - aShowHUDMessage(Message_strings[9]); + aShowHUDMessage(TXT("TwoSwitchFirst")); } // Increment the script action counter @@ -2798,11 +2618,11 @@ int16_t CustomObjectScript_406F::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_028 > 0) == true) { aCreatePopupView(0, Object_handles[29], 8.000000f, 1.000000f); aMatcenSetState(1, Matcen_indexes[1]); - aShowHUDMessage(Message_strings[8]); + aShowHUDMessage(TXT("TwoSwitchUnlock")); aDoorLockUnlock(0, Door_handles[2]); aDoorSetPos(Door_handles[2], 1.000000f); } else { - aShowHUDMessage(Message_strings[9]); + aShowHUDMessage(TXT("TwoSwitchFirst")); } // Increment the script action counter @@ -2835,7 +2655,7 @@ int16_t CustomObjectScript_0B3C::CallEvent(int event, tOSIRISEventInfo *data) { if (1) { aUserVarInc(5); aSetObjectTimer(Object_handles[31], 0.000000f, -1); - aShowHUDMessage(Message_strings[15]); + aShowHUDMessage(TXT("PowerCupLink")); // Increment the script action counter if (ScriptActionCtr_003 < MAX_ACTION_CTR_VALUE) @@ -3033,7 +2853,7 @@ int16_t CustomObjectScript_6856::CallEvent(int event, tOSIRISEventInfo *data) { } aGoalCompleted(Goal_indexes[1], 1); aGoalCompleted(Goal_indexes[2], 1); - aShowHUDMessage(Message_strings[12]); + aShowHUDMessage(TXT("Virus")); aSoundPlayObject(Sound_indexes[8], data->me_handle, 1.000000f); aObjDelete(data->me_handle); @@ -3067,7 +2887,7 @@ int16_t CustomObjectScript_0B40::CallEvent(int event, tOSIRISEventInfo *data) { if (1) { aUserVarInc(5); aSetObjectTimer(Object_handles[31], 0.000000f, -1); - aShowHUDMessage(Message_strings[15]); + aShowHUDMessage(TXT("PowerCupLink")); // Increment the script action counter if (ScriptActionCtr_062 < MAX_ACTION_CTR_VALUE) @@ -3085,7 +2905,7 @@ int16_t CustomObjectScript_0B30::CallEvent(int event, tOSIRISEventInfo *data) { // Script 069: BunkChildDestroyed12 if (1) { - aShowHUDMessage(Message_strings[15]); + aShowHUDMessage(TXT("PowerCupLink")); aUserVarInc(5); aSetObjectTimer(Object_handles[31], 0.000000f, -1); @@ -3107,7 +2927,7 @@ int16_t CustomObjectScript_0B31::CallEvent(int event, tOSIRISEventInfo *data) { if (1) { aUserVarInc(5); aSetObjectTimer(Object_handles[31], 0.000000f, -1); - aShowHUDMessage(Message_strings[15]); + aShowHUDMessage(TXT("PowerCupLink")); // Increment the script action counter if (ScriptActionCtr_068 < MAX_ACTION_CTR_VALUE) @@ -3127,7 +2947,7 @@ int16_t CustomObjectScript_1B2E::CallEvent(int event, tOSIRISEventInfo *data) { if (1) { aUserVarInc(5); aSetObjectTimer(Object_handles[31], 0.000000f, -1); - aShowHUDMessage(Message_strings[15]); + aShowHUDMessage(TXT("PowerCupLink")); // Increment the script action counter if (ScriptActionCtr_067 < MAX_ACTION_CTR_VALUE) @@ -3147,7 +2967,7 @@ int16_t CustomObjectScript_0B2F::CallEvent(int event, tOSIRISEventInfo *data) { if (1) { aUserVarInc(5); aSetObjectTimer(Object_handles[31], 0.000000f, -1); - aShowHUDMessage(Message_strings[15]); + aShowHUDMessage(TXT("PowerCupLink")); // Increment the script action counter if (ScriptActionCtr_066 < MAX_ACTION_CTR_VALUE) @@ -3167,7 +2987,7 @@ int16_t CustomObjectScript_0B32::CallEvent(int event, tOSIRISEventInfo *data) { if (1) { aUserVarInc(5); aSetObjectTimer(Object_handles[31], 0.000000f, -1); - aShowHUDMessage(Message_strings[15]); + aShowHUDMessage(TXT("PowerCupLink")); // Increment the script action counter if (ScriptActionCtr_065 < MAX_ACTION_CTR_VALUE) @@ -3187,7 +3007,7 @@ int16_t CustomObjectScript_232D::CallEvent(int event, tOSIRISEventInfo *data) { if (1) { aUserVarInc(5); aSetObjectTimer(Object_handles[31], 0.000000f, -1); - aShowHUDMessage(Message_strings[15]); + aShowHUDMessage(TXT("PowerCupLink")); // Increment the script action counter if (ScriptActionCtr_064 < MAX_ACTION_CTR_VALUE) @@ -3207,7 +3027,7 @@ int16_t CustomObjectScript_0B3F::CallEvent(int event, tOSIRISEventInfo *data) { if (1) { aUserVarInc(5); aSetObjectTimer(Object_handles[31], 0.000000f, -1); - aShowHUDMessage(Message_strings[15]); + aShowHUDMessage(TXT("PowerCupLink")); // Increment the script action counter if (ScriptActionCtr_063 < MAX_ACTION_CTR_VALUE) @@ -3227,7 +3047,7 @@ int16_t CustomObjectScript_0B3B::CallEvent(int event, tOSIRISEventInfo *data) { if (1) { aUserVarInc(5); aSetObjectTimer(Object_handles[31], 0.000000f, -1); - aShowHUDMessage(Message_strings[15]); + aShowHUDMessage(TXT("PowerCupLink")); // Increment the script action counter if (ScriptActionCtr_061 < MAX_ACTION_CTR_VALUE) @@ -3247,7 +3067,7 @@ int16_t CustomObjectScript_0B3D::CallEvent(int event, tOSIRISEventInfo *data) { if (1) { aUserVarInc(5); aSetObjectTimer(Object_handles[31], 0.000000f, -1); - aShowHUDMessage(Message_strings[15]); + aShowHUDMessage(TXT("PowerCupLink")); // Increment the script action counter if (ScriptActionCtr_060 < MAX_ACTION_CTR_VALUE) @@ -3267,7 +3087,7 @@ int16_t CustomObjectScript_0B3E::CallEvent(int event, tOSIRISEventInfo *data) { if (1) { aUserVarInc(5); aSetObjectTimer(Object_handles[31], 0.000000f, -1); - aShowHUDMessage(Message_strings[15]); + aShowHUDMessage(TXT("PowerCupLink")); // Increment the script action counter if (ScriptActionCtr_006 < MAX_ACTION_CTR_VALUE) @@ -3455,7 +3275,7 @@ int16_t TriggerScript_0014::CallEvent(int event, tOSIRISEventInfo *data) { aObjMakeInvuln(Object_handles[11], 10); aAttachExistingObject(Object_handles[11], 0, Object_handles[48], 0); aObjGhostSet(0, Object_handles[11]); - aCinematicSimple(Path_indexes[2], Message_strings[11], Object_handles[49], 10.000000f); + aCinematicSimple(Path_indexes[2], TXT("HeresVirus"), Object_handles[49], 10.000000f); aSetLevelTimer(3.000000f, 3); aSetLevelTimer(10.000000f, 5); diff --git a/scripts/Polaris.cpp b/scripts/Polaris.cpp index f93387553..7967147c7 100644 --- a/scripts/Polaris.cpp +++ b/scripts/Polaris.cpp @@ -22,10 +22,10 @@ // Filename: Polaris.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -166,180 +166,12 @@ void RestoreGlobalActionCtrs(void *file_ptr) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} +std::map Messages; -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -383,10 +215,6 @@ int *Matcen_indexes = NULL; const char **Goal_names = NULL; int *Goal_indexes = NULL; -#define NUM_MESSAGE_NAMES 1 -const char *Message_names[NUM_MESSAGE_NAMES] = {"Polar"}; -const char *Message_strings[NUM_MESSAGE_NAMES]; - // =============== // InitializeDLL() // =============== @@ -400,26 +228,16 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "Polaris.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { mprintf(0, "ERROR: Could not load message file - %s\n", filename); @@ -466,10 +284,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } @@ -660,7 +474,7 @@ int16_t CustomObjectScript_303F::CallEvent(int event, tOSIRISEventInfo *data) { // Script 001: RunIntoMe! if (qObjIsPlayer(event_data->it_handle) == true) { aMiscViewerShake(70.000000f); - aShowHUDMessage(Message_strings[0]); + aShowHUDMessage(TXT("Polar")); aObjDestroy(event_data->it_handle); if (qUserFlag(0) == true) { aUserFlagSet(0, 0); diff --git a/scripts/Polaris_Ger.msg b/scripts/Polaris_GER.msg similarity index 100% rename from scripts/Polaris_Ger.msg rename to scripts/Polaris_GER.msg diff --git a/scripts/Quadsomniac.cpp b/scripts/Quadsomniac.cpp index d9269a9f0..fffcf30fd 100644 --- a/scripts/Quadsomniac.cpp +++ b/scripts/Quadsomniac.cpp @@ -22,10 +22,10 @@ // Filename: Quadsomniac3.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -195,180 +195,12 @@ void RestoreGlobalActionCtrs(void *file_ptr) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} +std::map Messages; -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -413,10 +245,6 @@ int *Matcen_indexes = NULL; const char **Goal_names = NULL; int *Goal_indexes = NULL; -#define NUM_MESSAGE_NAMES 0 -const char **Message_names = NULL; -const char **Message_strings = NULL; - // =============== // InitializeDLL() // =============== @@ -430,26 +258,16 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "Quadsomniac3.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { mprintf(0, "ERROR: Could not load message file - %s\n", filename); @@ -496,10 +314,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } diff --git a/scripts/Quadsomniac_Ger.msg b/scripts/Quadsomniac_Ger.msg deleted file mode 100644 index 9ad5f0791..000000000 --- a/scripts/Quadsomniac_Ger.msg +++ /dev/null @@ -1,7 +0,0 @@ -////////////////////////////////////////////// -// D.A.L.L.A.S. Generated Message Table File -////////////////////////////////////////////// - -NEXT_MESSAGE_ID_NUMBER 1 - -// Message List diff --git a/scripts/RudeAwakening.cpp b/scripts/RudeAwakening.cpp index b82c20db8..2392a0096 100644 --- a/scripts/RudeAwakening.cpp +++ b/scripts/RudeAwakening.cpp @@ -22,10 +22,10 @@ // Filename: RudeAwakening.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -195,180 +195,12 @@ void RestoreGlobalActionCtrs(void *file_ptr) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} +std::map Messages; -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -414,10 +246,6 @@ int *Matcen_indexes = NULL; const char **Goal_names = NULL; int *Goal_indexes = NULL; -#define NUM_MESSAGE_NAMES 0 -const char **Message_names = NULL; -const char **Message_strings = NULL; - // =============== // InitializeDLL() // =============== @@ -431,26 +259,16 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "RudeAwakening.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { mprintf(0, "ERROR: Could not load message file - %s\n", filename); @@ -497,10 +315,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } diff --git a/scripts/SewerRat.cpp b/scripts/SewerRat.cpp index 9bcea2729..585e01e31 100644 --- a/scripts/SewerRat.cpp +++ b/scripts/SewerRat.cpp @@ -22,10 +22,10 @@ // Filename: SewerRat.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -118,180 +118,12 @@ void RestoreGlobalActionCtrs(void *file_ptr) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} +std::map Messages; -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -338,10 +170,6 @@ int Matcen_indexes[NUM_MATCEN_NAMES]; const char **Goal_names = NULL; int *Goal_indexes = NULL; -#define NUM_MESSAGE_NAMES 0 -const char **Message_names = NULL; -const char **Message_strings = NULL; - // =============== // InitializeDLL() // =============== @@ -355,26 +183,16 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "SewerRat.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { mprintf(0, "ERROR: Could not load message file - %s\n", filename); @@ -421,10 +239,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } diff --git a/scripts/TrainingMission.cpp b/scripts/TrainingMission.cpp index 0fe1309f2..3d58f9f9f 100644 --- a/scripts/TrainingMission.cpp +++ b/scripts/TrainingMission.cpp @@ -22,10 +22,10 @@ // Filename: TrainingMission.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -644,185 +644,6 @@ void aToggleAllPlayerControls(int enable, int playernum) { // End of Custom Script Block - DO NOT EDIT ANYTHING AFTER THIS // ============================================================ -// ================= -// Message File Data -// ================= - -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - -// Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} - -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} - //====================== // Name List Arrays //====================== @@ -872,44 +693,12 @@ int *Matcen_indexes = NULL; const char **Goal_names = NULL; int *Goal_indexes = NULL; -#define NUM_MESSAGE_NAMES 36 -const char *Message_names[NUM_MESSAGE_NAMES] = {"GoodJob", - "GoBackwards", - "Welcome", - "GoForward", - "GoLeft", - "GoRight", - "GoUp", - "GoDown", - "Repeat", - "ContinueToCourse", - "CourseInstructions", - "DodgeIntro", - "Dodge30", - "LeaveDodge", - "FollowIntro", - "FollowInstructions", - "KeepDodging", - "KeepMovingOutofDodging", - "BankIntro", - "AlmostDoneDodge", - "ManuverIntro", - "HeadingIntro", - "PitchIntro", - "WeaponsEnabled", - "DestroyFollowbot", - "Movingbotintro", - "ExitManuveur", - "GBIntro", - "UseCameraMonitor", - "KillBotIntro", - "KillBot2", - "ProceedtoLastRoom", - "FinalSessionIntro", - "AllDone", - "GBExtra", - "GetCameraMonitor"}; -const char *Message_strings[NUM_MESSAGE_NAMES]; +// Global storage for level script messages +std::map Messages; + +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) // =============== // InitializeDLL() @@ -924,26 +713,16 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "TrainingMission.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { mprintf(0, "ERROR: Could not load message file - %s\n", filename); @@ -990,10 +769,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } @@ -1359,7 +1134,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aCancelTimer(2); aSetObjectTimer(Object_handles[12], 14.000000f, 3); aSetObjectTimer(Object_handles[5], 20.000000f, 2); - aShowHUDMessage(Message_strings[16]); + aShowHUDMessage(TXT("KeepDodging")); aObjSetShields(qGetPlayerObj(0), 100.000000f); // Increment the script action counter @@ -1440,7 +1215,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { ((qObjIsType(qGetBuddyObj(0), 2) == true) && ((ScriptActionCtr_032 > 0) == true))) { aSoundPlaySteamingText("GuideBotB.osf", 1.000000f); aToggleAllPlayerControls(1, 0); - aShowHUDMessage(Message_strings[35]); + aShowHUDMessage(TXT("GetCameraMonitor")); // Increment the script action counter if (ScriptActionCtr_060 < MAX_ACTION_CTR_VALUE) @@ -1454,7 +1229,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aPortalRenderSet(0, 0, Room_indexes[4], 1); aPortalRenderSet(0, 1, Room_indexes[4], 1); aSoundPlaySteamingText("proceed6.osf", 1.000000f); - aShowHUDMessage(Message_strings[0]); + aShowHUDMessage(TXT("GoodJob")); // Increment the script action counter if (ScriptActionCtr_058 < MAX_ACTION_CTR_VALUE) @@ -1512,9 +1287,9 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 002: First Hud Mesage Timer if ((ScriptActionCtr_002 < 1) && ((ScriptActionCtr_002 > 0) == false)) { - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("Welcome")); aSoundPlaySteamingText("welcome.osf", 1.000000f); - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("GoForward")); // Increment the script action counter if (ScriptActionCtr_002 < MAX_ACTION_CTR_VALUE) @@ -1524,8 +1299,8 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 023: Done Bank -- Start Follow if ((ScriptActionCtr_023 < 1) && (((ScriptActionCtr_024 > 0) == true) && (4 == event_data->id))) { aTogglePlayerControl(1, 0, 4032); - aShowHUDMessage(Message_strings[14]); - aShowHUDMessage(Message_strings[15]); + aShowHUDMessage(TXT("FollowIntro")); + aShowHUDMessage(TXT("FollowInstructions")); aAISetState(1, Object_handles[13]); aAISetTeam(65536, Object_handles[13]); aSetObjectTimer(Object_handles[13], 20.000000f, 7); @@ -1541,7 +1316,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_024 < 1) && ((ScriptActionCtr_022 > 0) == true)) { aToggleAllPlayerControls(0, 0); aTogglePlayerControl(1, 0, 3072); - aShowHUDMessage(Message_strings[18]); + aShowHUDMessage(TXT("BankIntro")); aSoundPlaySteamingText("bank.osf", 1.000000f); aSetLevelTimer(15.000000f, 4); @@ -1552,10 +1327,10 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 022: Done Heading -- Start Pitch Time if ((ScriptActionCtr_022 < 1) && ((ScriptActionCtr_021 > 0) == true)) { - aShowHUDMessage(Message_strings[0]); + aShowHUDMessage(TXT("GoodJob")); aToggleAllPlayerControls(0, 0); aTogglePlayerControl(1, 0, 192); - aShowHUDMessage(Message_strings[22]); + aShowHUDMessage(TXT("PitchIntro")); aSoundPlaySteamingText("pitch.osf", 1.000000f); aSetLevelTimer(12.000000f, 4); @@ -1566,11 +1341,11 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 027: Follow Bot Destroyed if ((ScriptActionCtr_027 < 1) && (event_data->id == 11)) { - aShowHUDMessage(Message_strings[0]); + aShowHUDMessage(TXT("GoodJob")); aAISetTeam(65536, Object_handles[15]); aAISetTeam(65536, Object_handles[16]); aObjGhostSet(0, Object_handles[16]); - aShowHUDMessage(Message_strings[25]); + aShowHUDMessage(TXT("Movingbotintro")); aSoundPlaySteamingText("kill1.osf", 1.000000f); aAIGoalFollowPathSimple(Object_handles[16], Path_indexes[0], 8392960, -1, 3); @@ -1581,8 +1356,8 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 029: DestroyBot2 Destroyed if (event_data->id == 12) { - aShowHUDMessage(Message_strings[0]); - aShowHUDMessage(Message_strings[26]); + aShowHUDMessage(TXT("GoodJob")); + aShowHUDMessage(TXT("ExitManuveur")); aToggleShowPlayerControl(0, 0); aSoundPlaySteamingText("proceed5.osf", 1.000000f); @@ -1602,7 +1377,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 039: Killbot Message 2 if (event_data->id == 14) { aSoundPlaySteamingText("GuidebotF.osf", 1.000000f); - aShowHUDMessage(Message_strings[30]); + aShowHUDMessage(TXT("KillBotIntroKillBot2")); // Increment the script action counter if (ScriptActionCtr_039 < MAX_ACTION_CTR_VALUE) @@ -1611,8 +1386,8 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 049: Ready for last room if ((ScriptActionCtr_049 < 1) && (event_data->id == 9)) { - aShowHUDMessage(Message_strings[0]); - aShowHUDMessage(Message_strings[31]); + aShowHUDMessage(TXT("GoodJob")); + aShowHUDMessage(TXT("ProceedtoLastRoom")); aSoundPlaySteamingText("proceed5.osf", 1.000000f); // Increment the script action counter @@ -1622,7 +1397,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 056: All Bots killed if ((ScriptActionCtr_056 < 1) && (event_data->id == 10)) { - aShowHUDMessage(Message_strings[33]); + aShowHUDMessage(TXT("AllDone")); aSoundPlaySteamingText("done.osf", 1.000000f); // Increment the script action counter @@ -1641,9 +1416,9 @@ int16_t CustomObjectScript_300D::CallEvent(int event, tOSIRISEventInfo *data) { // Script 001: FirstGoal if ((ScriptActionCtr_001 < 1) && (1)) { - aShowHUDMessage(Message_strings[0]); + aShowHUDMessage(TXT("GoodJob")); aSoundPlaySteamingText("return1.osf", 1.000000f); - aShowHUDMessage(Message_strings[1]); + aShowHUDMessage(TXT("GoBackwards")); aTogglePlayerControl(0, 0, 1); aTogglePlayerControl(1, 0, 2); @@ -1657,7 +1432,7 @@ int16_t CustomObjectScript_300D::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlay2D(Sound_indexes[0], 1.000000f); aTogglePlayerControl(0, 0, 1); aTogglePlayerControl(1, 0, 2); - aShowHUDMessage(Message_strings[1]); + aShowHUDMessage(TXT("GoBackwards")); // Increment the script action counter if (ScriptActionCtr_008 < MAX_ACTION_CTR_VALUE) @@ -1675,7 +1450,7 @@ int16_t CustomObjectScript_300C::CallEvent(int event, tOSIRISEventInfo *data) { // Script 003: Return to Start from Forward Goal if ((ScriptActionCtr_003 < 1) && ((ScriptActionCtr_001 > 0) == true)) { - aShowHUDMessage(Message_strings[4]); + aShowHUDMessage(TXT("GoLeft")); aTogglePlayerControl(0, 0, 2); aSoundPlaySteamingText("left1.osf", 1.000000f); aTogglePlayerControl(1, 0, 4); @@ -1689,9 +1464,9 @@ int16_t CustomObjectScript_300C::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_005 < 1) && ((ScriptActionCtr_004 > 0) == true)) { aTogglePlayerControl(0, 0, 8); aTogglePlayerControl(1, 0, 16); - aShowHUDMessage(Message_strings[0]); + aShowHUDMessage(TXT("GoodJob")); aSoundPlaySteamingText("up1.osf", 1.000000f); - aShowHUDMessage(Message_strings[6]); + aShowHUDMessage(TXT("GoUp")); // Increment the script action counter if (ScriptActionCtr_005 < MAX_ACTION_CTR_VALUE) @@ -1700,9 +1475,9 @@ int16_t CustomObjectScript_300C::CallEvent(int event, tOSIRISEventInfo *data) { // Script 007: Return to Start from Up Goal if ((ScriptActionCtr_007 < 1) && ((ScriptActionCtr_006 > 0) == true)) { - aShowHUDMessage(Message_strings[0]); - aShowHUDMessage(Message_strings[8]); - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("GoodJob")); + aShowHUDMessage(TXT("Repeat")); + aShowHUDMessage(TXT("GoForward")); aSoundPlaySteamingText("repeat.osf", 1.000000f); aTogglePlayerControl(0, 0, 32); aTogglePlayerControl(1, 0, 1); @@ -1717,7 +1492,7 @@ int16_t CustomObjectScript_300C::CallEvent(int event, tOSIRISEventInfo *data) { aTogglePlayerControl(0, 0, 2); aSoundPlaySteamingText("lright.osf", 1.000000f); aTogglePlayerControl(1, 0, 4); - aShowHUDMessage(Message_strings[4]); + aShowHUDMessage(TXT("GoLeft")); // Increment the script action counter if (ScriptActionCtr_009 < MAX_ACTION_CTR_VALUE) @@ -1729,7 +1504,7 @@ int16_t CustomObjectScript_300C::CallEvent(int event, tOSIRISEventInfo *data) { aTogglePlayerControl(0, 0, 8); aTogglePlayerControl(1, 0, 16); aSoundPlaySteamingText("udown.osf", 1.000000f); - aShowHUDMessage(Message_strings[6]); + aShowHUDMessage(TXT("GoUp")); // Increment the script action counter if (ScriptActionCtr_011 < MAX_ACTION_CTR_VALUE) @@ -1741,7 +1516,7 @@ int16_t CustomObjectScript_300C::CallEvent(int event, tOSIRISEventInfo *data) { aPortalRenderSet(0, 0, Room_indexes[0], 1); aPortalRenderSet(0, 1, Room_indexes[0], 1); aSoundPlaySteamingText("proceed1.osf", 1.000000f); - aShowHUDMessage(Message_strings[9]); + aShowHUDMessage(TXT("ContinueToCourse")); // Increment the script action counter if (ScriptActionCtr_013 < MAX_ACTION_CTR_VALUE) @@ -1761,9 +1536,9 @@ int16_t CustomObjectScript_300B::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_004 < 1) && (1)) { aTogglePlayerControl(0, 0, 4); aTogglePlayerControl(1, 0, 8); - aShowHUDMessage(Message_strings[0]); + aShowHUDMessage(TXT("GoodJob")); aSoundPlaySteamingText("return2.osf", 1.000000f); - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("GoRight")); // Increment the script action counter if (ScriptActionCtr_004 < MAX_ACTION_CTR_VALUE) @@ -1775,7 +1550,7 @@ int16_t CustomObjectScript_300B::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlay2D(Sound_indexes[0], 1.000000f); aTogglePlayerControl(0, 0, 4); aTogglePlayerControl(1, 0, 8); - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("GoRight")); // Increment the script action counter if (ScriptActionCtr_010 < MAX_ACTION_CTR_VALUE) @@ -1793,8 +1568,8 @@ int16_t CustomObjectScript_4809::CallEvent(int event, tOSIRISEventInfo *data) { // Script 006: Up Goal if ((ScriptActionCtr_006 < 1) && (1)) { - aShowHUDMessage(Message_strings[0]); - aShowHUDMessage(Message_strings[7]); + aShowHUDMessage(TXT("GoodJob")); + aShowHUDMessage(TXT("GoDown")); aTogglePlayerControl(0, 0, 16); aSoundPlaySteamingText("return3.osf", 1.000000f); aTogglePlayerControl(1, 0, 32); @@ -1809,7 +1584,7 @@ int16_t CustomObjectScript_4809::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlay2D(Sound_indexes[0], 1.000000f); aTogglePlayerControl(0, 0, 16); aTogglePlayerControl(1, 0, 32); - aShowHUDMessage(Message_strings[7]); + aShowHUDMessage(TXT("GoDown")); // Increment the script action counter if (ScriptActionCtr_012 < MAX_ACTION_CTR_VALUE) @@ -1828,7 +1603,7 @@ int16_t CustomObjectScript_1803::CallEvent(int event, tOSIRISEventInfo *data) { // Script 014: Start Course if ((ScriptActionCtr_014 < 1) && (1)) { aPortalRenderSet(1, 1, Room_indexes[0], 1); - aShowHUDMessage(Message_strings[10]); + aShowHUDMessage(TXT("CourseInstructions")); aSoundPlaySteamingText("Intro1.osf", 1.000000f); aTogglePlayerControl(1, 0, 63); @@ -1852,9 +1627,9 @@ int16_t CustomObjectScript_1806::CallEvent(int event, tOSIRISEventInfo *data) { aTogglePlayerControl(1, 0, 32); aPortalRenderSet(0, 0, Room_indexes[1], 1); aPortalRenderSet(0, 1, Room_indexes[1], 1); - aShowHUDMessage(Message_strings[0]); + aShowHUDMessage(TXT("GoodJob")); aSoundPlaySteamingText("proceed2.osf", 1.000000f); - aShowHUDMessage(Message_strings[9]); + aShowHUDMessage(TXT("ContinueToCourse")); // Increment the script action counter if (ScriptActionCtr_015 < MAX_ACTION_CTR_VALUE) @@ -1877,7 +1652,7 @@ int16_t CustomObjectScript_100A::CallEvent(int event, tOSIRISEventInfo *data) { aPortalRenderSet(1, 0, Room_indexes[1], 1); aPortalRenderSet(1, 1, Room_indexes[1], 1); aSoundPlaySteamingText("intro2.osf", 1.000000f); - aShowHUDMessage(Message_strings[11]); + aShowHUDMessage(TXT("DodgeIntro")); aSetObjectTimer(data->me_handle, 10.000000f, 8); // Increment the script action counter @@ -1891,7 +1666,7 @@ int16_t CustomObjectScript_100A::CallEvent(int event, tOSIRISEventInfo *data) { // Script 016: Start Dodge if ((ScriptActionCtr_016 < 1) && (event_data->id == 8)) { aObjSetShields(qGetPlayerObj(0), 100.000000f); - aShowHUDMessage(Message_strings[12]); + aShowHUDMessage(TXT("Dodge30")); aSetObjectTimer(Object_handles[5], 20.000000f, 2); aSetObjectTimer(Object_handles[12], 14.000000f, 3); aAISetState(1, Object_handles[12]); @@ -1917,7 +1692,7 @@ int16_t CustomObjectScript_300E::CallEvent(int event, tOSIRISEventInfo *data) { aPortalRenderSet(0, 1, Room_indexes[2], 1); aTogglePlayerControl(0, 0, 62); aSoundPlaySteamingText("proceed4.osf", 1.000000f); - aShowHUDMessage(Message_strings[17]); + aShowHUDMessage(TXT("KeepMovingOutofDodging")); // Increment the script action counter if (ScriptActionCtr_019 < MAX_ACTION_CTR_VALUE) @@ -1935,8 +1710,8 @@ int16_t CustomObjectScript_300E::CallEvent(int event, tOSIRISEventInfo *data) { aAISetState(0, Object_handles[12]); aTogglePlayerControl(1, 0, 3); aSoundPlaySteamingText("proceed3.osf", 1.000000f); - aShowHUDMessage(Message_strings[0]); - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("GoodJob")); + aShowHUDMessage(TXT("LeaveDodge")); // Increment the script action counter if (ScriptActionCtr_017 < MAX_ACTION_CTR_VALUE) @@ -1955,7 +1730,7 @@ int16_t CustomObjectScript_2007::CallEvent(int event, tOSIRISEventInfo *data) { // Script 020: Almost Done dodging if (event_data->id == 3) { aSoundPlaySteamingText("almost.osf", 1.000000f); - aShowHUDMessage(Message_strings[19]); + aShowHUDMessage(TXT("AlmostDoneDodge")); // Increment the script action counter if (ScriptActionCtr_020 < MAX_ACTION_CTR_VALUE) @@ -1978,11 +1753,11 @@ int16_t CustomObjectScript_080F::CallEvent(int event, tOSIRISEventInfo *data) { aToggleAllPlayerControls(0, 0); aPortalRenderSet(1, 1, Room_indexes[2], 1); aPortalRenderSet(1, 0, Room_indexes[2], 1); - aShowHUDMessage(Message_strings[20]); + aShowHUDMessage(TXT("ManuverIntro")); aTogglePlayerControl(1, 0, 768); aSetLevelTimer(20.000000f, 4); aSoundPlaySteamingText("intro3.osf", 1.000000f); - aShowHUDMessage(Message_strings[21]); + aShowHUDMessage(TXT("HeadingIntro")); // Increment the script action counter if (ScriptActionCtr_021 < MAX_ACTION_CTR_VALUE) @@ -2018,10 +1793,10 @@ int16_t CustomObjectScript_2008::CallEvent(int event, tOSIRISEventInfo *data) { if (((ScriptActionCtr_025 > 0) == true) && (event_data->id == 7)) { aTogglePlayerControl(1, 0, 12288); aAIGoalFollowPathSimple(Object_handles[13], Path_indexes[1], 4352, 0, 3); - aShowHUDMessage(Message_strings[0]); - aShowHUDMessage(Message_strings[23]); + aShowHUDMessage(TXT("GoodJob")); + aShowHUDMessage(TXT("WeaponsEnabled")); aSoundPlaySteamingText("intro4.osf", 1.000000f); - aShowHUDMessage(Message_strings[24]); + aShowHUDMessage(TXT("DestroyFollowbot")); // Increment the script action counter if (ScriptActionCtr_026 < MAX_ACTION_CTR_VALUE) @@ -2091,7 +1866,7 @@ int16_t CustomObjectScript_1817::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlaySteamingText("GuideBotC.osf", 1.000000f); aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); aAddObjectToInventory(Object_handles[22], event_data->it_handle, 0); - aShowHUDMessage(Message_strings[28]); + aShowHUDMessage(TXT("UseCameraMonitor")); // Increment the script action counter if (ScriptActionCtr_040 < MAX_ACTION_CTR_VALUE) @@ -2104,7 +1879,7 @@ int16_t CustomObjectScript_1817::CallEvent(int event, tOSIRISEventInfo *data) { // Script 059: Player used camera monitor if (1) { aSoundPlaySteamingText("GuideBotD.osf", 1.000000f); - aShowHUDMessage(Message_strings[34]); + aShowHUDMessage(TXT("GBExtra")); aCreatePopupView(0, Object_handles[34], 10.000000f, 1.000000f); // Increment the script action counter @@ -2368,8 +2143,8 @@ int16_t TriggerScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aObjSetLightingDist(Object_handles[1], 0.000000f); aPortalRenderSet(1, 1, Room_indexes[3], 1); aPortalRenderSet(1, 0, Room_indexes[3], 1); - aShowHUDMessage(Message_strings[0]); - aShowHUDMessage(Message_strings[27]); + aShowHUDMessage(TXT("GoodJob")); + aShowHUDMessage(TXT("GBIntro")); aToggleAllPlayerControls(0, 0); // Increment the script action counter @@ -2390,7 +2165,7 @@ int16_t TriggerScript_0001::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_042 < 1) && (1)) { aSetLevelTimer(13.000000f, 14); aObjSetLightingDist(Object_handles[2], 0.000000f); - aShowHUDMessage(Message_strings[29]); + aShowHUDMessage(TXT("KillBotIntro")); aSoundPlaySteamingText("intro6.osf", 1.000000f); aPortalRenderSet(1, 1, Room_indexes[4], 1); aPortalRenderSet(1, 0, Room_indexes[4], 1); @@ -2412,11 +2187,11 @@ int16_t TriggerScript_0002::CallEvent(int event, tOSIRISEventInfo *data) { // Script 050: Entered Last Room if ((ScriptActionCtr_050 < 1) && (1)) { aObjSetLightingDist(Object_handles[3], 0.000000f); - aShowHUDMessage(Message_strings[0]); + aShowHUDMessage(TXT("GoodJob")); aPortalRenderSet(1, 1, Room_indexes[5], 1); aPortalRenderSet(1, 0, Room_indexes[5], 1); aSoundPlaySteamingText("intro7.osf", 1.000000f); - aShowHUDMessage(Message_strings[32]); + aShowHUDMessage(TXT("FinalSessionIntro")); // Increment the script action counter if (ScriptActionCtr_050 < MAX_ACTION_CTR_VALUE) diff --git a/scripts/TrainingMission_Ger.msg b/scripts/TrainingMission_GER.msg similarity index 100% rename from scripts/TrainingMission_Ger.msg rename to scripts/TrainingMission_GER.msg diff --git a/scripts/Y2K.cpp b/scripts/Y2K.cpp index 38c1fee4f..2c35bbcfe 100644 --- a/scripts/Y2K.cpp +++ b/scripts/Y2K.cpp @@ -22,10 +22,10 @@ // Filename: BathroomJungle.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -114,185 +114,6 @@ void RestoreGlobalActionCtrs(void *file_ptr) { // End of Custom Script Block - DO NOT EDIT ANYTHING AFTER THIS // ============================================================ -// ================= -// Message File Data -// ================= - -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - -// Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} - -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} - //====================== // Name List Arrays //====================== @@ -335,9 +156,12 @@ int *Matcen_indexes = NULL; const char **Goal_names = NULL; int *Goal_indexes = NULL; -#define NUM_MESSAGE_NAMES 0 -const char **Message_names = NULL; -const char **Message_strings = NULL; +// Global storage for level script messages +std::map Messages; + +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) // =============== // InitializeDLL() @@ -352,37 +176,19 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - char english_filename[(_MAX_PATH + 32) * 2]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - snprintf(english_filename, sizeof(english_filename), "%s.msg", filename); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); - else if (lang_type == LANGUAGE_POLISH) - strcat(filename, "_POL"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "BathroomJungle.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { - if (lang_type == LANGUAGE_ENGLISH) { - mprintf(0, "ERROR: Could not load message file - %s\n", filename); - } else if (!ReadMessageFile(english_filename)) { - mprintf(0, "ERROR: Could not load message file - %s\n", english_filename); - } + mprintf(0, "ERROR: Could not load message file - %s\n", filename); } int j; @@ -426,10 +232,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } diff --git a/scripts/aigame2.cpp b/scripts/aigame2.cpp index e5008b73b..46d13597f 100644 --- a/scripts/aigame2.cpp +++ b/scripts/aigame2.cpp @@ -18,9 +18,12 @@ // aigame2.cpp // 0.1 -#include -#include -#include +#include +#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "osiris_vector.h" @@ -42,16 +45,15 @@ DLLEXPORT int STDCALL SaveRestoreState(void *file_ptr, uint8_t saving_state); } #endif -static int String_table_size = 0; -static char **String_table = NULL; +static std::vector String_table; static const char *_Error_string = "!!ERROR MISSING STRING!!"; static const char *_Empty_string = ""; -const char *GetStringFromTable(int index) { - if ((index < 0) || (index >= String_table_size)) +const char *GetStringFromTable(uint32_t index) { + if (index >= String_table.size()) return _Error_string; - if (!String_table[index]) + if (String_table[index].empty()) return _Empty_string; - return String_table[index]; + return String_table[index].c_str(); } #define TXT(x) GetStringFromTable(x) @@ -259,7 +261,6 @@ class aiSTBlackBarrel : public aiObjScript { // Returns 1 if initialization went ok, 0 if there was an error and the DLL should not be loaded. char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { osicommon_Initialize((tOSIRISModuleInit *)func_list); - String_table_size = func_list->string_count; String_table = func_list->string_table; if (func_list->game_checksum != CHECKSUM) { mprintf(0, "Game-Checksum FAIL!!! (%ul!=%ul)\n", func_list->game_checksum, CHECKSUM); diff --git a/scripts/aigame4.cpp b/scripts/aigame4.cpp index 977d9dffd..9528666e5 100644 --- a/scripts/aigame4.cpp +++ b/scripts/aigame4.cpp @@ -18,9 +18,11 @@ // AIGame.cpp // -#include -#include -#include +#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "osiris_vector.h" @@ -42,16 +44,15 @@ DLLEXPORT int STDCALL SaveRestoreState(void *file_ptr, uint8_t saving_state); } #endif -int String_table_size = 0; -char **String_table = NULL; +std::vector String_table; static const char *_Error_string = "!!ERROR MISSING STRING!!"; static const char *_Empty_string = ""; -const char *GetStringFromTable(int index) { - if ((index < 0) || (index >= String_table_size)) +const char *GetStringFromTable(uint32_t index) { + if (index >= String_table.size()) return _Error_string; - if (!String_table[index]) + if (String_table[index].empty()) return _Empty_string; - return String_table[index]; + return String_table[index].c_str(); } #define TXT(x) GetStringFromTable(x) @@ -301,7 +302,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { return 0; } aigame_mod_id = func_list->module_identifier; - String_table_size = func_list->string_count; String_table = func_list->string_table; return 1; diff --git a/scripts/barney.cpp b/scripts/barney.cpp index f55a39703..1bcf7ee23 100644 --- a/scripts/barney.cpp +++ b/scripts/barney.cpp @@ -22,10 +22,10 @@ // Filename: barney.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -102,185 +102,6 @@ void RestoreGlobalActionCtrs(void *file_ptr) {} // End of Custom Script Block - DO NOT EDIT ANYTHING AFTER THIS // ============================================================ -// ================= -// Message File Data -// ================= - -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - -// Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} - -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} - //====================== // Name List Arrays //====================== @@ -323,9 +144,12 @@ int *Matcen_indexes = NULL; const char **Goal_names = NULL; int *Goal_indexes = NULL; -#define NUM_MESSAGE_NAMES 0 -const char **Message_names = NULL; -const char **Message_strings = NULL; +// Global storage for level script messages +std::map Messages; + +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) // =============== // InitializeDLL() @@ -340,7 +164,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); ReadMessageFile("barney.msg"); int j; @@ -384,10 +207,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } diff --git a/scripts/clutter.cpp b/scripts/clutter.cpp index bdf516b3a..52d0540a0 100644 --- a/scripts/clutter.cpp +++ b/scripts/clutter.cpp @@ -18,9 +18,11 @@ // clutter.cpp // 0.1 -#include -#include -#include +#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "osiris_vector.h" @@ -41,16 +43,15 @@ DLLEXPORT int STDCALL SaveRestoreState(void *file_ptr, uint8_t saving_state); } #endif -static int String_table_size = 0; -static char **String_table = NULL; +static std::vector String_table; static const char *_Error_string = "!!ERROR MISSING STRING!!"; static const char *_Empty_string = ""; -static const char *GetStringFromTable(int index) { - if ((index < 0) || (index >= String_table_size)) +static const char *GetStringFromTable(uint32_t index) { + if (index >= String_table.size()) return _Error_string; - if (!String_table[index]) + if (String_table[index].empty()) return _Empty_string; - return String_table[index]; + return String_table[index].c_str(); } #define TXT(x) GetStringFromTable(x) @@ -141,7 +142,6 @@ class LavaRock : public ClutterScript { // Returns 1 if initialization went ok, 0 if there was an error and the DLL should not be loaded. char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { osicommon_Initialize((tOSIRISModuleInit *)func_list); - String_table_size = func_list->string_count; String_table = func_list->string_table; if (func_list->game_checksum != CHECKSUM) { mprintf(0, "Game-Checksum FAIL!!! (%ul!=%ul)\n", func_list->game_checksum, CHECKSUM); diff --git a/scripts/generic.cpp b/scripts/generic.cpp index 291621a0c..30e012093 100644 --- a/scripts/generic.cpp +++ b/scripts/generic.cpp @@ -19,9 +19,11 @@ // generic.cpp // 0.1 #include -#include #include #include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" @@ -41,16 +43,15 @@ DLLEXPORT int STDCALL SaveRestoreState(void *file_ptr, uint8_t saving_state); } #endif -int String_table_size = 0; -char **String_table = NULL; +std::vector String_table; static const char *_Error_string = "!!ERROR MISSING STRING!!"; static const char *_Empty_string = ""; -const char *GetStringFromTable(int index) { - if ((index < 0) || (index >= String_table_size)) +const char *GetStringFromTable(uint32_t index) { + if (index >= String_table.size()) return _Error_string; - if (!String_table[index]) + if (String_table[index].empty()) return _Empty_string; - return String_table[index]; + return String_table[index].c_str(); } #define TXT(x) GetStringFromTable(x) #define TXT_DOORLOCKED TXT(0) //"Door Locked!" @@ -150,14 +151,11 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { return 0; } - String_table_size = func_list->string_count; String_table = func_list->string_table; - int i; - // initialize rapid fire script data - for (i = 0; i < MAX_PLAYERS; i++) { - RapidFirePlayerTimers[i].timer_handle = -1; + for (auto & RapidFirePlayerTimer : RapidFirePlayerTimers) { + RapidFirePlayerTimer.timer_handle = -1; } return 1; diff --git a/scripts/level1.cpp b/scripts/level1.cpp index 6e03591a5..4fa362726 100644 --- a/scripts/level1.cpp +++ b/scripts/level1.cpp @@ -22,10 +22,10 @@ // Filename: Level1.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -413,180 +413,12 @@ void RestoreGlobalActionCtrs(void *file_ptr) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} +std::map Messages; -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -657,32 +489,6 @@ const char *Goal_names[NUM_GOAL_NAMES] = {"Deactivate the Containment Forcefield "Find the Main Data Retention Complex"}; int Goal_indexes[NUM_GOAL_NAMES]; -#define NUM_MESSAGE_NAMES 23 -const char *Message_names[NUM_MESSAGE_NAMES] = {"FirstForcefield", - "ClassifiedAccessPass", - "LeftConsoleSwitch", - "RightConsoleSwitch", - "PrimaryLoginSwitch", - "EndLevel", - "AccessDenied", - "CEDData", - "ShipMessageLog", - "BossData", - "PTMCdisconnected", - "DravisData", - "SRADLabData", - "ConsoleCrash", - "SweitzerData", - "SecurityAlert", - "LockDown", - "MDData", - "EmergencySwitchOpen", - "EmergencySwitch", - "SingleFireSwitch", - "BothFireSwitches", - "IntroMessage"}; -const char *Message_strings[NUM_MESSAGE_NAMES]; - // =============== // InitializeDLL() // =============== @@ -696,7 +502,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; @@ -704,14 +509,7 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { if (func_list->script_identifier != NULL) { _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "Level1.msg"); @@ -762,10 +560,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } @@ -1156,7 +950,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 029: IntroCam if (1) { - aCinematicIntro(Path_indexes[2], Message_strings[22], Object_handles[1], Path_indexes[3], 12.000000f); + aCinematicIntro(Path_indexes[2], TXT("IntroMessage"), Object_handles[1], Path_indexes[3], 12.000000f); aSetLevelTimer(15.000000f, 11); // Increment the script action counter @@ -1242,19 +1036,19 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 015: Left Console Level Timers if (1) { if (event_data->id == 4) { - aAddGameMessage(Message_strings[7], Message_strings[8]); + aAddGameMessage(TXT("CEDData"), TXT("ShipMessageLog")); aRoomSetFaceTexture(Room_indexes[1], 148, Texture_indexes[1]); aObjPlayAnim(Object_handles[14], 7, 15, 3.000000f, 0); aSetLevelTimer(6.000000f, 8); } if (event_data->id == 8) { - aAddGameMessage(Message_strings[9], Message_strings[8]); + aAddGameMessage(TXT("BossData"), TXT("ShipMessageLog")); aRoomSetFaceTexture(Room_indexes[1], 148, Texture_indexes[2]); aObjPlayAnim(Object_handles[14], 15, 22, 4.000000f, 0); aSetLevelTimer(4.000000f, 9); } if (event_data->id == 9) { - aShowHUDMessage(Message_strings[10]); + aShowHUDMessage(TXT("PTMCdisconnected")); aRoomSetFaceTexture(Room_indexes[1], 148, Texture_indexes[3]); } @@ -1266,19 +1060,19 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 014: Right Console Level Timers if (1) { if (event_data->id == 3) { - aAddGameMessage(Message_strings[11], Message_strings[8]); + aAddGameMessage(TXT("DravisData"), TXT("ShipMessageLog")); aRoomSetFaceTexture(Room_indexes[2], 148, Texture_indexes[4]); aObjPlayAnim(Object_handles[16], 7, 15, 3.000000f, 0); aSetLevelTimer(6.000000f, 5); } if (event_data->id == 5) { - aAddGameMessage(Message_strings[12], Message_strings[8]); + aAddGameMessage(TXT("SRADLabData"), TXT("ShipMessageLog")); aRoomSetFaceTexture(Room_indexes[2], 148, Texture_indexes[5]); aObjPlayAnim(Object_handles[16], 15, 22, 4.000000f, 0); aSetLevelTimer(4.000000f, 6); } if (event_data->id == 6) { - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("ConsoleCrash")); aRoomSetFaceTexture(Room_indexes[2], 148, Texture_indexes[6]); } @@ -1290,19 +1084,19 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 007: Primary Console Timers if (1) { if (event_data->id == 0) { - aAddGameMessage(Message_strings[14], Message_strings[8]); + aAddGameMessage(TXT("SweitzerData"), TXT("ShipMessageLog")); aRoomSetFaceTexture(Room_indexes[6], 148, Texture_indexes[7]); aObjPlayAnim(Object_handles[18], 7, 15, 3.000000f, 0); aSetLevelTimer(6.000000f, 1); } if (event_data->id == 7) { - aShowHUDMessage(Message_strings[15]); + aShowHUDMessage(TXT("SecurityAlert")); aRoomSetFaceTexture(Room_indexes[6], 148, Texture_indexes[8]); aObjPlayAnim(Object_handles[18], 15, 22, 4.000000f, 0); aSetLevelTimer(4.000000f, 2); } if (event_data->id == 2) { - aShowHUDMessage(Message_strings[16]); + aShowHUDMessage(TXT("LockDown")); aRoomSetFaceTexture(Room_indexes[6], 148, Texture_indexes[9]); aMatcenSetEnableState(1, Matcen_indexes[0]); aMatcenSetState(1, Matcen_indexes[0]); @@ -1311,7 +1105,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aObjPlayAnim(Object_handles[18], 0, 7, 3.000000f, 0); aSetLevelTimer(6.000000f, 7); aRoomSetFaceTexture(Room_indexes[6], 148, Texture_indexes[10]); - aAddGameMessage(Message_strings[17], Message_strings[8]); + aAddGameMessage(TXT("MDData"), TXT("ShipMessageLog")); } // Increment the script action counter @@ -1343,7 +1137,7 @@ int16_t CustomObjectScript_3855::CallEvent(int event, tOSIRISEventInfo *data) { aGoalCompleted(Goal_indexes[0], 1); aObjPlayAnim(Object_handles[0], 0, 4, 2.000000f, 0); aPortalRenderSet(0, 1, Room_indexes[0], 1); - aShowHUDMessage(Message_strings[0]); + aShowHUDMessage(TXT("FirstForcefield")); aUserFlagSet(0, 0); } else { } @@ -1365,7 +1159,7 @@ int16_t CustomObjectScript_10DC::CallEvent(int event, tOSIRISEventInfo *data) { // Script 003: Restricted Access Passkey if (qObjIsPlayer(event_data->it_handle) == true) { aGoalCompleted(Goal_indexes[1], 1); - aObjectPlayerGiveKey(event_data->it_handle, Object_handles[12], 1, Message_strings[1], 1); + aObjectPlayerGiveKey(event_data->it_handle, Object_handles[12], 1, TXT("ClassifiedAccessPass"), 1); // Increment the script action counter if (ScriptActionCtr_003 < MAX_ACTION_CTR_VALUE) @@ -1387,7 +1181,7 @@ int16_t CustomObjectScript_10E0::CallEvent(int event, tOSIRISEventInfo *data) { aUserFlagSet(5, 1); aObjPlayAnim(Object_handles[13], 0, 7, 4.000000f, 0); aRoomSetFaceTexture(Room_indexes[1], 148, Texture_indexes[0]); - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("LeftConsoleSwitch")); aObjPlayAnim(Object_handles[14], 0, 7, 3.000000f, 0); aSetLevelTimer(6.000000f, 4); } else { @@ -1413,7 +1207,7 @@ int16_t CustomObjectScript_10DF::CallEvent(int event, tOSIRISEventInfo *data) { aUserFlagSet(4, 1); aObjPlayAnim(Object_handles[15], 0, 7, 4.000000f, 0); aRoomSetFaceTexture(Room_indexes[2], 148, Texture_indexes[0]); - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("RightConsoleSwitch")); aObjPlayAnim(Object_handles[16], 0, 7, 3.000000f, 0); aSetLevelTimer(6.000000f, 3); } else { @@ -1446,7 +1240,7 @@ int16_t CustomObjectScript_08E8::CallEvent(int event, tOSIRISEventInfo *data) { aUserFlagSet(1, 1); aObjPlayAnim(Object_handles[17], 0, 7, 4.000000f, 0); aRoomSetFaceTexture(Room_indexes[6], 148, Texture_indexes[0]); - aShowHUDMessage(Message_strings[4]); + aShowHUDMessage(TXT("PrimaryLoginSwitch")); aObjPlayAnim(Object_handles[18], 0, 7, 3.000000f, 0); aSetLevelTimer(6.000000f, 0); aObjSetLightingDist(Object_handles[19], 70.000000f); @@ -1518,7 +1312,7 @@ int16_t CustomObjectScript_584D::CallEvent(int event, tOSIRISEventInfo *data) { ((qObjIsPlayer(event_data->it_handle) == true) && ((ScriptActionCtr_005 > 0) == false))) { aGoalCompleted(Goal_indexes[4], 1); aObjDestroy(Object_handles[37]); - aStartEndlevelSequencePath(Path_indexes[0], Path_indexes[1], 10.000000f, Message_strings[5]); + aStartEndlevelSequencePath(Path_indexes[0], Path_indexes[1], 10.000000f, TXT("EndLevel")); // Increment the script action counter if (ScriptActionCtr_031 < MAX_ACTION_CTR_VALUE) @@ -1537,7 +1331,7 @@ int16_t CustomObjectScript_0816::CallEvent(int event, tOSIRISEventInfo *data) { // Script 006: Restricted Access Door Locked if (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) { if ((ScriptActionCtr_003 > 0) == false) { - aShowHUDMessageI(Message_strings[6], 0); + aShowHUDMessageI(TXT("AccessDenied"), 0); } // Increment the script action counter @@ -1569,9 +1363,9 @@ int16_t CustomObjectScript_100D::CallEvent(int event, tOSIRISEventInfo *data) { aUserFlagSet(6, 0); aDoorLockUnlock(0, Door_handles[2]); aDoorActivate(Door_handles[2]); - aShowHUDMessage(Message_strings[18]); + aShowHUDMessage(TXT("EmergencySwitchOpen")); } else { - aShowHUDMessage(Message_strings[19]); + aShowHUDMessage(TXT("EmergencySwitch")); } // Increment the script action counter @@ -1593,7 +1387,7 @@ int16_t CustomObjectScript_301B::CallEvent(int event, tOSIRISEventInfo *data) { if (qUserFlag(3) == false) { aObjPlayAnim(Object_handles[40], 0, 4, 2.000000f, 0); aUserFlagSet(3, 1); - aShowHUDMessage(Message_strings[20]); + aShowHUDMessage(TXT("SingleFireSwitch")); } if ((qUserFlag(2) == true) && (qUserFlag(3) == true)) { aTurnOffSpew(6); @@ -1606,7 +1400,7 @@ int16_t CustomObjectScript_301B::CallEvent(int event, tOSIRISEventInfo *data) { aTurnOffSpew(13); aRoomChangeFog(Room_indexes[7], 1.000000f, 0.700000f, 0.400000f, 6000.000000f, 20.000000f); aRoomChangeFog(Room_indexes[8], 1.000000f, 0.700000f, 0.400000f, 6000.000000f, 20.000000f); - aShowHUDMessage(Message_strings[21]); + aShowHUDMessage(TXT("BothFireSwitches")); aDoorLockUnlock(0, Door_handles[2]); aDoorActivate(Door_handles[2]); aUserFlagSet(6, 0); @@ -1632,7 +1426,7 @@ int16_t CustomObjectScript_18DB::CallEvent(int event, tOSIRISEventInfo *data) { if (qUserFlag(2) == false) { aObjPlayAnim(Object_handles[41], 0, 4, 2.000000f, 0); aUserFlagSet(2, 1); - aShowHUDMessage(Message_strings[20]); + aShowHUDMessage(TXT("SingleFireSwitch")); } if ((qUserFlag(2) == true) && (qUserFlag(3) == true)) { aTurnOffSpew(6); @@ -1645,7 +1439,7 @@ int16_t CustomObjectScript_18DB::CallEvent(int event, tOSIRISEventInfo *data) { aTurnOffSpew(13); aRoomChangeFog(Room_indexes[7], 1.000000f, 0.700000f, 0.400000f, 6000.000000f, 20.000000f); aRoomChangeFog(Room_indexes[8], 1.000000f, 0.700000f, 0.400000f, 6000.000000f, 20.000000f); - aShowHUDMessage(Message_strings[21]); + aShowHUDMessage(TXT("BothFireSwitches")); aDoorLockUnlock(0, Door_handles[2]); aDoorActivate(Door_handles[2]); aUserFlagSet(6, 0); @@ -1671,7 +1465,7 @@ int16_t TriggerScript_000C::CallEvent(int event, tOSIRISEventInfo *data) { ((qObjIsPlayer(event_data->it_handle) == true) && ((ScriptActionCtr_031 > 0) == false))) { aGoalCompleted(Goal_indexes[4], 1); aObjDestroy(Object_handles[37]); - aStartEndlevelSequencePath(Path_indexes[0], Path_indexes[1], 10.000000f, Message_strings[5]); + aStartEndlevelSequencePath(Path_indexes[0], Path_indexes[1], 10.000000f, TXT("EndLevel")); // Increment the script action counter if (ScriptActionCtr_005 < MAX_ACTION_CTR_VALUE) diff --git a/scripts/level10.cpp b/scripts/level10.cpp index cbd2d875f..0df3ecc25 100644 --- a/scripts/level10.cpp +++ b/scripts/level10.cpp @@ -22,10 +22,10 @@ // Filename: Level10.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -1246,180 +1246,12 @@ void aUpdateBaseAlertDisplay(const char *text, int level) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} +std::map Messages; -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -1603,74 +1435,6 @@ const char *Goal_names[NUM_GOAL_NAMES] = { "Upload Virus Information"}; int Goal_indexes[NUM_GOAL_NAMES]; -#define NUM_MESSAGE_NAMES 65 -const char *Message_names[NUM_MESSAGE_NAMES] = {"Empty", - "IntroText", - "ZMegaTrap", - "ZDVSpotted", - "ZDVAlerted", - "ZTurretHit", - "CannonHitPlayer", - "JuggSawPlayer", - "JuggAlertedBase", - "JuggAlertWarning", - "ZCanyonRun", - "ZCanyonAmbush", - "ZCBNoticed", - "ZCBAlerted", - "D1GuardSpotted", - "HangerGuardSpotted", - "GuardTowerAlertedHG", - "GuardTowerAlertedGG", - "BaseAlertStatus", - "BaseAlertDisplay", - "VaultKeyAcquired", - "InterfaceAcquired", - "HangerDoorUnlocked", - "HangerMsgGame", - "HangerMsgHUD", - "MemPlasmaGame", - "MemPlasmaHUD", - "UplinkControlGame", - "UplinkControlHUD", - "UplinkCenterGame", - "UplinkCenterHUD", - "InterfacePrepInstrGame", - "InterfacePrepInstHUD", - "InterfaceInitialized", - "InitInterfaceCin", - "InterfacePrepDenied", - "UplinkPlasmaOff", - "UplinkPlasmaOn", - "MemPlasmaOff", - "MemPlasmaOn", - "NanoPlasmaDefOff", - "NanoPlasmaDefOn", - "MatcenActivated", - "MatcenDeactivated", - "InterfacePowerOff", - "InterfacePowerOn", - "DataUplinkActivated", - "InterfaceHasNoPower", - "UplinkDocking", - "UplinkErrorNoChg", - "UplinkErrorNoPlasma", - "UplinkErrorNotAct", - "UplinkErrorNoInit", - "UplinkErrorNoInt", - "UplinkErrorNano", - "MemPlasmaObtained", - "MemPlasmaLost", - "UploadingVirus", - "ZCamSpotted", - "ZGotCamMonitor", - "ZCamMonitorOff", - "ZCamMonitorOn", - "CrashedShipGame", - "CrashedShipHud", - "NoEntry"}; -const char *Message_strings[NUM_MESSAGE_NAMES]; - // =============== // InitializeDLL() // =============== @@ -1684,26 +1448,16 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "Level10.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { mprintf(0, "ERROR: Could not load message file - %s\n", filename); @@ -1750,10 +1504,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } @@ -2726,7 +2476,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aComplexCinematicTrack(Object_handles[40], 0.000000f, 1.000000f); aComplexCinematicStartTrans(1); aComplexCinematicCameraOnPath(Path_indexes[0]); - aComplexCinematicEnd(Message_strings[0], 9.500000f); + aComplexCinematicEnd(TXT("Empty"), 9.500000f); // Increment the script action counter if (ScriptActionCtr_039 < MAX_ACTION_CTR_VALUE) @@ -2748,7 +2498,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 121: Show Data Vault Guard Spotted Msg if ((ScriptActionCtr_121 < 1) && ((event_data->id == 21) && (qObjShields(Object_handles[46]) > 0.000000f) && ((ScriptActionCtr_094 > 0) == false))) { - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("ZDVSpotted")); // Increment the script action counter if (ScriptActionCtr_121 < MAX_ACTION_CTR_VALUE) @@ -2759,7 +2509,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { if (event_data->id == 15) { if (qObjCanSeePlayerAdvancedWithStore(3, 45, Object_handles[49], 500.000000f, 1048585) == true) { if (qObjShields(qObjSavedHandle(3)) > 0.000000f) { - aShowHUDMessage(Message_strings[6]); + aShowHUDMessage(TXT("CannonHitPlayer")); aStoreObjectInPositionClipboard(qObjSavedHandle(3)); aMoveObjectToPositionClipboard(Object_handles[50]); aObjApplyDamage(qObjSavedHandle(3), 80.000000f); @@ -2782,7 +2532,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 122: Show Jugg Guard Spotted Msg if ((ScriptActionCtr_122 < 1) && ((event_data->id == 22) && (qObjShields(Object_handles[51]) > 0.000000f) && ((ScriptActionCtr_019 > 0) == false))) { - aShowHUDMessage(Message_strings[7]); + aShowHUDMessage(TXT("JuggSawPlayer")); aSetLevelTimer(4.000000f, 3); // Increment the script action counter @@ -2792,7 +2542,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 020: Show Juggernaut Alert Warning if (event_data->id == 3) { - aShowHUDMessage(Message_strings[9]); + aShowHUDMessage(TXT("JuggAlertWarning")); // Increment the script action counter if (ScriptActionCtr_020 < MAX_ACTION_CTR_VALUE) @@ -2802,7 +2552,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 123: Show Canyon Guard Spotted Msg if ((ScriptActionCtr_123 < 1) && ((event_data->id == 19) && (qObjShields(Object_handles[54]) > 0.000000f) && ((ScriptActionCtr_087 > 0) == false))) { - aShowHUDMessage(Message_strings[10]); + aShowHUDMessage(TXT("ZCanyonRun")); // Increment the script action counter if (ScriptActionCtr_123 < MAX_ACTION_CTR_VALUE) @@ -2812,7 +2562,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 124: Show Command Base Guard Spotted Msg if ((ScriptActionCtr_124 < 1) && ((event_data->id == 20) && (qObjShields(Object_handles[55]) > 0.000000f) && ((ScriptActionCtr_089 > 0) == false))) { - aShowHUDMessage(Message_strings[12]); + aShowHUDMessage(TXT("ZCBNoticed")); // Increment the script action counter if (ScriptActionCtr_124 < MAX_ACTION_CTR_VALUE) @@ -2822,7 +2572,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 073: Show D1 Ground Guard Spotted Msg if ((ScriptActionCtr_073 < 1) && ((event_data->id == 12) && (qObjShields(Object_handles[62]) > 0.000000f) && ((ScriptActionCtr_035 > 0) == false))) { - aShowHUDMessage(Message_strings[14]); + aShowHUDMessage(TXT("D1GuardSpotted")); // Increment the script action counter if (ScriptActionCtr_073 < MAX_ACTION_CTR_VALUE) @@ -2832,7 +2582,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 120: Show Hanger Guard Spotted Msg if ((ScriptActionCtr_120 < 1) && ((event_data->id == 18) && (qObjShields(Object_handles[64]) > 0.000000f) && ((ScriptActionCtr_034 > 0) == false))) { - aShowHUDMessage(Message_strings[15]); + aShowHUDMessage(TXT("HangerGuardSpotted")); // Increment the script action counter if (ScriptActionCtr_120 < MAX_ACTION_CTR_VALUE) @@ -2953,9 +2703,9 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aMatcenSetState(1, Matcen_indexes[17]); aMatcenSetState(1, Matcen_indexes[18]); } - aShowHUDMessageI(Message_strings[18], qMathAddInt(ScriptActionCtr_045, 1)); + aShowHUDMessageI(TXT("BaseAlertStatus"), qMathAddInt(ScriptActionCtr_045, 1)); aSoundPlay2D(Sound_indexes[1], 1.000000f); - aUpdateBaseAlertDisplay(Message_strings[19], qMathAddInt(ScriptActionCtr_045, 1)); + aUpdateBaseAlertDisplay(TXT("BaseAlertDisplay"), qMathAddInt(ScriptActionCtr_045, 1)); // Increment the script action counter if (ScriptActionCtr_045 < MAX_ACTION_CTR_VALUE) @@ -3075,7 +2825,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { if ((event_data->id == 2) && (qUserFlag(9) == false)) { aUserVarDec(0); if (qUserVarValue(0) <= 0.000000f) { - aShowHUDMessage(Message_strings[56]); + aShowHUDMessage(TXT("MemPlasmaLost")); aSoundPlayObject(Sound_indexes[7], qObjSavedHandle(2), 1.000000f); aUserFlagSet(1, 0); aUserVarSet(0, 0.000000f); @@ -3149,7 +2899,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { if (event_data->id == 1) { aGoalCompleted(Goal_indexes[12], 1); aSetLevelTimer(1.000000f, 11); - aStartEndlevelSequencePath(Path_indexes[25], Path_indexes[26], 15.000000f, Message_strings[57]); + aStartEndlevelSequencePath(Path_indexes[25], Path_indexes[26], 15.000000f, TXT("UploadingVirus")); aSoundPlaySteaming("VoxLev10EndLevel.osf", 1.000000f); // Increment the script action counter @@ -3345,10 +3095,10 @@ int16_t CustomObjectScript_2042::CallEvent(int event, tOSIRISEventInfo *data) { aComplexCinematicTrack(Object_handles[40], 0.000000f, 1.000000f); aComplexCinematicStartTrans(1); aComplexCinematicCameraOnPath(Path_indexes[1]); - aComplexCinematicEnd(Message_strings[0], 9.000000f); + aComplexCinematicEnd(TXT("Empty"), 9.000000f); } if (ScriptActionCtr_040 == 1) { - aCinematicIntro(Path_indexes[2], Message_strings[1], data->me_handle, Path_indexes[3], 12.000000f); + aCinematicIntro(Path_indexes[2], TXT("IntroText"), data->me_handle, Path_indexes[3], 12.000000f); aSoundPlaySteaming("VoxLev10StartLevel.osf", 1.000000f); } @@ -3406,7 +3156,7 @@ int16_t CustomObjectScript_0945::CallEvent(int event, tOSIRISEventInfo *data) { // Script 096: Mega Trap Setoff if ((ScriptActionCtr_096 < 1) && (qObjIsPlayer(event_data->it_handle) == true)) { - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("ZMegaTrap")); aSoundPlay2D(Sound_indexes[0], 1.000000f); aObjGhostSet(0, Object_handles[17]); aAISetState(1, Object_handles[17]); @@ -3497,7 +3247,7 @@ int16_t CustomObjectScript_2140::CallEvent(int event, tOSIRISEventInfo *data) { // Script 094: Data Vault Alerted if ((ScriptActionCtr_094 < 1) && (event_data->goal_uid == 13)) { - aShowHUDMessage(Message_strings[4]); + aShowHUDMessage(TXT("ZDVAlerted")); aSoundPlay2D(Sound_indexes[1], 1.000000f); aObjPlayAnim(Object_handles[47], 0, 25, 3.000000f, 0); aSoundPlayObject(Sound_indexes[2], Object_handles[47], 1.000000f); @@ -3528,7 +3278,7 @@ int16_t CustomObjectScript_0875::CallEvent(int event, tOSIRISEventInfo *data) { // Script 143: Data Vault Turret 1 Hit by Player if ((ScriptActionCtr_143 < 1) && ((qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) && (qUserFlag(28) == false))) { - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ZTurretHit")); aAISetState(1, Object_handles[1]); aAISetState(1, Object_handles[2]); aAISetState(1, Object_handles[3]); @@ -3552,7 +3302,7 @@ int16_t CustomObjectScript_0877::CallEvent(int event, tOSIRISEventInfo *data) { // Script 144: Data Vault Turret 2 Hit by Player if ((ScriptActionCtr_144 < 1) && ((qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) && (qUserFlag(28) == false))) { - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ZTurretHit")); aAISetState(1, Object_handles[1]); aAISetState(1, Object_handles[2]); aAISetState(1, Object_handles[3]); @@ -3576,7 +3326,7 @@ int16_t CustomObjectScript_105C::CallEvent(int event, tOSIRISEventInfo *data) { // Script 145: Data Vault Turret 3 Hit by Player if ((ScriptActionCtr_145 < 1) && ((qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) && (qUserFlag(28) == false))) { - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ZTurretHit")); aAISetState(1, Object_handles[1]); aAISetState(1, Object_handles[2]); aAISetState(1, Object_handles[3]); @@ -3600,7 +3350,7 @@ int16_t CustomObjectScript_0878::CallEvent(int event, tOSIRISEventInfo *data) { // Script 146: Data Vault Turret 4 Hit by Player if ((ScriptActionCtr_146 < 1) && ((qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) && (qUserFlag(28) == false))) { - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ZTurretHit")); aAISetState(1, Object_handles[1]); aAISetState(1, Object_handles[2]); aAISetState(1, Object_handles[3]); @@ -3636,7 +3386,7 @@ int16_t CustomObjectScript_28BA::CallEvent(int event, tOSIRISEventInfo *data) { // Script 019: Jugg Has Alerted the Base if ((ScriptActionCtr_019 < 1) && (event_data->goal_uid == 0)) { - aShowHUDMessage(Message_strings[8]); + aShowHUDMessage(TXT("JuggAlertedBase")); aSoundPlay2D(Sound_indexes[1], 1.000000f); aObjPlayAnim(Object_handles[52], 0, 25, 3.000000f, 0); aSoundPlayObject(Sound_indexes[2], Object_handles[52], 1.000000f); @@ -3692,7 +3442,7 @@ int16_t CustomObjectScript_2133::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_087 < 1) && (event_data->goal_uid == 11)) { aObjSaveHandle(qPlayerClosest(data->me_handle, 1), 4); if (qUserVarValue(1) < 500.000000f) { - aShowHUDMessage(Message_strings[11]); + aShowHUDMessage(TXT("ZCanyonAmbush")); aSoundPlay2D(Sound_indexes[0], 1.000000f); } aAISetMaxSpeed(data->me_handle, 50.000000f); @@ -3750,7 +3500,7 @@ int16_t CustomObjectScript_1139::CallEvent(int event, tOSIRISEventInfo *data) { // Script 089: Command Base Alerted if ((ScriptActionCtr_089 < 1) && (event_data->goal_uid == 12)) { - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("ZCBAlerted")); aSoundPlay2D(Sound_indexes[1], 1.000000f); aObjPlayAnim(Object_handles[58], 0, 25, 3.000000f, 0); aSoundPlayObject(Sound_indexes[2], Object_handles[58], 1.000000f); @@ -3843,7 +3593,7 @@ int16_t CustomObjectScript_18BF::CallEvent(int event, tOSIRISEventInfo *data) { // Script 035: D1 Ground Guard Has Alerted Guard Tower if ((ScriptActionCtr_035 < 1) && (event_data->goal_uid == 7)) { - aShowHUDMessage(Message_strings[17]); + aShowHUDMessage(TXT("GuardTowerAlertedGG")); aSoundPlay2D(Sound_indexes[1], 1.000000f); aObjPlayAnim(Object_handles[63], 0, 25, 3.000000f, 0); aSoundPlayObject(Sound_indexes[2], Object_handles[63], 1.000000f); @@ -3908,7 +3658,7 @@ int16_t CustomObjectScript_10C0::CallEvent(int event, tOSIRISEventInfo *data) { // Script 034: Hanger Guard Has Alerted Guard Tower if ((ScriptActionCtr_034 < 1) && (event_data->goal_uid == 6)) { - aShowHUDMessage(Message_strings[16]); + aShowHUDMessage(TXT("GuardTowerAlertedHG")); aSoundPlay2D(Sound_indexes[1], 1.000000f); aObjPlayAnim(Object_handles[65], 0, 25, 3.000000f, 0); aSoundPlayObject(Sound_indexes[2], Object_handles[65], 1.000000f); @@ -3976,7 +3726,7 @@ int16_t CustomObjectScript_3088::CallEvent(int event, tOSIRISEventInfo *data) { aDoorLockUnlock(0, Door_handles[0]); aAddObjectToInventory(data->me_handle, event_data->it_handle, 0); aSoundPlayObject(Sound_indexes[5], event_data->it_handle, 1.000000f); - aShowHUDMessage(Message_strings[20]); + aShowHUDMessage(TXT("VaultKeyAcquired")); aGoalCompleted(Goal_indexes[3], 1); // Increment the script action counter @@ -3998,7 +3748,7 @@ int16_t CustomObjectScript_2105::CallEvent(int event, tOSIRISEventInfo *data) { aUserFlagSet(2, 1); aAddObjectToInventory(data->me_handle, event_data->it_handle, 0); aSoundPlayObject(Sound_indexes[5], event_data->it_handle, 1.000000f); - aShowHUDMessage(Message_strings[21]); + aShowHUDMessage(TXT("InterfaceAcquired")); aGoalCompleted(Goal_indexes[6], 1); // Increment the script action counter @@ -4019,7 +3769,7 @@ int16_t CustomObjectScript_3092::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_014 < 1) && (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true)) { aObjPlayAnim(data->me_handle, 0, 4, 2.000000f, 0); aSoundPlayObject(Sound_indexes[4], Object_handles[80], 1.000000f); - aShowHUDMessage(Message_strings[22]); + aShowHUDMessage(TXT("HangerDoorUnlocked")); aDoorLockUnlock(0, Door_handles[1]); // Increment the script action counter @@ -4040,7 +3790,7 @@ int16_t CustomObjectScript_187C::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_060 < 1) && (qObjIsPlayer(event_data->it_handle) == true)) { aObjPlayAnim(data->me_handle, 0, 10, 3.000000f, 0); aSoundPlayObject(Sound_indexes[2], data->me_handle, 1.000000f); - aAddGameMessage(Message_strings[23], Message_strings[24]); + aAddGameMessage(TXT("HangerMsgGame"), TXT("HangerMsgHUD")); // Increment the script action counter if (ScriptActionCtr_060 < MAX_ACTION_CTR_VALUE) @@ -4060,7 +3810,7 @@ int16_t CustomObjectScript_10FA::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_041 < 1) && (qObjIsPlayer(event_data->it_handle) == true)) { aObjPlayAnim(data->me_handle, 0, 10, 3.000000f, 0); aSoundPlayObject(Sound_indexes[2], data->me_handle, 1.000000f); - aAddGameMessage(Message_strings[25], Message_strings[26]); + aAddGameMessage(TXT("MemPlasmaGame"), TXT("MemPlasmaHUD")); // Increment the script action counter if (ScriptActionCtr_041 < MAX_ACTION_CTR_VALUE) @@ -4080,7 +3830,7 @@ int16_t CustomObjectScript_0903::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_063 < 1) && (qObjIsPlayer(event_data->it_handle) == true)) { aObjPlayAnim(data->me_handle, 0, 10, 3.000000f, 0); aSoundPlayObject(Sound_indexes[2], data->me_handle, 1.000000f); - aAddGameMessage(Message_strings[27], Message_strings[28]); + aAddGameMessage(TXT("UplinkControlGame"), TXT("UplinkControlHUD")); // Increment the script action counter if (ScriptActionCtr_063 < MAX_ACTION_CTR_VALUE) @@ -4100,7 +3850,7 @@ int16_t CustomObjectScript_1902::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_062 < 1) && (qObjIsPlayer(event_data->it_handle) == true)) { aObjPlayAnim(data->me_handle, 0, 10, 3.000000f, 0); aSoundPlayObject(Sound_indexes[2], data->me_handle, 1.000000f); - aAddGameMessage(Message_strings[29], Message_strings[30]); + aAddGameMessage(TXT("UplinkCenterGame"), TXT("UplinkCenterHUD")); // Increment the script action counter if (ScriptActionCtr_062 < MAX_ACTION_CTR_VALUE) @@ -4120,7 +3870,7 @@ int16_t CustomObjectScript_4047::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_004 < 1) && (qObjIsPlayer(event_data->it_handle) == true)) { aObjPlayAnim(data->me_handle, 0, 10, 3.000000f, 0); aSoundPlayObject(Sound_indexes[2], data->me_handle, 1.000000f); - aAddGameMessage(Message_strings[31], Message_strings[32]); + aAddGameMessage(TXT("InterfacePrepInstrGame"), TXT("InterfacePrepInstHUD")); // Increment the script action counter if (ScriptActionCtr_004 < MAX_ACTION_CTR_VALUE) @@ -4142,14 +3892,14 @@ int16_t CustomObjectScript_289B::CallEvent(int event, tOSIRISEventInfo *data) { if (qUserFlag(0) == false) { aObjSaveHandle(event_data->it_handle, 0); aUserFlagSet(0, 1); - aShowHUDMessage(Message_strings[33]); + aShowHUDMessage(TXT("InterfaceInitialized")); aGoalCompleted(Goal_indexes[7], 1); aSetLevelTimer(1.000000f, 9); - aCinematicIntro(Path_indexes[23], Message_strings[34], Object_handles[33], Path_indexes[24], 9.000000f); + aCinematicIntro(Path_indexes[23], TXT("InitInterfaceCin"), Object_handles[33], Path_indexes[24], 9.000000f); } } else { if (qUserFlag(8) == false) { - aShowHUDMessage(Message_strings[35]); + aShowHUDMessage(TXT("InterfacePrepDenied")); aUserFlagSet(8, 1); aSetLevelTimer(3.000000f, 10); } @@ -4176,7 +3926,7 @@ int16_t CustomObjectScript_3849::CallEvent(int event, tOSIRISEventInfo *data) { aObjPlayAnim(data->me_handle, 0, 1, 2.000000f, 0); aSoundPlayObject(Sound_indexes[4], data->me_handle, 1.000000f); aUserFlagSet(5, 0); - aShowHUDMessage(Message_strings[36]); + aShowHUDMessage(TXT("UplinkPlasmaOff")); aTurnOffSpew(2); aGoalCompleted(Goal_indexes[2], 0); } @@ -4185,7 +3935,7 @@ int16_t CustomObjectScript_3849::CallEvent(int event, tOSIRISEventInfo *data) { aObjPlayAnim(data->me_handle, 1, 2, 2.000000f, 0); aSoundPlayObject(Sound_indexes[4], data->me_handle, 1.000000f); aUserFlagSet(5, 1); - aShowHUDMessage(Message_strings[37]); + aShowHUDMessage(TXT("UplinkPlasmaOn")); aTurnOnSpew(Object_handles[38], -1, 7, 0.000000f, 0.000000f, 65536, 0, 1.400000f, 0.150000f, -1.000000f, 4.000000f, 20.000000f, 1, 2); aGoalCompleted(Goal_indexes[2], 1); @@ -4214,7 +3964,7 @@ int16_t CustomObjectScript_184B::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[4], data->me_handle, 1.000000f); aMatcenSetState(0, Matcen_indexes[1]); aUserFlagSet(4, 0); - aShowHUDMessage(Message_strings[38]); + aShowHUDMessage(TXT("MemPlasmaOff")); aTurnOffSpew(0); aGoalCompleted(Goal_indexes[1], 0); } @@ -4224,7 +3974,7 @@ int16_t CustomObjectScript_184B::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[4], data->me_handle, 1.000000f); aMatcenSetState(1, Matcen_indexes[1]); aUserFlagSet(4, 1); - aShowHUDMessage(Message_strings[39]); + aShowHUDMessage(TXT("MemPlasmaOn")); aTurnOnSpew(Object_handles[37], -1, 7, 0.000000f, 0.000000f, 65536, 0, 1.000000f, 0.150000f, -1.000000f, 4.000000f, 20.000000f, 1, 0); aGoalCompleted(Goal_indexes[1], 1); @@ -4252,7 +4002,7 @@ int16_t CustomObjectScript_204A::CallEvent(int event, tOSIRISEventInfo *data) { aObjPlayAnim(data->me_handle, 0, 1, 2.000000f, 0); aSoundPlayObject(Sound_indexes[4], data->me_handle, 1.000000f); aUserFlagSet(3, 0); - aShowHUDMessage(Message_strings[40]); + aShowHUDMessage(TXT("NanoPlasmaDefOff")); aMatcenSetEnableState(0, Matcen_indexes[10]); aMatcenSetEnableState(0, Matcen_indexes[11]); aMatcenSetEnableState(0, Matcen_indexes[12]); @@ -4264,7 +4014,7 @@ int16_t CustomObjectScript_204A::CallEvent(int event, tOSIRISEventInfo *data) { aObjPlayAnim(data->me_handle, 1, 2, 2.000000f, 0); aSoundPlayObject(Sound_indexes[4], data->me_handle, 1.000000f); aUserFlagSet(3, 1); - aShowHUDMessage(Message_strings[41]); + aShowHUDMessage(TXT("NanoPlasmaDefOn")); aMatcenSetEnableState(1, Matcen_indexes[10]); aMatcenSetEnableState(1, Matcen_indexes[11]); aMatcenSetEnableState(1, Matcen_indexes[12]); @@ -4296,7 +4046,7 @@ int16_t CustomObjectScript_2064::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[4], data->me_handle, 1.000000f); aMatcenSetState(1, Matcen_indexes[2]); aUserFlagSet(10, 1); - aShowHUDMessage(Message_strings[42]); + aShowHUDMessage(TXT("MatcenActivated")); } } else { if (qObjAnimFrame(data->me_handle) == 1.000000f) { @@ -4304,7 +4054,7 @@ int16_t CustomObjectScript_2064::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[4], data->me_handle, 1.000000f); aMatcenSetState(0, Matcen_indexes[2]); aUserFlagSet(10, 0); - aShowHUDMessage(Message_strings[43]); + aShowHUDMessage(TXT("MatcenDeactivated")); } } @@ -4330,7 +4080,7 @@ int16_t CustomObjectScript_1065::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[4], data->me_handle, 1.000000f); aMatcenSetState(1, Matcen_indexes[3]); aUserFlagSet(11, 1); - aShowHUDMessage(Message_strings[42]); + aShowHUDMessage(TXT("MatcenActivated")); } } else { if (qObjAnimFrame(data->me_handle) == 1.000000f) { @@ -4338,7 +4088,7 @@ int16_t CustomObjectScript_1065::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[4], data->me_handle, 1.000000f); aMatcenSetState(0, Matcen_indexes[3]); aUserFlagSet(11, 0); - aShowHUDMessage(Message_strings[43]); + aShowHUDMessage(TXT("MatcenDeactivated")); } } @@ -4364,7 +4114,7 @@ int16_t CustomObjectScript_2063::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[4], data->me_handle, 1.000000f); aMatcenSetState(1, Matcen_indexes[4]); aUserFlagSet(12, 1); - aShowHUDMessage(Message_strings[42]); + aShowHUDMessage(TXT("MatcenActivated")); } } else { if (qObjAnimFrame(data->me_handle) == 1.000000f) { @@ -4372,7 +4122,7 @@ int16_t CustomObjectScript_2063::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[4], data->me_handle, 1.000000f); aMatcenSetState(0, Matcen_indexes[4]); aUserFlagSet(12, 0); - aShowHUDMessage(Message_strings[43]); + aShowHUDMessage(TXT("MatcenDeactivated")); } } @@ -4398,7 +4148,7 @@ int16_t CustomObjectScript_5843::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[4], data->me_handle, 1.000000f); aMatcenSetState(1, Matcen_indexes[5]); aUserFlagSet(13, 1); - aShowHUDMessage(Message_strings[42]); + aShowHUDMessage(TXT("MatcenActivated")); } } else { if (qObjAnimFrame(data->me_handle) == 1.000000f) { @@ -4406,7 +4156,7 @@ int16_t CustomObjectScript_5843::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[4], data->me_handle, 1.000000f); aMatcenSetState(0, Matcen_indexes[5]); aUserFlagSet(13, 0); - aShowHUDMessage(Message_strings[43]); + aShowHUDMessage(TXT("MatcenDeactivated")); } } @@ -4432,7 +4182,7 @@ int16_t CustomObjectScript_1095::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[4], data->me_handle, 1.000000f); aMatcenSetState(1, Matcen_indexes[6]); aUserFlagSet(14, 1); - aShowHUDMessage(Message_strings[42]); + aShowHUDMessage(TXT("MatcenActivated")); } } else { if (qObjAnimFrame(data->me_handle) == 1.000000f) { @@ -4440,7 +4190,7 @@ int16_t CustomObjectScript_1095::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[4], data->me_handle, 1.000000f); aMatcenSetState(0, Matcen_indexes[6]); aUserFlagSet(14, 0); - aShowHUDMessage(Message_strings[43]); + aShowHUDMessage(TXT("MatcenDeactivated")); } } @@ -4466,7 +4216,7 @@ int16_t CustomObjectScript_1094::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[4], data->me_handle, 1.000000f); aMatcenSetState(1, Matcen_indexes[7]); aUserFlagSet(15, 1); - aShowHUDMessage(Message_strings[42]); + aShowHUDMessage(TXT("MatcenActivated")); } } else { if (qObjAnimFrame(data->me_handle) == 1.000000f) { @@ -4474,7 +4224,7 @@ int16_t CustomObjectScript_1094::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[4], data->me_handle, 1.000000f); aMatcenSetState(0, Matcen_indexes[7]); aUserFlagSet(15, 0); - aShowHUDMessage(Message_strings[43]); + aShowHUDMessage(TXT("MatcenDeactivated")); } } @@ -4500,7 +4250,7 @@ int16_t CustomObjectScript_1080::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[4], data->me_handle, 1.000000f); aMatcenSetState(1, Matcen_indexes[8]); aUserFlagSet(16, 1); - aShowHUDMessage(Message_strings[42]); + aShowHUDMessage(TXT("MatcenActivated")); } } else { if (qObjAnimFrame(data->me_handle) == 1.000000f) { @@ -4508,7 +4258,7 @@ int16_t CustomObjectScript_1080::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[4], data->me_handle, 1.000000f); aMatcenSetState(0, Matcen_indexes[8]); aUserFlagSet(16, 0); - aShowHUDMessage(Message_strings[43]); + aShowHUDMessage(TXT("MatcenDeactivated")); } } @@ -4534,7 +4284,7 @@ int16_t CustomObjectScript_187F::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[4], data->me_handle, 1.000000f); aMatcenSetState(1, Matcen_indexes[9]); aUserFlagSet(17, 1); - aShowHUDMessage(Message_strings[42]); + aShowHUDMessage(TXT("MatcenActivated")); } } else { if (qObjAnimFrame(data->me_handle) == 1.000000f) { @@ -4542,7 +4292,7 @@ int16_t CustomObjectScript_187F::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[4], data->me_handle, 1.000000f); aMatcenSetState(0, Matcen_indexes[9]); aUserFlagSet(17, 0); - aShowHUDMessage(Message_strings[43]); + aShowHUDMessage(TXT("MatcenDeactivated")); } } @@ -4567,7 +4317,7 @@ int16_t CustomObjectScript_501A::CallEvent(int event, tOSIRISEventInfo *data) { aObjPlayAnim(data->me_handle, 0, 1, 2.000000f, 0); aSoundPlayObject(Sound_indexes[4], data->me_handle, 1.000000f); aUserFlagSet(6, 0); - aShowHUDMessage(Message_strings[44]); + aShowHUDMessage(TXT("InterfacePowerOff")); aGoalCompleted(Goal_indexes[0], 0); } } else { @@ -4575,7 +4325,7 @@ int16_t CustomObjectScript_501A::CallEvent(int event, tOSIRISEventInfo *data) { aObjPlayAnim(data->me_handle, 1, 2, 2.000000f, 0); aSoundPlayObject(Sound_indexes[4], data->me_handle, 1.000000f); aUserFlagSet(6, 1); - aShowHUDMessage(Message_strings[45]); + aShowHUDMessage(TXT("InterfacePowerOn")); aGoalCompleted(Goal_indexes[0], 1); } } @@ -4600,12 +4350,12 @@ int16_t CustomObjectScript_D80D::CallEvent(int event, tOSIRISEventInfo *data) { if (qUserFlag(7) == false) { aObjPlayAnim(Object_handles[91], 0, 3, 3.000000f, 0); aSoundPlayObject(Sound_indexes[2], data->me_handle, 1.000000f); - aShowHUDMessage(Message_strings[46]); + aShowHUDMessage(TXT("DataUplinkActivated")); aUserFlagSet(7, 1); aGoalCompleted(Goal_indexes[9], 1); } } else { - aShowHUDMessage(Message_strings[47]); + aShowHUDMessage(TXT("InterfaceHasNoPower")); if (qGoalEnabled(Goal_indexes[0]) == false) { aGoalEnableDisable(1, Goal_indexes[0]); } @@ -4640,12 +4390,12 @@ int16_t CustomObjectScript_18A1::CallEvent(int event, tOSIRISEventInfo *data) { aMatcenSetEnableState(0, Matcen_indexes[19]); aTogglePlayerObjAllControls(0, event_data->it_handle); aObjSaveHandle(event_data->it_handle, 1); - aShowHUDMessage(Message_strings[48]); + aShowHUDMessage(TXT("UplinkDocking")); aGoalCompleted(Goal_indexes[10], 1); aSetLevelTimer(2.000000f, 1); } else { if (qUserFlag(8) == false) { - aShowHUDMessage(Message_strings[49]); + aShowHUDMessage(TXT("UplinkErrorNoChg")); aUserFlagSet(8, 1); aSetLevelTimer(3.000000f, 10); } @@ -4658,7 +4408,7 @@ int16_t CustomObjectScript_18A1::CallEvent(int event, tOSIRISEventInfo *data) { } } else { if (qUserFlag(8) == false) { - aShowHUDMessage(Message_strings[50]); + aShowHUDMessage(TXT("UplinkErrorNoPlasma")); aUserFlagSet(8, 1); aSetLevelTimer(3.000000f, 10); } @@ -4668,7 +4418,7 @@ int16_t CustomObjectScript_18A1::CallEvent(int event, tOSIRISEventInfo *data) { } } else { if (qUserFlag(8) == false) { - aShowHUDMessage(Message_strings[51]); + aShowHUDMessage(TXT("UplinkErrorNotAct")); aUserFlagSet(8, 1); aSetLevelTimer(3.000000f, 10); } @@ -4678,21 +4428,21 @@ int16_t CustomObjectScript_18A1::CallEvent(int event, tOSIRISEventInfo *data) { } } else { if (qUserFlag(8) == false) { - aShowHUDMessage(Message_strings[52]); + aShowHUDMessage(TXT("UplinkErrorNoInit")); aUserFlagSet(8, 1); aSetLevelTimer(3.000000f, 10); } } } else { if (qUserFlag(8) == false) { - aShowHUDMessage(Message_strings[53]); + aShowHUDMessage(TXT("UplinkErrorNoInt")); aUserFlagSet(8, 1); aSetLevelTimer(3.000000f, 10); } } } else { if (qUserFlag(8) == false) { - aShowHUDMessage(Message_strings[54]); + aShowHUDMessage(TXT("UplinkErrorNano")); aUserFlagSet(8, 1); aSetLevelTimer(3.000000f, 10); } @@ -4722,7 +4472,7 @@ int16_t CustomObjectScript_208B::CallEvent(int event, tOSIRISEventInfo *data) { aMatcenSetState(1, Matcen_indexes[1]); } aUserVarSet(4, qMathSubFloat(40.000000f, qMathMulFloat(5.000000f, qMathIntToFloat(qGetDifficulty())))); - aShowHUDMessageI(Message_strings[55], qUserVarValueInt(4)); + aShowHUDMessageI(TXT("MemPlasmaObtained"), qUserVarValueInt(4)); aSoundPlayObject(Sound_indexes[6], event_data->it_handle, 1.000000f); aUserFlagSet(1, 1); aUserVarInc(0); @@ -4764,7 +4514,7 @@ int16_t CustomObjectScript_2074::CallEvent(int event, tOSIRISEventInfo *data) { ((qObjIsPlayer(event_data->it_handle) == true) && (qUserFlag(18) == false) && ((qObjExists(Object_handles[5]) == true) || (qObjExists(Object_handles[6]) == true) || (qObjExists(Object_handles[7]) == true) || (qObjExists(Object_handles[8]) == true)))) { - aShowHUDMessageObj(Message_strings[58], event_data->it_handle); + aShowHUDMessageObj(TXT("ZCamSpotted"), event_data->it_handle); aAISetState(1, Object_handles[5]); aAISetState(1, Object_handles[6]); aAISetState(1, Object_handles[7]); @@ -4800,7 +4550,7 @@ int16_t CustomObjectScript_203D::CallEvent(int event, tOSIRISEventInfo *data) { // Script 111: Prep Room Cam Saw Player if ((ScriptActionCtr_111 < 1) && ((qObjIsPlayer(event_data->it_handle) == true) && (qUserFlag(20) == false) && (qObjExists(Object_handles[20]) == true))) { - aShowHUDMessageObj(Message_strings[58], event_data->it_handle); + aShowHUDMessageObj(TXT("ZCamSpotted"), event_data->it_handle); aAISetState(1, Object_handles[20]); aUserFlagSet(20, 1); @@ -4835,7 +4585,7 @@ int16_t CustomObjectScript_11B1::CallEvent(int event, tOSIRISEventInfo *data) { ((qObjIsPlayer(event_data->it_handle) == true) && (qUserFlag(21) == false) && ((qObjExists(Object_handles[21]) == true) || (qObjExists(Object_handles[22]) == true) || (qObjExists(Object_handles[23]) == true) || (qObjExists(Object_handles[24]) == true)))) { - aShowHUDMessageObj(Message_strings[58], event_data->it_handle); + aShowHUDMessageObj(TXT("ZCamSpotted"), event_data->it_handle); aAISetState(1, Object_handles[21]); aAISetState(1, Object_handles[22]); aAISetState(1, Object_handles[23]); @@ -4872,7 +4622,7 @@ int16_t CustomObjectScript_3898::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_113 < 1) && ((qObjIsPlayer(event_data->it_handle) == true) && (qUserFlag(22) == false) && ((qObjExists(Object_handles[25]) == true) || (qObjExists(Object_handles[26]) == true)))) { - aShowHUDMessageObj(Message_strings[58], event_data->it_handle); + aShowHUDMessageObj(TXT("ZCamSpotted"), event_data->it_handle); aAISetState(1, Object_handles[25]); aAISetState(1, Object_handles[26]); aUserFlagSet(22, 1); @@ -4906,7 +4656,7 @@ int16_t CustomObjectScript_303C::CallEvent(int event, tOSIRISEventInfo *data) { // Script 114: Substation 1 Cam Saw Player if ((ScriptActionCtr_114 < 1) && ((qObjIsPlayer(event_data->it_handle) == true) && (qUserFlag(23) == false) && (qObjExists(Object_handles[27]) == true))) { - aShowHUDMessageObj(Message_strings[58], event_data->it_handle); + aShowHUDMessageObj(TXT("ZCamSpotted"), event_data->it_handle); aAISetState(1, Object_handles[27]); aUserFlagSet(23, 1); @@ -4941,7 +4691,7 @@ int16_t CustomObjectScript_2090::CallEvent(int event, tOSIRISEventInfo *data) { ((qObjIsPlayer(event_data->it_handle) == true) && (qUserFlag(24) == false) && ((qObjExists(Object_handles[28]) == true) || (qObjExists(Object_handles[29]) == true) || (qObjExists(Object_handles[30]) == true)))) { - aShowHUDMessageObj(Message_strings[58], event_data->it_handle); + aShowHUDMessageObj(TXT("ZCamSpotted"), event_data->it_handle); aAISetState(1, Object_handles[28]); aAISetState(1, Object_handles[29]); aAISetState(1, Object_handles[30]); @@ -4977,7 +4727,7 @@ int16_t CustomObjectScript_09D4::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_116 < 1) && ((qObjIsPlayer(event_data->it_handle) == true) && (qUserFlag(25) == false) && ((qObjExists(Object_handles[31]) == true) || (qObjExists(Object_handles[32]) == true)))) { - aShowHUDMessageObj(Message_strings[58], event_data->it_handle); + aShowHUDMessageObj(TXT("ZCamSpotted"), event_data->it_handle); aAISetState(1, Object_handles[31]); aAISetState(1, Object_handles[32]); aUserFlagSet(25, 1); @@ -4999,7 +4749,7 @@ int16_t CustomObjectScript_1050::CallEvent(int event, tOSIRISEventInfo *data) { // Script 126: Hangar Turret 1 Hit by Player if ((ScriptActionCtr_126 < 1) && ((qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) && (qUserFlag(18) == false))) { - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ZTurretHit")); aAISetState(1, Object_handles[5]); aAISetState(1, Object_handles[6]); aAISetState(1, Object_handles[7]); @@ -5023,7 +4773,7 @@ int16_t CustomObjectScript_2044::CallEvent(int event, tOSIRISEventInfo *data) { // Script 127: Hangar Turret 2 Hit by Player if ((ScriptActionCtr_127 < 1) && ((qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) && (qUserFlag(18) == false))) { - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ZTurretHit")); aAISetState(1, Object_handles[5]); aAISetState(1, Object_handles[6]); aAISetState(1, Object_handles[7]); @@ -5047,7 +4797,7 @@ int16_t CustomObjectScript_1845::CallEvent(int event, tOSIRISEventInfo *data) { // Script 128: Hangar Turret 3 Hit by Player if ((ScriptActionCtr_128 < 1) && ((qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) && (qUserFlag(18) == false))) { - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ZTurretHit")); aAISetState(1, Object_handles[5]); aAISetState(1, Object_handles[6]); aAISetState(1, Object_handles[7]); @@ -5071,7 +4821,7 @@ int16_t CustomObjectScript_1058::CallEvent(int event, tOSIRISEventInfo *data) { // Script 129: Hangar Turret 4 Hit by Player if ((ScriptActionCtr_129 < 1) && ((qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) && (qUserFlag(18) == false))) { - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ZTurretHit")); aAISetState(1, Object_handles[5]); aAISetState(1, Object_handles[6]); aAISetState(1, Object_handles[7]); @@ -5095,7 +4845,7 @@ int16_t CustomObjectScript_09A3::CallEvent(int event, tOSIRISEventInfo *data) { // Script 130: Prep Room Turret Hit by Player if ((ScriptActionCtr_130 < 1) && ((qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) && (qUserFlag(20) == false))) { - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ZTurretHit")); aAISetState(1, Object_handles[20]); aUserFlagSet(18, 1); @@ -5116,7 +4866,7 @@ int16_t CustomObjectScript_11AF::CallEvent(int event, tOSIRISEventInfo *data) { // Script 131: Mem Plasma Turret 1 Hit by Player if ((ScriptActionCtr_131 < 1) && ((qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) && (qUserFlag(21) == false))) { - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ZTurretHit")); aAISetState(1, Object_handles[21]); aAISetState(1, Object_handles[22]); aAISetState(1, Object_handles[23]); @@ -5140,7 +4890,7 @@ int16_t CustomObjectScript_49B0::CallEvent(int event, tOSIRISEventInfo *data) { // Script 132: Mem Plasma Turret 2 Hit by Player if ((ScriptActionCtr_132 < 1) && ((qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) && (qUserFlag(21) == false))) { - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ZTurretHit")); aAISetState(1, Object_handles[21]); aAISetState(1, Object_handles[22]); aAISetState(1, Object_handles[23]); @@ -5164,7 +4914,7 @@ int16_t CustomObjectScript_11D2::CallEvent(int event, tOSIRISEventInfo *data) { // Script 133: Mem Plasma Turret 3 Hit by Player if ((ScriptActionCtr_133 < 1) && ((qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) && (qUserFlag(21) == false))) { - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ZTurretHit")); aAISetState(1, Object_handles[21]); aAISetState(1, Object_handles[22]); aAISetState(1, Object_handles[23]); @@ -5188,7 +4938,7 @@ int16_t CustomObjectScript_09D5::CallEvent(int event, tOSIRISEventInfo *data) { // Script 134: Mem Plasma Turret 4 Hit by Player if ((ScriptActionCtr_134 < 1) && ((qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) && (qUserFlag(21) == false))) { - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ZTurretHit")); aAISetState(1, Object_handles[21]); aAISetState(1, Object_handles[22]); aAISetState(1, Object_handles[23]); @@ -5212,7 +4962,7 @@ int16_t CustomObjectScript_18A5::CallEvent(int event, tOSIRISEventInfo *data) { // Script 135: Corridor Turret 1 Hit by Player if ((ScriptActionCtr_135 < 1) && ((qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) && (qUserFlag(22) == false))) { - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ZTurretHit")); aAISetState(1, Object_handles[25]); aAISetState(1, Object_handles[26]); aUserFlagSet(22, 1); @@ -5234,7 +4984,7 @@ int16_t CustomObjectScript_10FB::CallEvent(int event, tOSIRISEventInfo *data) { // Script 136: Corridor Turret 2 Hit by Player if ((ScriptActionCtr_136 < 1) && ((qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) && (qUserFlag(22) == false))) { - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ZTurretHit")); aAISetState(1, Object_handles[25]); aAISetState(1, Object_handles[26]); aUserFlagSet(22, 1); @@ -5256,7 +5006,7 @@ int16_t CustomObjectScript_19A2::CallEvent(int event, tOSIRISEventInfo *data) { // Script 137: Substation 1 Turret Hit by Player if ((ScriptActionCtr_137 < 1) && ((qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) && (qUserFlag(23) == false))) { - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ZTurretHit")); aAISetState(1, Object_handles[27]); aUserFlagSet(23, 1); @@ -5277,7 +5027,7 @@ int16_t CustomObjectScript_09A4::CallEvent(int event, tOSIRISEventInfo *data) { // Script 138: Auxillary Turret 1 Hit by Player if ((ScriptActionCtr_138 < 1) && ((qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) && (qUserFlag(24) == false))) { - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ZTurretHit")); aAISetState(1, Object_handles[28]); aAISetState(1, Object_handles[29]); aAISetState(1, Object_handles[30]); @@ -5300,7 +5050,7 @@ int16_t CustomObjectScript_09A5::CallEvent(int event, tOSIRISEventInfo *data) { // Script 139: Auxillary Turret 2 Hit by Player if ((ScriptActionCtr_139 < 1) && ((qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) && (qUserFlag(24) == false))) { - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ZTurretHit")); aAISetState(1, Object_handles[28]); aAISetState(1, Object_handles[29]); aAISetState(1, Object_handles[30]); @@ -5323,7 +5073,7 @@ int16_t CustomObjectScript_09A6::CallEvent(int event, tOSIRISEventInfo *data) { // Script 140: Auxillary Turret 3 Hit by Player if ((ScriptActionCtr_140 < 1) && ((qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) && (qUserFlag(24) == false))) { - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ZTurretHit")); aAISetState(1, Object_handles[28]); aAISetState(1, Object_handles[29]); aAISetState(1, Object_handles[30]); @@ -5346,7 +5096,7 @@ int16_t CustomObjectScript_09A1::CallEvent(int event, tOSIRISEventInfo *data) { // Script 141: Control Turret 1 Hit by Player if ((ScriptActionCtr_141 < 1) && ((qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) && (qUserFlag(25) == false))) { - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ZTurretHit")); aAISetState(1, Object_handles[31]); aAISetState(1, Object_handles[32]); aUserFlagSet(25, 1); @@ -5368,7 +5118,7 @@ int16_t CustomObjectScript_20FD::CallEvent(int event, tOSIRISEventInfo *data) { // Script 142: Control Turret 2 Hit by Player if ((ScriptActionCtr_142 < 1) && ((qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) && (qUserFlag(25) == false))) { - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ZTurretHit")); aAISetState(1, Object_handles[31]); aAISetState(1, Object_handles[32]); aUserFlagSet(25, 1); @@ -5390,7 +5140,7 @@ int16_t CustomObjectScript_187E::CallEvent(int event, tOSIRISEventInfo *data) { // Script 046: Player Picks Up Camera Monitor if (qObjIsPlayer(event_data->it_handle) == true) { aSoundPlayObject(Sound_indexes[5], event_data->it_handle, 1.000000f); - aShowHUDMessageObj(Message_strings[59], event_data->it_handle); + aShowHUDMessageObj(TXT("ZGotCamMonitor"), event_data->it_handle); aAddObjectToInventory(data->me_handle, event_data->it_handle, 0); aObjSaveHandle(event_data->it_handle, 5); aUserFlagSet(26, 1); @@ -5409,10 +5159,10 @@ int16_t CustomObjectScript_187E::CallEvent(int event, tOSIRISEventInfo *data) { aObjGhostSet(0, data->me_handle); aAddObjectToInventory(data->me_handle, event_data->it_handle, 0); if (qUserFlag(27) == true) { - aShowHUDMessageObj(Message_strings[60], event_data->it_handle); + aShowHUDMessageObj(TXT("ZCamMonitorOff"), event_data->it_handle); aUserFlagSet(27, 0); } else { - aShowHUDMessageObj(Message_strings[61], event_data->it_handle); + aShowHUDMessageObj(TXT("ZCamMonitorOn"), event_data->it_handle); aUserFlagSet(27, 1); } aSoundPlay2DObj(Sound_indexes[8], event_data->it_handle, 1.000000f); @@ -5435,7 +5185,7 @@ int16_t CustomObjectScript_987D::CallEvent(int event, tOSIRISEventInfo *data) { if (qObjIsPlayer(event_data->it_handle) == 1) { aObjDelete(data->me_handle); aSoundPlayObject(Sound_indexes[5], event_data->it_handle, 1.000000f); - aAddGameMessage(Message_strings[62], Message_strings[63]); + aAddGameMessage(TXT("CrashedShipGame"), TXT("CrashedShipHud")); // Increment the script action counter if (ScriptActionCtr_118 < MAX_ACTION_CTR_VALUE) @@ -5488,7 +5238,7 @@ int16_t CustomObjectScript_0816::CallEvent(int event, tOSIRISEventInfo *data) { // Script 147: Locked Door - No Entry Message if (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[64]); + aShowHUDMessage(TXT("NoEntry")); // Increment the script action counter if (ScriptActionCtr_147 < MAX_ACTION_CTR_VALUE) diff --git a/scripts/Level10_FRN.msg b/scripts/level10_FRN.msg similarity index 100% rename from scripts/Level10_FRN.msg rename to scripts/level10_FRN.msg diff --git a/scripts/level10_Ger.msg b/scripts/level10_GER.msg similarity index 100% rename from scripts/level10_Ger.msg rename to scripts/level10_GER.msg diff --git a/scripts/Level10_ITN.msg b/scripts/level10_ITN.msg similarity index 100% rename from scripts/Level10_ITN.msg rename to scripts/level10_ITN.msg diff --git a/scripts/level11.cpp b/scripts/level11.cpp index 1db0f5955..e3778e9b0 100644 --- a/scripts/level11.cpp +++ b/scripts/level11.cpp @@ -22,10 +22,10 @@ // Filename: level11.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -1670,180 +1670,12 @@ void RestoreGlobalActionCtrs(void *file_ptr) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; +std::map Messages; - return (s); -} - -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -2043,25 +1875,6 @@ const char *Goal_names[NUM_GOAL_NAMES] = {"Destroy secondary forcefield generato "Release the prisoner"}; int Goal_indexes[NUM_GOAL_NAMES]; -#define NUM_MESSAGE_NAMES 16 -const char *Message_names[NUM_MESSAGE_NAMES] = {"Work", - "FirstCamera", - "ForcefieldDisabled", - "MainDestroyed", - "ForcefieldsDisabled", - "ForcefieldFirst", - "PickupKey", - "DoorUnlocked", - "Spotted", - "GotHim", - "FreeAtLast", - "GoUpLeft", - "PipeDemo", - "Reroute", - "All6Deactive", - "DestroyThese"}; -const char *Message_strings[NUM_MESSAGE_NAMES]; - // =============== // InitializeDLL() // =============== @@ -2075,7 +1888,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; @@ -2083,14 +1895,7 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { if (func_list->script_identifier != NULL) { _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "level11.msg"); @@ -2141,10 +1946,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } @@ -3655,7 +3456,7 @@ int16_t CustomObjectScript_0985::CallEvent(int event, tOSIRISEventInfo *data) { // Script 120: IntroCam if ((ScriptActionCtr_120 < 1) && (1 == true)) { - aCinematicIntro(Path_indexes[0], Message_strings[0], Object_handles[1], Path_indexes[1], 22.000000f); + aCinematicIntro(Path_indexes[0], TXT("Work"), Object_handles[1], Path_indexes[1], 22.000000f); // Increment the script action counter if (ScriptActionCtr_120 < MAX_ACTION_CTR_VALUE) @@ -3722,7 +3523,7 @@ int16_t CustomObjectScript_092B::CallEvent(int event, tOSIRISEventInfo *data) { // Script 049: Disable First FF if (1) { aGoalCompleted(Goal_indexes[0], 1); - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("ForcefieldDisabled")); aSetWaypoint(2); aPortalRenderSet(0, 0, Room_indexes[2], 1); @@ -3752,7 +3553,7 @@ int16_t CustomObjectScript_093E::CallEvent(int event, tOSIRISEventInfo *data) { aGoalCompleted(Goal_indexes[2], 1); aSetWaypoint(3); aPortalRenderSet(0, 0, Room_indexes[3], 1); - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("MainDestroyed")); // Increment the script action counter if (ScriptActionCtr_050 < MAX_ACTION_CTR_VALUE) @@ -3779,7 +3580,7 @@ int16_t CustomObjectScript_0940::CallEvent(int event, tOSIRISEventInfo *data) { } aGoalCompleted(Goal_indexes[2], 1); aPortalRenderSet(0, 0, Room_indexes[3], 1); - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("MainDestroyed")); aSetWaypoint(3); // Increment the script action counter @@ -3808,7 +3609,7 @@ int16_t CustomObjectScript_093F::CallEvent(int event, tOSIRISEventInfo *data) { aGoalCompleted(Goal_indexes[2], 1); aPortalRenderSet(0, 0, Room_indexes[3], 1); aSetWaypoint(3); - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("MainDestroyed")); // Increment the script action counter if (ScriptActionCtr_011 < MAX_ACTION_CTR_VALUE) @@ -3830,7 +3631,7 @@ int16_t CustomObjectScript_0954::CallEvent(int event, tOSIRISEventInfo *data) { // Script 053: Disable Extra1 FF if (1) { - aShowHUDMessage(Message_strings[4]); + aShowHUDMessage(TXT("ForcefieldsDisabled")); aPortalRenderSet(0, 0, Room_indexes[4], 1); aPortalRenderSet(0, 1, Room_indexes[4], 1); aPortalRenderSet(0, 3, Room_indexes[4], 1); @@ -3856,7 +3657,7 @@ int16_t CustomObjectScript_3951::CallEvent(int event, tOSIRISEventInfo *data) { // Script 052: Disable Extra2 FF if (1) { - aShowHUDMessage(Message_strings[4]); + aShowHUDMessage(TXT("ForcefieldsDisabled")); aPortalRenderSet(0, 2, Room_indexes[5], 1); aPortalRenderSet(0, 3, Room_indexes[5], 1); aPortalRenderSet(0, 4, Room_indexes[5], 1); @@ -3881,7 +3682,7 @@ int16_t CustomObjectScript_08CF::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[0], Object_handles[8], 1.000000f); aObjSetLightingDist(Object_handles[8], 40.000000f); aCreatePopupView(0, Object_handles[57], 5.000000f, 1.000000f); - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ForcefieldFirst")); aObjPlayAnim(Object_handles[8], 1, 3, 2.000000f, 1); aObjMakeVulnerable(Object_handles[8]); aObjPlayAnim(data->me_handle, 0, 3, 4.000000f, 0); @@ -3908,7 +3709,7 @@ int16_t CustomObjectScript_08CC::CallEvent(int event, tOSIRISEventInfo *data) { aObjMakeVulnerable(Object_handles[9]); aObjPlayAnim(data->me_handle, 0, 3, 4.000000f, 0); aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ForcefieldFirst")); aCreatePopupView(0, Object_handles[59], 5.000000f, 1.000000f); aSoundPlayObject(Sound_indexes[0], Object_handles[9], 1.000000f); @@ -3937,7 +3738,7 @@ int16_t CustomObjectScript_10D2::CallEvent(int event, tOSIRISEventInfo *data) { aObjPlayAnim(data->me_handle, 0, 3, 4.000000f, 0); aCreatePopupView(0, Object_handles[61], 8.000000f, 1.000000f); aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ForcefieldFirst")); // Increment the script action counter if (ScriptActionCtr_024 < MAX_ACTION_CTR_VALUE) @@ -3961,7 +3762,7 @@ int16_t CustomObjectScript_0943::CallEvent(int event, tOSIRISEventInfo *data) { aObjMakeVulnerable(Object_handles[5]); aObjPlayAnim(data->me_handle, 0, 3, 4.000000f, 0); aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ForcefieldFirst")); aCreatePopupView(0, Object_handles[63], 8.000000f, 1.000000f); // Increment the script action counter @@ -3986,7 +3787,7 @@ int16_t CustomObjectScript_0944::CallEvent(int event, tOSIRISEventInfo *data) { aObjMakeVulnerable(Object_handles[7]); aObjPlayAnim(data->me_handle, 0, 3, 4.000000f, 0); aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ForcefieldFirst")); aCreatePopupView(0, Object_handles[65], 8.000000f, 1.000000f); // Increment the script action counter @@ -4011,7 +3812,7 @@ int16_t CustomObjectScript_08CE::CallEvent(int event, tOSIRISEventInfo *data) { aObjMakeVulnerable(Object_handles[6]); aObjPlayAnim(data->me_handle, 0, 3, 4.000000f, 0); aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ForcefieldFirst")); aCreatePopupView(0, Object_handles[67], 8.000000f, 1.000000f); // Increment the script action counter @@ -4036,7 +3837,7 @@ int16_t CustomObjectScript_0952::CallEvent(int event, tOSIRISEventInfo *data) { aObjMakeVulnerable(Object_handles[10]); aObjPlayAnim(data->me_handle, 0, 3, 4.000000f, 0); aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ForcefieldFirst")); aCreatePopupView(0, Object_handles[69], 8.000000f, 1.000000f); // Increment the script action counter @@ -4061,7 +3862,7 @@ int16_t CustomObjectScript_0953::CallEvent(int event, tOSIRISEventInfo *data) { aObjMakeVulnerable(Object_handles[11]); aObjPlayAnim(data->me_handle, 0, 3, 4.000000f, 0); aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ForcefieldFirst")); aCreatePopupView(0, Object_handles[71], 8.000000f, 1.000000f); // Increment the script action counter @@ -4082,7 +3883,7 @@ int16_t CustomObjectScript_1826::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_004 < 1) && (qObjIsPlayer(event_data->it_handle) == true)) { aSetWaypoint(4); aSoundPlayObject(Sound_indexes[2], data->me_handle, 1.000000f); - aShowHUDMessage(Message_strings[6]); + aShowHUDMessage(TXT("PickupKey")); aObjDelete(data->me_handle); aDoorLockUnlock(0, Door_handles[2]); aDoorLockUnlock(0, Door_handles[3]); @@ -4624,7 +4425,7 @@ int16_t CustomObjectScript_1182::CallEvent(int event, tOSIRISEventInfo *data) { // Script 063: AnotherSwitch-2 if ((ScriptActionCtr_063 < 1) && (qObjIsPlayerWeapon(event_data->it_handle) == true)) { - aShowHUDMessage(Message_strings[7]); + aShowHUDMessage(TXT("DoorUnlocked")); aDoorLockUnlock(0, Door_handles[16]); aSoundPlayObject(Sound_indexes[3], data->me_handle, 1.000000f); aObjPlayAnim(data->me_handle, 0, 4, 2.000000f, 0); @@ -4645,7 +4446,7 @@ int16_t CustomObjectScript_1181::CallEvent(int event, tOSIRISEventInfo *data) { // Script 062: AnotherSwitch-1 if ((ScriptActionCtr_062 < 1) && (qObjIsPlayerWeapon(event_data->it_handle) == true)) { - aShowHUDMessage(Message_strings[7]); + aShowHUDMessage(TXT("DoorUnlocked")); aDoorLockUnlock(0, Door_handles[17]); aSoundPlayObject(Sound_indexes[3], data->me_handle, 1.000000f); aObjPlayAnim(data->me_handle, 0, 4, 2.000000f, 0); @@ -4669,7 +4470,7 @@ int16_t CustomObjectScript_110A::CallEvent(int event, tOSIRISEventInfo *data) { ((qObjCanSeePlayer(65, data->me_handle, 240.000000f) == true) && ((ScriptActionCtr_131 > 0) == true))) { aAISetState(1, Object_handles[54]); aAISetState(1, Object_handles[53]); - aShowHUDMessage(Message_strings[8]); + aShowHUDMessage(TXT("Spotted")); aSoundPlayObject(Sound_indexes[6], data->me_handle, 1.000000f); // Increment the script action counter @@ -4739,7 +4540,7 @@ int16_t CustomObjectScript_10DF::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_078 < 1) && (qObjCanSeePlayer(50, data->me_handle, 150.000000f) == true)) { aAISetState(1, Object_handles[50]); aAISetState(1, Object_handles[49]); - aShowHUDMessage(Message_strings[8]); + aShowHUDMessage(TXT("Spotted")); aSoundPlayObject(Sound_indexes[6], data->me_handle, 1.000000f); // Increment the script action counter @@ -4760,7 +4561,7 @@ int16_t CustomObjectScript_10DE::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_077 < 1) && (qObjCanSeePlayer(50, data->me_handle, 150.000000f) == true)) { aAISetState(1, Object_handles[51]); aAISetState(1, Object_handles[52]); - aShowHUDMessage(Message_strings[8]); + aShowHUDMessage(TXT("Spotted")); aSoundPlayObject(Sound_indexes[6], data->me_handle, 1.000000f); // Increment the script action counter @@ -4781,7 +4582,7 @@ int16_t CustomObjectScript_10DD::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_076 < 1) && (qObjCanSeePlayer(50, data->me_handle, 150.000000f) == true)) { aAISetState(1, Object_handles[48]); aAISetState(1, Object_handles[47]); - aShowHUDMessage(Message_strings[8]); + aShowHUDMessage(TXT("Spotted")); aSoundPlayObject(Sound_indexes[6], data->me_handle, 1.000000f); // Increment the script action counter @@ -4802,7 +4603,7 @@ int16_t CustomObjectScript_10DC::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_075 < 1) && (qObjCanSeePlayer(65, data->me_handle, 150.000000f) == true)) { aAISetState(1, Object_handles[45]); aAISetState(1, Object_handles[46]); - aShowHUDMessage(Message_strings[8]); + aShowHUDMessage(TXT("Spotted")); aSoundPlayObject(Sound_indexes[6], data->me_handle, 1.000000f); // Increment the script action counter @@ -4825,7 +4626,7 @@ int16_t CustomObjectScript_10DB::CallEvent(int event, tOSIRISEventInfo *data) { aAISetState(1, Object_handles[32]); aAISetState(1, Object_handles[33]); aAISetState(1, Object_handles[30]); - aShowHUDMessage(Message_strings[8]); + aShowHUDMessage(TXT("Spotted")); aSoundPlayObject(Sound_indexes[6], data->me_handle, 1.000000f); // Increment the script action counter @@ -4845,7 +4646,7 @@ int16_t CustomObjectScript_10D6::CallEvent(int event, tOSIRISEventInfo *data) { // Script 073: Security Alert-A if ((ScriptActionCtr_073 < 1) && (qObjCanSeePlayer(30, data->me_handle, 60.000000f) == true)) { aAISetState(1, Object_handles[44]); - aShowHUDMessage(Message_strings[8]); + aShowHUDMessage(TXT("Spotted")); aSoundPlayObject(Sound_indexes[6], data->me_handle, 1.000000f); // Increment the script action counter @@ -4867,7 +4668,7 @@ int16_t CustomObjectScript_10D7::CallEvent(int event, tOSIRISEventInfo *data) { aAISetState(1, Object_handles[43]); aAISetState(1, Object_handles[41]); aAISetState(1, Object_handles[42]); - aShowHUDMessage(Message_strings[8]); + aShowHUDMessage(TXT("Spotted")); aSoundPlayObject(Sound_indexes[6], data->me_handle, 1.000000f); // Increment the script action counter @@ -4889,7 +4690,7 @@ int16_t CustomObjectScript_10D8::CallEvent(int event, tOSIRISEventInfo *data) { aAISetState(1, Object_handles[38]); aAISetState(1, Object_handles[40]); aAISetState(1, Object_handles[39]); - aShowHUDMessage(Message_strings[8]); + aShowHUDMessage(TXT("Spotted")); aSoundPlayObject(Sound_indexes[6], data->me_handle, 1.000000f); // Increment the script action counter @@ -4910,7 +4711,7 @@ int16_t CustomObjectScript_116C::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_070 < 1) && (qObjCanSeePlayer(90, data->me_handle, 70.000000f) == true)) { aAISetState(1, Object_handles[29]); aAISetState(1, Object_handles[28]); - aShowHUDMessage(Message_strings[8]); + aShowHUDMessage(TXT("Spotted")); aSoundPlayObject(Sound_indexes[6], data->me_handle, 1.000000f); // Increment the script action counter @@ -4933,7 +4734,7 @@ int16_t CustomObjectScript_10D5::CallEvent(int event, tOSIRISEventInfo *data) { aAISetState(1, Object_handles[34]); aAISetState(1, Object_handles[36]); aAISetState(1, Object_handles[35]); - aShowHUDMessage(Message_strings[8]); + aShowHUDMessage(TXT("Spotted")); aSoundPlayObject(Sound_indexes[6], data->me_handle, 1.000000f); // Increment the script action counter @@ -4954,7 +4755,7 @@ int16_t CustomObjectScript_10DA::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_068 < 1) && (qObjCanSeePlayer(90, data->me_handle, 80.000000f) == true)) { aAISetState(1, Object_handles[26]); aAISetState(1, Object_handles[27]); - aShowHUDMessage(Message_strings[8]); + aShowHUDMessage(TXT("Spotted")); aSoundPlayObject(Sound_indexes[6], data->me_handle, 1.000000f); // Increment the script action counter @@ -4977,7 +4778,7 @@ int16_t CustomObjectScript_18D4::CallEvent(int event, tOSIRISEventInfo *data) { aAISetState(1, Object_handles[17]); aAISetState(1, Object_handles[18]); aAISetState(1, Object_handles[16]); - aShowHUDMessage(Message_strings[8]); + aShowHUDMessage(TXT("Spotted")); aSoundPlayObject(Sound_indexes[6], data->me_handle, 1.000000f); // Increment the script action counter @@ -5000,7 +4801,7 @@ int16_t CustomObjectScript_18CD::CallEvent(int event, tOSIRISEventInfo *data) { aAISetState(1, Object_handles[22]); aAISetState(1, Object_handles[20]); aAISetState(1, Object_handles[19]); - aShowHUDMessage(Message_strings[8]); + aShowHUDMessage(TXT("Spotted")); aSoundPlayObject(Sound_indexes[6], data->me_handle, 1.000000f); // Increment the script action counter @@ -5022,7 +4823,7 @@ int16_t CustomObjectScript_18D3::CallEvent(int event, tOSIRISEventInfo *data) { aAISetState(1, Object_handles[23]); aAISetState(1, Object_handles[25]); aAISetState(1, Object_handles[24]); - aShowHUDMessage(Message_strings[8]); + aShowHUDMessage(TXT("Spotted")); aSoundPlayObject(Sound_indexes[6], data->me_handle, 1.000000f); // Increment the script action counter @@ -5812,7 +5613,7 @@ int16_t CustomObjectScript_0A53::CallEvent(int event, tOSIRISEventInfo *data) { aDoorLockUnlock(0, Door_handles[0]); aSoundPlaySteaming("VoxLev11SpecificB.osf", 1.000000f); aAIGoalFollowPath(Object_handles[72], Path_indexes[3], 1, 23, 1, 3, 4352, -1); - aShowHUDMessage(Message_strings[10]); + aShowHUDMessage(TXT("FreeAtLast")); // Increment the script action counter if (ScriptActionCtr_127 < MAX_ACTION_CTR_VALUE) @@ -5879,7 +5680,7 @@ int16_t CustomObjectScript_096A::CallEvent(int event, tOSIRISEventInfo *data) { // Script 169: PPipeDestroyed 3 if (1) { - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("ForcefieldDisabled")); aPortalRenderSet(0, 0, Room_indexes[6], 1); // Increment the script action counter @@ -5898,7 +5699,7 @@ int16_t CustomObjectScript_0A66::CallEvent(int event, tOSIRISEventInfo *data) { // Script 160: PSwitch6 Hit if ((qObjIsPlayerWeapon(event_data->it_handle) == true) && (qUserVarValue(6) == 0.000000f)) { - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("Reroute")); aObjPlayAnim(data->me_handle, 0, 3, 2.000000f, 0); aSoundPlayObject(Sound_indexes[3], data->me_handle, 1.000000f); aSetObjectTimer(Object_handles[14], 0.000000f, -1); @@ -5941,7 +5742,7 @@ int16_t CustomObjectScript_0A65::CallEvent(int event, tOSIRISEventInfo *data) { // Script 159: PSwitch5 Hit if ((qObjIsPlayerWeapon(event_data->it_handle) == true) && (qUserVarValue(5) == 0.000000f)) { - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("Reroute")); aObjPlayAnim(data->me_handle, 0, 3, 2.000000f, 0); aSoundPlayObject(Sound_indexes[3], data->me_handle, 1.000000f); aSetObjectTimer(Object_handles[14], 0.000000f, -1); @@ -5984,7 +5785,7 @@ int16_t CustomObjectScript_0A64::CallEvent(int event, tOSIRISEventInfo *data) { // Script 158: PSwitch4 Hit if ((qObjIsPlayerWeapon(event_data->it_handle) == true) && (qUserVarValue(4) == 0.000000f)) { - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("Reroute")); aObjPlayAnim(data->me_handle, 0, 3, 2.000000f, 0); aSoundPlayObject(Sound_indexes[3], data->me_handle, 1.000000f); aSetObjectTimer(Object_handles[14], 0.000000f, -1); @@ -6027,7 +5828,7 @@ int16_t CustomObjectScript_0A63::CallEvent(int event, tOSIRISEventInfo *data) { // Script 157: PSwitch3 Hit if ((qObjIsPlayerWeapon(event_data->it_handle) == true) && (qUserVarValue(3) == 0.000000f)) { - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("Reroute")); aObjPlayAnim(data->me_handle, 0, 3, 2.000000f, 0); aSoundPlayObject(Sound_indexes[3], data->me_handle, 1.000000f); aSetObjectTimer(Object_handles[14], 0.000000f, -1); @@ -6070,7 +5871,7 @@ int16_t CustomObjectScript_0A62::CallEvent(int event, tOSIRISEventInfo *data) { // Script 061: PSwitch2 Hit if ((qObjIsPlayerWeapon(event_data->it_handle) == true) && (qUserVarValue(2) == 0.000000f)) { - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("Reroute")); aObjPlayAnim(data->me_handle, 0, 3, 2.000000f, 0); aSoundPlayObject(Sound_indexes[3], data->me_handle, 1.000000f); aSetObjectTimer(Object_handles[14], 0.000000f, -1); @@ -6113,7 +5914,7 @@ int16_t CustomObjectScript_1221::CallEvent(int event, tOSIRISEventInfo *data) { // Script 059: PSwitch1 Hit if ((qObjIsPlayerWeapon(event_data->it_handle) == true) && (qUserVarValue(1) == 0.000000f)) { - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("Reroute")); aObjPlayAnim(data->me_handle, 0, 3, 2.000000f, 0); aSoundPlayObject(Sound_indexes[3], data->me_handle, 1.000000f); aSetObjectTimer(Object_handles[14], 0.000000f, -1); @@ -6160,7 +5961,7 @@ int16_t CustomObjectScript_096B::CallEvent(int event, tOSIRISEventInfo *data) { // Script 167: PPipeDestroyed 1 if (1) { - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("ForcefieldDisabled")); aPortalRenderSet(0, 0, Room_indexes[8], 1); // Increment the script action counter @@ -6176,7 +5977,7 @@ int16_t CustomObjectScript_096B::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[0], Object_handles[12], 1.000000f); aSoundPlayObject(Sound_indexes[0], Object_handles[13], 1.000000f); aSoundPlayObject(Sound_indexes[0], Object_handles[14], 1.000000f); - aShowHUDMessage(Message_strings[14]); + aShowHUDMessage(TXT("All6Deactive")); aObjPlayAnim(Object_handles[14], 1, 3, 2.000000f, 1); aObjPlayAnim(Object_handles[13], 1, 3, 2.000000f, 1); aObjPlayAnim(Object_handles[12], 1, 3, 2.000000f, 1); @@ -6207,7 +6008,7 @@ int16_t CustomObjectScript_0969::CallEvent(int event, tOSIRISEventInfo *data) { // Script 168: PPipeDestroyed 2 if (1) { - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("ForcefieldDisabled")); aPortalRenderSet(0, 0, Room_indexes[7], 1); // Increment the script action counter @@ -6229,7 +6030,7 @@ int16_t CustomObjectScript_1A7F::CallEvent(int event, tOSIRISEventInfo *data) { aPortalRenderSet(0, 0, Room_indexes[9], 1); aObjPlayAnim(data->me_handle, 0, 4, 2.000000f, 0); aSoundPlayObject(Sound_indexes[3], data->me_handle, 1.000000f); - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("ForcefieldDisabled")); // Increment the script action counter if (ScriptActionCtr_026 < MAX_ACTION_CTR_VALUE) @@ -6250,7 +6051,7 @@ int16_t CustomObjectScript_227E::CallEvent(int event, tOSIRISEventInfo *data) { aPortalRenderSet(0, 1, Room_indexes[9], 1); aObjPlayAnim(data->me_handle, 0, 4, 2.000000f, 0); aSoundPlayObject(Sound_indexes[3], data->me_handle, 1.000000f); - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("ForcefieldDisabled")); // Increment the script action counter if (ScriptActionCtr_025 < MAX_ACTION_CTR_VALUE) @@ -6304,7 +6105,7 @@ int16_t TriggerScript_0008::CallEvent(int event, tOSIRISEventInfo *data) { // Script 122: WayPoint-1 if ((ScriptActionCtr_122 < 1) && (1)) { - aCinematicSimple(Path_indexes[2], Message_strings[1], Object_handles[55], 10.000000f, 1); + aCinematicSimple(Path_indexes[2], TXT("FirstCamera"), Object_handles[55], 10.000000f, 1); aSetObjectTimer(Object_handles[55], 14.000000f, -1); aSetWaypoint(1); @@ -6390,7 +6191,7 @@ int16_t TriggerScript_0002::CallEvent(int event, tOSIRISEventInfo *data) { 3.000000f, 25.000000f, 0, -1); aTurnOnSpew(Object_handles[123], -1, 16, 0.000000f, 0.000000f, 65536, 0, 1.400000f, 0.070000f, 30.000000f, 3.000000f, 25.000000f, 0, -1); - aStartEndlevelSequencePath(Path_indexes[6], Path_indexes[7], 8.000000f, Message_strings[9]); + aStartEndlevelSequencePath(Path_indexes[6], Path_indexes[7], 8.000000f, TXT("GotHim")); // Increment the script action counter if (ScriptActionCtr_119 < MAX_ACTION_CTR_VALUE) @@ -6474,7 +6275,7 @@ int16_t TriggerScript_0009::CallEvent(int event, tOSIRISEventInfo *data) { aDoorLockUnlock(0, Door_handles[14]); aDoorLockUnlock(0, Door_handles[9]); aSoundPlaySteaming("VoxLev11SpecificC.osf", 1.000000f); - aShowHUDMessage(Message_strings[11]); + aShowHUDMessage(TXT("GoUpLeft")); // Increment the script action counter if (ScriptActionCtr_128 < MAX_ACTION_CTR_VALUE) @@ -6493,7 +6294,7 @@ int16_t TriggerScript_0024::CallEvent(int event, tOSIRISEventInfo *data) { // Script 156: PipeDemo 2 if ((ScriptActionCtr_156 < 1) && ((qObjExists(Object_handles[3]) == true) && ((ScriptActionCtr_132 > 0) == false))) { - aCinematicSimple(Path_indexes[8], Message_strings[12], Object_handles[3], 10.000000f, 1); + aCinematicSimple(Path_indexes[8], TXT("PipeDemo"), Object_handles[3], 10.000000f, 1); // Increment the script action counter if (ScriptActionCtr_156 < MAX_ACTION_CTR_VALUE) @@ -6512,7 +6313,7 @@ int16_t TriggerScript_000B::CallEvent(int event, tOSIRISEventInfo *data) { // Script 132: PipeDemo 1 if ((ScriptActionCtr_132 < 1) && ((qObjExists(Object_handles[3]) == true) && ((ScriptActionCtr_156 > 0) == false))) { - aCinematicSimple(Path_indexes[8], Message_strings[12], Object_handles[3], 10.000000f, 1); + aCinematicSimple(Path_indexes[8], TXT("PipeDemo"), Object_handles[3], 10.000000f, 1); // Increment the script action counter if (ScriptActionCtr_132 < MAX_ACTION_CTR_VALUE) @@ -6944,7 +6745,7 @@ int16_t TriggerScript_0026::CallEvent(int event, tOSIRISEventInfo *data) { // Script 170: Prison Cinema if ((ScriptActionCtr_170 < 1) && (1)) { - aCinematicSimple(Path_indexes[9], Message_strings[15], Object_handles[13], 10.000000f, 1); + aCinematicSimple(Path_indexes[9], TXT("DestroyThese"), Object_handles[13], 10.000000f, 1); // Increment the script action counter if (ScriptActionCtr_170 < MAX_ACTION_CTR_VALUE) diff --git a/scripts/Level11_FRN.msg b/scripts/level11_FRN.msg similarity index 100% rename from scripts/Level11_FRN.msg rename to scripts/level11_FRN.msg diff --git a/scripts/level11_Ger.msg b/scripts/level11_GER.msg similarity index 100% rename from scripts/level11_Ger.msg rename to scripts/level11_GER.msg diff --git a/scripts/Level11_ITN.msg b/scripts/level11_ITN.msg similarity index 100% rename from scripts/Level11_ITN.msg rename to scripts/level11_ITN.msg diff --git a/scripts/level13.cpp b/scripts/level13.cpp index 478db75ef..5fe8069c7 100644 --- a/scripts/level13.cpp +++ b/scripts/level13.cpp @@ -22,10 +22,10 @@ // Filename: level13.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -1297,180 +1297,12 @@ void RestoreGlobalActionCtrs(void *file_ptr) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} +std::map Messages; -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -1646,17 +1478,6 @@ const char *Goal_names[NUM_GOAL_NAMES] = {"ShutdownEngineCore", "Disable Aft Mat "Eliminate Remaining StormTroopers", "Reduce Infected Robot Threat"}; int Goal_indexes[NUM_GOAL_NAMES]; -#define NUM_MESSAGE_NAMES 39 -const char *Message_names[NUM_MESSAGE_NAMES] = { - "PplDoors1", "Bay62Lance", "EngineDown", "NoEntry", "EngineMisfire", "SecondaryObjective", - "EngineTakover", "PrimerDamage", "CoreRads", "LevelObjA", "NoEntry62", "CoreInfo2", - "CoreInfo1", "BayInfoGame", "BayInfoHud", "MainDeckGame", "MainDeckHud", "Bay62Game", - "Bay62Hud", "ShipInfo2", "ShipInfo1", "AftMatcenCheck", "AuxCoreDoor", "CoreAccFF", - "EndMission", "GotReconInterface", "RobotCount", "EndCine", "LevelObjtives1", "LevelObjtives2", - "LevelObjtives3", "LeaderTaunt1", "LeaderTaunt2", "LeaderTaunt3", "LeaderTaunt4", "LeaderTaunt5", - "IntroText", "Bay62Fuse", "SpyPlead"}; -const char *Message_strings[NUM_MESSAGE_NAMES]; - // =============== // InitializeDLL() // =============== @@ -1670,7 +1491,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; @@ -1678,14 +1498,7 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { if (func_list->script_identifier != NULL) { _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "level13.msg"); @@ -1736,10 +1549,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } @@ -2860,7 +2669,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 062: IntroLevel if ((ScriptActionCtr_062 < 1) && (1)) { - aCinematicIntro(Path_indexes[10], Message_strings[36], Object_handles[75], Path_indexes[11], 20.000000f); + aCinematicIntro(Path_indexes[10], TXT("IntroText"), Object_handles[75], Path_indexes[11], 20.000000f); // Increment the script action counter if (ScriptActionCtr_062 < MAX_ACTION_CTR_VALUE) @@ -2922,9 +2731,9 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { if ((2 == event_data->id) && (qObjExists(Object_handles[16]) == true) && (qUserFlag(0) == false)) { aMiscViewerShake(100.000000f); aSetLevelTimer(1.000000f, 0); - aShowColoredHUDMessage(255, 0, 0, Message_strings[4]); + aShowColoredHUDMessage(255, 0, 0, TXT("EngineMisfire")); aCreatePopupView(0, Object_handles[17], 8.000000f, 1.000000f); - aAddGameMessage(Message_strings[5], Message_strings[6]); + aAddGameMessage(TXT("SecondaryObjective"), TXT("EngineTakover")); aGoalEnableDisable(1, Goal_indexes[0]); // Increment the script action counter @@ -2955,7 +2764,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { qObjCountTypeID(2, "stormtroopergreen")) <= 3) { aGoalCompleted(Goal_indexes[3], 1); aGoalCompleted(Goal_indexes[4], 1); - aShowColoredHUDMessage(0, 255, 232, Message_strings[24]); + aShowColoredHUDMessage(0, 255, 232, TXT("EndMission")); aSetLevelTimer(10.000000f, 6); } else { aSetLevelTimer(2.000000f, 5); @@ -2968,7 +2777,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 053: End level Timer if (event_data->id == 6) { - aStartEndlevelSequencePath(Path_indexes[1], Path_indexes[2], 9.000000f, Message_strings[27]); + aStartEndlevelSequencePath(Path_indexes[1], Path_indexes[2], 9.000000f, TXT("EndCine")); // Increment the script action counter if (ScriptActionCtr_053 < MAX_ACTION_CTR_VALUE) @@ -3019,7 +2828,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 049: Start Level Objectives Messege if ((ScriptActionCtr_049 < 1) && (1)) { - aCinematicSimple(Path_indexes[7], Message_strings[28], Object_handles[30], 10.000000f, 1); + aCinematicSimple(Path_indexes[7], TXT("LevelObjtives1"), Object_handles[30], 10.000000f, 1); // Increment the script action counter if (ScriptActionCtr_049 < MAX_ACTION_CTR_VALUE) @@ -3037,7 +2846,7 @@ int16_t CustomObjectScript_1074::CallEvent(int event, tOSIRISEventInfo *data) { // Script 001: Bay 62 Fusable Link if ((ScriptActionCtr_001 < 1) && (qObjIsPlayerWeapon(event_data->it_handle) == true)) { - aShowHUDMessage(Message_strings[1]); + aShowHUDMessage(TXT("Bay62Lance")); aObjDestroy(data->me_handle); aAISetState(0, Object_handles[1]); aAISetState(0, Object_handles[2]); @@ -3061,7 +2870,7 @@ int16_t CustomObjectScript_0878::CallEvent(int event, tOSIRISEventInfo *data) { aObjPlayAnim(data->me_handle, 0, 2, 2.000000f, 0); if (((ScriptActionCtr_006 > 0) == true) && ((ScriptActionCtr_011 > 0) == true)) { aSetLevelTimer(0.000000f, 3); - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("EngineDown")); } // Increment the script action counter @@ -3083,7 +2892,7 @@ int16_t CustomObjectScript_0877::CallEvent(int event, tOSIRISEventInfo *data) { aObjPlayAnim(data->me_handle, 0, 2, 2.000000f, 0); if (((ScriptActionCtr_006 > 0) == true) && ((ScriptActionCtr_012 > 0) == true)) { aSetLevelTimer(0.000000f, 3); - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("EngineDown")); } // Increment the script action counter @@ -3105,7 +2914,7 @@ int16_t CustomObjectScript_0879::CallEvent(int event, tOSIRISEventInfo *data) { aObjPlayAnim(data->me_handle, 0, 2, 2.000000f, 0); if (((ScriptActionCtr_011 > 0) == true) && ((ScriptActionCtr_012 > 0) == true)) { aSetLevelTimer(0.000000f, 3); - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("EngineDown")); } // Increment the script action counter @@ -3124,7 +2933,7 @@ int16_t CustomObjectScript_6813::CallEvent(int event, tOSIRISEventInfo *data) { // Script 021: NonPlayer Entry if (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("NoEntry")); // Increment the script action counter if (ScriptActionCtr_021 < MAX_ACTION_CTR_VALUE) @@ -3144,7 +2953,7 @@ int16_t CustomObjectScript_083A::CallEvent(int event, tOSIRISEventInfo *data) { // Script 008: NonPlayer Entry if (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("NoEntry")); // Increment the script action counter if (ScriptActionCtr_008 < MAX_ACTION_CTR_VALUE) @@ -3262,7 +3071,7 @@ int16_t CustomObjectScript_9021::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_031 < 1) && (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true)) { aGoalCompleted(Goal_indexes[1], 1); aObjPlayAnim(data->me_handle, 0, 2, 1.000000f, 0); - aShowColoredHUDMessage(0, 150, 255, Message_strings[9]); + aShowColoredHUDMessage(0, 150, 255, TXT("LevelObjA")); aMatcenSetValues(Matcen_indexes[0], 0, 1.000000f, 1); aMatcenSetValues(Matcen_indexes[1], 0, 1.000000f, 1); aMatcenSetValues(Matcen_indexes[2], 0, 1.000000f, 1); @@ -3277,7 +3086,7 @@ int16_t CustomObjectScript_9021::CallEvent(int event, tOSIRISEventInfo *data) { // Script 056: Start Level Objectives Messege 2 if ((ScriptActionCtr_056 < 1) && (1)) { - aCinematicSimple(Path_indexes[8], Message_strings[29], Object_handles[16], 10.000000f, 1); + aCinematicSimple(Path_indexes[8], TXT("LevelObjtives2"), Object_handles[16], 10.000000f, 1); // Increment the script action counter if (ScriptActionCtr_056 < MAX_ACTION_CTR_VALUE) @@ -3295,7 +3104,7 @@ int16_t CustomObjectScript_282A::CallEvent(int event, tOSIRISEventInfo *data) { // Script 024: NonPlayer Entry if (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("NoEntry")); // Increment the script action counter if (ScriptActionCtr_024 < MAX_ACTION_CTR_VALUE) @@ -3315,7 +3124,7 @@ int16_t CustomObjectScript_0838::CallEvent(int event, tOSIRISEventInfo *data) { // Script 018: NonPlayer Entry if (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("NoEntry")); // Increment the script action counter if (ScriptActionCtr_018 < MAX_ACTION_CTR_VALUE) @@ -3335,7 +3144,7 @@ int16_t CustomObjectScript_083D::CallEvent(int event, tOSIRISEventInfo *data) { // Script 037: NonPlayer Entry if (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("NoEntry")); // Increment the script action counter if (ScriptActionCtr_037 < MAX_ACTION_CTR_VALUE) @@ -3355,7 +3164,7 @@ int16_t CustomObjectScript_084E::CallEvent(int event, tOSIRISEventInfo *data) { // Script 038: NonPlayer Entry if (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("NoEntry")); // Increment the script action counter if (ScriptActionCtr_038 < MAX_ACTION_CTR_VALUE) @@ -3375,7 +3184,7 @@ int16_t CustomObjectScript_085F::CallEvent(int event, tOSIRISEventInfo *data) { // Script 039: NonPlayer Entry if (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("NoEntry")); // Increment the script action counter if (ScriptActionCtr_039 < MAX_ACTION_CTR_VALUE) @@ -3395,7 +3204,7 @@ int16_t CustomObjectScript_085D::CallEvent(int event, tOSIRISEventInfo *data) { // Script 042: NonPlayer Entry if (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("NoEntry")); // Increment the script action counter if (ScriptActionCtr_042 < MAX_ACTION_CTR_VALUE) @@ -3415,7 +3224,7 @@ int16_t CustomObjectScript_085A::CallEvent(int event, tOSIRISEventInfo *data) { // Script 043: NonPlayer Entry if (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("NoEntry")); // Increment the script action counter if (ScriptActionCtr_043 < MAX_ACTION_CTR_VALUE) @@ -3435,7 +3244,7 @@ int16_t CustomObjectScript_0844::CallEvent(int event, tOSIRISEventInfo *data) { // Script 044: NonPlayer Entry if (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("NoEntry")); // Increment the script action counter if (ScriptActionCtr_044 < MAX_ACTION_CTR_VALUE) @@ -3455,7 +3264,7 @@ int16_t CustomObjectScript_0835::CallEvent(int event, tOSIRISEventInfo *data) { // Script 045: NonPlayer Entry if (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("NoEntry")); // Increment the script action counter if (ScriptActionCtr_045 < MAX_ACTION_CTR_VALUE) @@ -3475,7 +3284,7 @@ int16_t CustomObjectScript_1816::CallEvent(int event, tOSIRISEventInfo *data) { // Script 063: NonPlayer Entry if (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("NoEntry")); // Increment the script action counter if (ScriptActionCtr_063 < MAX_ACTION_CTR_VALUE) @@ -3495,7 +3304,7 @@ int16_t CustomObjectScript_0825::CallEvent(int event, tOSIRISEventInfo *data) { // Script 066: NonPlayer Entry if (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("NoEntry")); // Increment the script action counter if (ScriptActionCtr_066 < MAX_ACTION_CTR_VALUE) @@ -3515,7 +3324,7 @@ int16_t CustomObjectScript_084B::CallEvent(int event, tOSIRISEventInfo *data) { // Script 120: NonPlayer Entry if (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("NoEntry")); // Increment the script action counter if (ScriptActionCtr_120 < MAX_ACTION_CTR_VALUE) @@ -3535,7 +3344,7 @@ int16_t CustomObjectScript_0839::CallEvent(int event, tOSIRISEventInfo *data) { // Script 003: NonPlayer Entry if (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("NoEntry")); // Increment the script action counter if (ScriptActionCtr_003 < MAX_ACTION_CTR_VALUE) @@ -3556,7 +3365,7 @@ int16_t CustomObjectScript_1847::CallEvent(int event, tOSIRISEventInfo *data) { // Script 025: NonPlayer Entry - 62 Acc Door if (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) { aSoundPlayObject(Sound_indexes[1], Object_handles[45], 1.000000f); - aShowHUDMessage(Message_strings[10]); + aShowHUDMessage(TXT("NoEntry62")); // Increment the script action counter if (ScriptActionCtr_025 < MAX_ACTION_CTR_VALUE) @@ -3577,7 +3386,7 @@ int16_t CustomObjectScript_10C6::CallEvent(int event, tOSIRISEventInfo *data) { // Script 030: Core Hall Data Link if ((ScriptActionCtr_030 < 1) && (qObjIsPlayer(event_data->it_handle) == true)) { aObjPlayAnim(data->me_handle, 0, 10, 3.000000f, 0); - aAddGameMessage(Message_strings[11], Message_strings[12]); + aAddGameMessage(TXT("CoreInfo2"), TXT("CoreInfo1")); // Increment the script action counter if (ScriptActionCtr_030 < MAX_ACTION_CTR_VALUE) @@ -3596,7 +3405,7 @@ int16_t CustomObjectScript_11F6::CallEvent(int event, tOSIRISEventInfo *data) { // Script 085: Bay 36 Data Link if ((ScriptActionCtr_085 < 1) && (qObjIsPlayer(event_data->it_handle) == true)) { aObjPlayAnim(data->me_handle, 0, 10, 3.000000f, 0); - aAddGameMessage(Message_strings[13], Message_strings[14]); + aAddGameMessage(TXT("BayInfoGame"), TXT("BayInfoHud")); // Increment the script action counter if (ScriptActionCtr_085 < MAX_ACTION_CTR_VALUE) @@ -3615,7 +3424,7 @@ int16_t CustomObjectScript_0A24::CallEvent(int event, tOSIRISEventInfo *data) { // Script 087: Main Deck Data Link if ((ScriptActionCtr_087 < 1) && (qObjIsPlayer(event_data->it_handle) == true)) { aObjPlayAnim(data->me_handle, 0, 10, 3.000000f, 0); - aAddGameMessage(Message_strings[15], Message_strings[16]); + aAddGameMessage(TXT("MainDeckGame"), TXT("MainDeckHud")); // Increment the script action counter if (ScriptActionCtr_087 < MAX_ACTION_CTR_VALUE) @@ -3634,7 +3443,7 @@ int16_t CustomObjectScript_0A23::CallEvent(int event, tOSIRISEventInfo *data) { // Script 086: Bay 62 Data Link if ((ScriptActionCtr_086 < 1) && (qObjIsPlayer(event_data->it_handle) == true)) { aObjPlayAnim(data->me_handle, 0, 10, 3.000000f, 0); - aAddGameMessage(Message_strings[17], Message_strings[18]); + aAddGameMessage(TXT("Bay62Game"), TXT("Bay62Hud")); // Increment the script action counter if (ScriptActionCtr_086 < MAX_ACTION_CTR_VALUE) @@ -3653,7 +3462,7 @@ int16_t CustomObjectScript_18A0::CallEvent(int event, tOSIRISEventInfo *data) { // Script 077: Aft Matcen Data Link if ((ScriptActionCtr_077 < 1) && (qObjIsPlayer(event_data->it_handle) == true)) { aObjPlayAnim(data->me_handle, 0, 10, 3.000000f, 0); - aAddGameMessage(Message_strings[19], Message_strings[20]); + aAddGameMessage(TXT("ShipInfo2"), TXT("ShipInfo1")); // Increment the script action counter if (ScriptActionCtr_077 < MAX_ACTION_CTR_VALUE) @@ -3672,7 +3481,7 @@ int16_t CustomObjectScript_1090::CallEvent(int event, tOSIRISEventInfo *data) { // Script 033: Stern Data Link if ((ScriptActionCtr_033 < 1) && (qObjIsPlayer(event_data->it_handle) == true)) { aObjPlayAnim(data->me_handle, 0, 10, 3.000000f, 0); - aCinematicSimple(Path_indexes[0], Message_strings[21], Object_handles[30], 8.000000f, 1); + aCinematicSimple(Path_indexes[0], TXT("AftMatcenCheck"), Object_handles[30], 8.000000f, 1); // Increment the script action counter if (ScriptActionCtr_033 < MAX_ACTION_CTR_VALUE) @@ -3867,8 +3676,8 @@ int16_t CustomObjectScript_295F::CallEvent(int event, tOSIRISEventInfo *data) { // Script 069: Leader Taunt Cam if ((ScriptActionCtr_069 < 1) && (qObjIsPlayer(event_data->it_handle) == true)) { - aShowHUDMessage(Message_strings[33]); - aShowHUDMessage(Message_strings[34]); + aShowHUDMessage(TXT("LeaderTaunt3")); + aShowHUDMessage(TXT("LeaderTaunt4")); // Increment the script action counter if (ScriptActionCtr_069 < MAX_ACTION_CTR_VALUE) @@ -3906,7 +3715,7 @@ int16_t CustomObjectScript_2023::CallEvent(int event, tOSIRISEventInfo *data) { // Script 034: Aux Core Access if ((ScriptActionCtr_034 < 1) && ((qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) && (qUserFlag(0) == false))) { - aShowHUDMessage(Message_strings[22]); + aShowHUDMessage(TXT("AuxCoreDoor")); // Increment the script action counter if (ScriptActionCtr_034 < MAX_ACTION_CTR_VALUE) @@ -3965,7 +3774,7 @@ int16_t CustomObjectScript_30C7::CallEvent(int event, tOSIRISEventInfo *data) { // Script 073: Start Level Objectives Messege 3 if ((ScriptActionCtr_073 < 1) && (1)) { aSoundPlaySteaming("VoxL13StartLevel.osf", 1.000000f); - aCinematicSimple(Path_indexes[9], Message_strings[30], Object_handles[65], 10.000000f, 1); + aCinematicSimple(Path_indexes[9], TXT("LevelObjtives3"), Object_handles[65], 10.000000f, 1); // Increment the script action counter if (ScriptActionCtr_073 < MAX_ACTION_CTR_VALUE) @@ -3983,7 +3792,7 @@ int16_t CustomObjectScript_0A5C::CallEvent(int event, tOSIRISEventInfo *data) { // Script 089: Picked Up Recon Interface if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[25], event_data->it_handle); + aShowHUDMessageObj(TXT("GotReconInterface"), event_data->it_handle); aSoundPlayObject(Sound_indexes[2], event_data->it_handle, 1.000000f); aAddObjectToInventory(data->me_handle, event_data->it_handle, 0); @@ -3999,7 +3808,7 @@ int16_t CustomObjectScript_0A5C::CallEvent(int event, tOSIRISEventInfo *data) { if (qObjIsPlayer(event_data->it_handle) == true) { aObjGhostSet(0, data->me_handle); aAddObjectToInventory(data->me_handle, event_data->it_handle, 0); - aShowHUDMessageI(Message_strings[26], qMathAddInt(qMathAddInt(qObjCountTypeID(2, "stormtrooperred"), + aShowHUDMessageI(TXT("RobotCount"), qMathAddInt(qMathAddInt(qObjCountTypeID(2, "stormtrooperred"), qObjCountTypeID(2, "stormtroopergreen")), qObjCountTypeID(2, "stormtrooperwhite"))); aSoundPlay2D(Sound_indexes[3], 1.000000f); @@ -4020,8 +3829,8 @@ int16_t CustomObjectScript_1134::CallEvent(int event, tOSIRISEventInfo *data) { // Script 058: Leader Taunt Cam if ((ScriptActionCtr_058 < 2) && (qObjIsPlayer(event_data->it_handle) == true)) { - aShowHUDMessage(Message_strings[31]); - aShowHUDMessage(Message_strings[32]); + aShowHUDMessage(TXT("LeaderTaunt1")); + aShowHUDMessage(TXT("LeaderTaunt2")); // Increment the script action counter if (ScriptActionCtr_058 < MAX_ACTION_CTR_VALUE) @@ -4039,8 +3848,8 @@ int16_t CustomObjectScript_0887::CallEvent(int event, tOSIRISEventInfo *data) { // Script 059: Leader Taunt Cam if ((ScriptActionCtr_059 < 2) && (qObjIsPlayer(event_data->it_handle) == true)) { - aShowHUDMessage(Message_strings[33]); - aShowHUDMessage(Message_strings[34]); + aShowHUDMessage(TXT("LeaderTaunt3")); + aShowHUDMessage(TXT("LeaderTaunt4")); // Increment the script action counter if (ScriptActionCtr_059 < MAX_ACTION_CTR_VALUE) @@ -4058,8 +3867,8 @@ int16_t CustomObjectScript_095B::CallEvent(int event, tOSIRISEventInfo *data) { // Script 068: Leader Taunt Cam if ((ScriptActionCtr_068 < 4) && (qObjIsPlayer(event_data->it_handle) == true)) { - aShowHUDMessage(Message_strings[33]); - aShowHUDMessage(Message_strings[34]); + aShowHUDMessage(TXT("LeaderTaunt3")); + aShowHUDMessage(TXT("LeaderTaunt4")); // Increment the script action counter if (ScriptActionCtr_068 < MAX_ACTION_CTR_VALUE) @@ -4077,8 +3886,8 @@ int16_t CustomObjectScript_295E::CallEvent(int event, tOSIRISEventInfo *data) { // Script 070: Leader Taunt Cam if ((ScriptActionCtr_070 < 2) && (qObjIsPlayer(event_data->it_handle) == true)) { - aShowHUDMessage(Message_strings[31]); - aShowHUDMessage(Message_strings[33]); + aShowHUDMessage(TXT("LeaderTaunt1")); + aShowHUDMessage(TXT("LeaderTaunt3")); // Increment the script action counter if (ScriptActionCtr_070 < MAX_ACTION_CTR_VALUE) @@ -4096,7 +3905,7 @@ int16_t CustomObjectScript_09F0::CallEvent(int event, tOSIRISEventInfo *data) { // Script 071: Leader Taunt Cam if ((ScriptActionCtr_071 < 2) && (qObjIsPlayer(event_data->it_handle) == true)) { - aShowHUDMessage(Message_strings[33]); + aShowHUDMessage(TXT("LeaderTaunt3")); // Increment the script action counter if (ScriptActionCtr_071 < MAX_ACTION_CTR_VALUE) @@ -4114,8 +3923,8 @@ int16_t CustomObjectScript_09D3::CallEvent(int event, tOSIRISEventInfo *data) { // Script 060: Leader Taunt Cam if ((ScriptActionCtr_060 < 1) && (qObjIsPlayer(event_data->it_handle) == true)) { - aShowHUDMessage(Message_strings[31]); - aShowHUDMessage(Message_strings[34]); + aShowHUDMessage(TXT("LeaderTaunt1")); + aShowHUDMessage(TXT("LeaderTaunt4")); // Increment the script action counter if (ScriptActionCtr_060 < MAX_ACTION_CTR_VALUE) @@ -4133,7 +3942,7 @@ int16_t CustomObjectScript_087D::CallEvent(int event, tOSIRISEventInfo *data) { // Script 067: Leader Taunt Cam if ((ScriptActionCtr_067 < 2) && (qObjIsPlayer(event_data->it_handle) == true)) { - aShowHUDMessage(Message_strings[33]); + aShowHUDMessage(TXT("LeaderTaunt3")); // Increment the script action counter if (ScriptActionCtr_067 < MAX_ACTION_CTR_VALUE) @@ -4151,7 +3960,7 @@ int16_t CustomObjectScript_0869::CallEvent(int event, tOSIRISEventInfo *data) { // Script 048: Leader Taunt Cam if ((ScriptActionCtr_048 < 1) && (qObjIsPlayer(event_data->it_handle) == true)) { - aShowHUDMessage(Message_strings[35]); + aShowHUDMessage(TXT("LeaderTaunt5")); // Increment the script action counter if (ScriptActionCtr_048 < MAX_ACTION_CTR_VALUE) @@ -4169,8 +3978,8 @@ int16_t CustomObjectScript_09F9::CallEvent(int event, tOSIRISEventInfo *data) { // Script 057: Leader Taunt Cam if ((ScriptActionCtr_057 < 1) && (qObjIsPlayer(event_data->it_handle) == true)) { - aShowHUDMessage(Message_strings[31]); - aShowHUDMessage(Message_strings[32]); + aShowHUDMessage(TXT("LeaderTaunt1")); + aShowHUDMessage(TXT("LeaderTaunt2")); // Increment the script action counter if (ScriptActionCtr_057 < MAX_ACTION_CTR_VALUE) @@ -4190,7 +3999,7 @@ int16_t CustomObjectScript_193B::CallEvent(int event, tOSIRISEventInfo *data) { if (qObjIsPlayerWeapon(event_data->it_handle) == true) { aMatcenSetEnableState(0, Matcen_indexes[3]); aMatcenSetEnableState(0, Matcen_indexes[6]); - aShowHUDMessage(Message_strings[37]); + aShowHUDMessage(TXT("Bay62Fuse")); aObjDestroy(data->me_handle); // Increment the script action counter @@ -4234,7 +4043,7 @@ int16_t CustomObjectScript_0A08::CallEvent(int event, tOSIRISEventInfo *data) { // Script 083: SpyHunter_Plead if (qObjIsPlayer(event_data->it_handle) == true) { aAISetMode(data->me_handle, 1); - aShowHUDMessage(Message_strings[38]); + aShowHUDMessage(TXT("SpyPlead")); // Increment the script action counter if (ScriptActionCtr_083 < MAX_ACTION_CTR_VALUE) @@ -4473,7 +4282,7 @@ int16_t TriggerScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 036: Personell Acc Doors if (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) { - aShowColoredHUDMessage(100, 100, 255, Message_strings[0]); + aShowColoredHUDMessage(100, 100, 255, TXT("PplDoors1")); // Increment the script action counter if (ScriptActionCtr_036 < MAX_ACTION_CTR_VALUE) @@ -4491,7 +4300,7 @@ int16_t TriggerScript_000B::CallEvent(int event, tOSIRISEventInfo *data) { // Script 017: Personell Acc Doors if (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) { - aShowColoredHUDMessage(100, 100, 255, Message_strings[0]); + aShowColoredHUDMessage(100, 100, 255, TXT("PplDoors1")); // Increment the script action counter if (ScriptActionCtr_017 < MAX_ACTION_CTR_VALUE) @@ -4509,7 +4318,7 @@ int16_t TriggerScript_0005::CallEvent(int event, tOSIRISEventInfo *data) { // Script 078: Personell Acc Doors if (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) { - aShowColoredHUDMessage(100, 100, 255, Message_strings[0]); + aShowColoredHUDMessage(100, 100, 255, TXT("PplDoors1")); // Increment the script action counter if (ScriptActionCtr_078 < MAX_ACTION_CTR_VALUE) @@ -4527,7 +4336,7 @@ int16_t TriggerScript_000C::CallEvent(int event, tOSIRISEventInfo *data) { // Script 000: Personell Acc Doors if (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) { - aShowColoredHUDMessage(100, 100, 255, Message_strings[0]); + aShowColoredHUDMessage(100, 100, 255, TXT("PplDoors1")); // Increment the script action counter if (ScriptActionCtr_000 < MAX_ACTION_CTR_VALUE) @@ -4546,7 +4355,7 @@ int16_t TriggerScript_0002::CallEvent(int event, tOSIRISEventInfo *data) { // Script 015: PrimerDamage if (qObjIsPlayer(event_data->it_handle) == true) { aObjApplyDamage(event_data->it_handle, 33.330002f); - aShowHUDMessage(Message_strings[7]); + aShowHUDMessage(TXT("PrimerDamage")); // Increment the script action counter if (ScriptActionCtr_015 < MAX_ACTION_CTR_VALUE) @@ -4567,7 +4376,7 @@ int16_t TriggerScript_0004::CallEvent(int event, tOSIRISEventInfo *data) { // Script 020: CoreRoom Microwave Effect if ((ScriptActionCtr_020 < 15) && (qObjIsPlayer(event_data->it_handle) == true)) { aObjDeform(event_data->it_handle, 0.300000f, 2.500000f); - aShowColoredHUDMessage(255, 25, 0, Message_strings[8]); + aShowColoredHUDMessage(255, 25, 0, TXT("CoreRads")); aObjApplyDamage(event_data->it_handle, 5.000000f); // Increment the script action counter @@ -4604,7 +4413,7 @@ int16_t TriggerScript_000A::CallEvent(int event, tOSIRISEventInfo *data) { // Script 047: Core Acc Forcefield if ((ScriptActionCtr_047 < 1) && (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true)) { - aShowHUDMessage(Message_strings[23]); + aShowHUDMessage(TXT("CoreAccFF")); // Increment the script action counter if (ScriptActionCtr_047 < MAX_ACTION_CTR_VALUE) diff --git a/scripts/Level13_FRN.msg b/scripts/level13_FRN.msg similarity index 100% rename from scripts/Level13_FRN.msg rename to scripts/level13_FRN.msg diff --git a/scripts/level13_Ger.msg b/scripts/level13_GER.msg similarity index 100% rename from scripts/level13_Ger.msg rename to scripts/level13_GER.msg diff --git a/scripts/Level13_ITN.msg b/scripts/level13_ITN.msg similarity index 100% rename from scripts/Level13_ITN.msg rename to scripts/level13_ITN.msg diff --git a/scripts/level14.cpp b/scripts/level14.cpp index c82bd9c4f..cc5c65489 100644 --- a/scripts/level14.cpp +++ b/scripts/level14.cpp @@ -22,10 +22,10 @@ // Filename: level14.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -837,180 +837,12 @@ void aUpdateBypassConnDisplay(const char *text, int level) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} +std::map Messages; -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -1147,64 +979,6 @@ const char *Goal_names[NUM_GOAL_NAMES] = {"Find Three Bypass Connectors", "Broadcast the Anti-Virus Program"}; int Goal_indexes[NUM_GOAL_NAMES]; -#define NUM_MESSAGE_NAMES 55 -const char *Message_names[NUM_MESSAGE_NAMES] = {"IntroText", - "Empty", - "BypassConnDisplay", - "PowerOffline", - "PowerOnline", - "FoundAllBypassConns", - "FoundBypassConn", - "FoundEquipRmKey", - "DataLinkAlreadyActive", - "DataLinkFixed", - "SystemStarting", - "DataLinkError", - "GotCoreMaterial", - "UploadStarted", - "UploadError", - "UseCoreMaterialFailed", - "SystemStarted", - "OmnicronDisplayed", - "BumpDialError", - "DialCodeEntered", - "DialCodeIncorrect", - "DialSwitchError", - "ShieldCodeSeqStart", - "ShieldCodeSeqReset", - "ShieldDeactivated", - "ShieldCodeIncorrect", - "ShuttleFreed", - "BeamIgnited", - "BeamIgniteError6", - "BeamIgniteError5", - "BeamIgniteError4", - "BeamIgniteError3", - "BeamIgniteError2", - "BeamIgniteError1", - "LensRobotWarning", - "LensDestroyed", - "GotSpareLens", - "UseLensCompleted", - "UseLensFailed2", - "UseLensFailed1", - "MirrorNodesUnaligned", - "PowerInsufficient", - "TransmissionComplete", - "JournalBeamGame", - "JournalBeamHUD", - "JournalShieldGame", - "JournalShieldHUD", - "JournalVirusGame", - "JournalVirusHUD", - "JournalPowerGame", - "JournalPowerHUD", - "JournalRobotGame", - "JournalRobotHUD", - "JournalDialGame", - "JournalDialHUD"}; -const char *Message_strings[NUM_MESSAGE_NAMES]; - // =============== // InitializeDLL() // =============== @@ -1218,26 +992,16 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "level14.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { mprintf(0, "ERROR: Could not load message file - %s\n", filename); @@ -1284,10 +1048,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } @@ -1800,9 +1560,9 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { if (qUserVarValue(0) != qUserVarValue(12)) { aUserVarSet(12, qUserVarValue(0)); if (qUserVarValue(12) == 0.000000f) { - aUpdateBypassConnDisplay(Message_strings[1], 0); + aUpdateBypassConnDisplay(TXT("Empty"), 0); } else { - aUpdateBypassConnDisplay(Message_strings[2], qUserVarValueInt(12)); + aUpdateBypassConnDisplay(TXT("BypassConnDisplay"), qUserVarValueInt(12)); } // Increment the script action counter @@ -1869,7 +1629,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 038: Level Start - Intro Cinematic if (1 == true) { - aCinematicIntro(Path_indexes[0], Message_strings[0], Object_handles[3], Path_indexes[1], 20.000000f); + aCinematicIntro(Path_indexes[0], TXT("IntroText"), Object_handles[3], Path_indexes[1], 20.000000f); aSoundPlaySteaming("VoxLev14StartLevel.osf", 1.000000f); // Increment the script action counter @@ -1911,7 +1671,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { } if (ScriptActionCtr_008 == 2) { aSetTextureForMonitors(Texture_indexes[2]); - aShowHUDMessage(Message_strings[16]); + aShowHUDMessage(TXT("SystemStarted")); aUserFlagSet(14, 1); aGoalCompleted(Goal_indexes[2], 1); } @@ -1960,7 +1720,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 010: Process System Omnicron Sequence if (event_data->id == 3) { aSetTextureForMonitors(Texture_indexes[10]); - aShowHUDMessage(Message_strings[17]); + aShowHUDMessage(TXT("OmnicronDisplayed")); aUserFlagSet(15, 1); aGoalCompleted(Goal_indexes[3], 1); @@ -1995,7 +1755,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[0], Object_handles[19], 1.000000f); aUserFlagSet(6, 0); } - aShowHUDMessage(Message_strings[23]); + aShowHUDMessage(TXT("ShieldCodeSeqReset")); } // Increment the script action counter @@ -2070,7 +1830,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { } } else { if ((qGoalCompleted(Goal_indexes[6]) == true) && (qUserFlag(17) == false)) { - aShowHUDMessage(Message_strings[40]); + aShowHUDMessage(TXT("MirrorNodesUnaligned")); aGoalCompleted(Goal_indexes[6], 0); } } @@ -2081,7 +1841,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { } else { if ((qGoalEnabled(Goal_indexes[9]) == true) && (qGoalCompleted(Goal_indexes[9]) == true) && (qUserFlag(17) == false)) { - aShowHUDMessage(Message_strings[41]); + aShowHUDMessage(TXT("PowerInsufficient")); aGoalCompleted(Goal_indexes[9], 0); } } @@ -2094,7 +1854,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 040: Transmission Completed if (event_data->id == 6) { if (qObjExists(Object_handles[31]) == true) { - aShowHUDMessage(Message_strings[42]); + aShowHUDMessage(TXT("TransmissionComplete")); aGoalCompleted(Goal_indexes[12], 1); aSetLevelTimer(5.000000f, 9); } @@ -2106,7 +1866,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 046: New Transmission Completed if (event_data->id == 8) { - aShowHUDMessage(Message_strings[42]); + aShowHUDMessage(TXT("TransmissionComplete")); aGoalCompleted(Goal_indexes[12], 1); aSetLevelTimer(5.000000f, 9); @@ -2118,7 +1878,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 047: Start End Level Sequence if (event_data->id == 9) { aGoalCompleted(Goal_indexes[13], 1); - aStartEndlevelSequencePath(Path_indexes[5], Path_indexes[6], 20.000000f, Message_strings[1]); + aStartEndlevelSequencePath(Path_indexes[5], Path_indexes[6], 20.000000f, TXT("Empty")); // Increment the script action counter if (ScriptActionCtr_047 < MAX_ACTION_CTR_VALUE) @@ -2186,7 +1946,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { if (event_data->goal_uid == 1) { aObjKill(qObjSavedHandle(3), 0, 1, 65760, 0.000000f, 0.000000f); aObjDestroy(Object_handles[31]); - aShowHUDMessage(Message_strings[35]); + aShowHUDMessage(TXT("LensDestroyed")); aGoalEnableDisable(1, Goal_indexes[10]); aGoalEnableDisable(1, Goal_indexes[11]); @@ -2203,7 +1963,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aObjSaveHandle(event_data->it_handle, 3); aAIFlags(0, 33554432, event_data->it_handle); aAIGoalFollowPathSimple(event_data->it_handle, Path_indexes[4], 4352, 1, 3); - aShowHUDMessage(Message_strings[34]); + aShowHUDMessage(TXT("LensRobotWarning")); // Increment the script action counter if (ScriptActionCtr_042 < MAX_ACTION_CTR_VALUE) @@ -2223,7 +1983,7 @@ int16_t CustomObjectScript_10B8::CallEvent(int event, tOSIRISEventInfo *data) { if (qObjIsPlayer(event_data->it_handle) == true) { aAddObjectToInventory(data->me_handle, event_data->it_handle, 0); aSoundPlayObject(Sound_indexes[1], event_data->it_handle, 1.000000f); - aShowHUDMessageObj(Message_strings[12], event_data->it_handle); + aShowHUDMessageObj(TXT("GotCoreMaterial"), event_data->it_handle); // Increment the script action counter if (ScriptActionCtr_006 < MAX_ACTION_CTR_VALUE) @@ -2249,37 +2009,37 @@ int16_t CustomObjectScript_10B8::CallEvent(int event, tOSIRISEventInfo *data) { if ((qObjIsPlayer(event_data->it_handle) == true) && (qUserFlag(15) == false)) { if (qObjGetDistance(event_data->it_handle, Object_handles[11]) < 25.000000f) { if (qUserFlag(14) == true) { - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("UploadStarted")); aSetLevelTimer(0.100000f, 2); } else { aObjGhostSet(0, data->me_handle); aAddObjectToInventory(data->me_handle, event_data->it_handle, 0); - aShowHUDMessage(Message_strings[14]); + aShowHUDMessage(TXT("UploadError")); } } else { if (qObjGetDistance(event_data->it_handle, Object_handles[12]) < 25.000000f) { if (qUserFlag(14) == true) { - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("UploadStarted")); aSetLevelTimer(0.100000f, 2); } else { aObjGhostSet(0, data->me_handle); aAddObjectToInventory(data->me_handle, event_data->it_handle, 0); - aShowHUDMessage(Message_strings[14]); + aShowHUDMessage(TXT("UploadError")); } } else { if (qObjGetDistance(event_data->it_handle, Object_handles[13]) < 25.000000f) { if (qUserFlag(14) == true) { - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("UploadStarted")); aSetLevelTimer(0.100000f, 2); } else { aObjGhostSet(0, data->me_handle); aAddObjectToInventory(data->me_handle, event_data->it_handle, 0); - aShowHUDMessage(Message_strings[14]); + aShowHUDMessage(TXT("UploadError")); } } else { aObjGhostSet(0, data->me_handle); aAddObjectToInventory(data->me_handle, event_data->it_handle, 0); - aShowHUDMessageObj(Message_strings[15], event_data->it_handle); + aShowHUDMessageObj(TXT("UseCoreMaterialFailed"), event_data->it_handle); } } } @@ -2364,7 +2124,7 @@ int16_t CustomObjectScript_08A8::CallEvent(int event, tOSIRISEventInfo *data) { aUserFlagSet(11, 1); aObjGhostSet(1, qObjSavedHandle(0)); aMatcenGroupASetEnableState(0); - aShowHUDMessageI(Message_strings[3], 1); + aShowHUDMessageI(TXT("PowerOffline"), 1); } } else { if (qObjAnimFrame(data->me_handle) == 1.000000f) { @@ -2373,7 +2133,7 @@ int16_t CustomObjectScript_08A8::CallEvent(int event, tOSIRISEventInfo *data) { aUserFlagSet(11, 0); aObjGhostSet(0, qObjSavedHandle(0)); aMatcenGroupASetEnableState(1); - aShowHUDMessageI(Message_strings[4], 1); + aShowHUDMessageI(TXT("PowerOnline"), 1); } } @@ -2400,7 +2160,7 @@ int16_t CustomObjectScript_08A7::CallEvent(int event, tOSIRISEventInfo *data) { aUserFlagSet(12, 1); aObjGhostSet(1, qObjSavedHandle(1)); aMatcenGroupBSetEnableState(0); - aShowHUDMessageI(Message_strings[3], 2); + aShowHUDMessageI(TXT("PowerOffline"), 2); } } else { if (qObjAnimFrame(data->me_handle) == 1.000000f) { @@ -2409,7 +2169,7 @@ int16_t CustomObjectScript_08A7::CallEvent(int event, tOSIRISEventInfo *data) { aUserFlagSet(12, 0); aObjGhostSet(0, qObjSavedHandle(1)); aMatcenGroupBSetEnableState(1); - aShowHUDMessageI(Message_strings[4], 2); + aShowHUDMessageI(TXT("PowerOnline"), 2); } } @@ -2436,7 +2196,7 @@ int16_t CustomObjectScript_180F::CallEvent(int event, tOSIRISEventInfo *data) { aUserFlagSet(13, 1); aObjGhostSet(1, qObjSavedHandle(2)); aMatcenGroupCSetEnableState(0); - aShowHUDMessageI(Message_strings[3], 3); + aShowHUDMessageI(TXT("PowerOffline"), 3); } } else { if (qObjAnimFrame(data->me_handle) == 1.000000f) { @@ -2445,7 +2205,7 @@ int16_t CustomObjectScript_180F::CallEvent(int event, tOSIRISEventInfo *data) { aUserFlagSet(13, 0); aObjGhostSet(0, qObjSavedHandle(2)); aMatcenGroupCSetEnableState(1); - aShowHUDMessageI(Message_strings[4], 3); + aShowHUDMessageI(TXT("PowerOnline"), 3); } } @@ -2469,10 +2229,10 @@ int16_t CustomObjectScript_1081::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[1], event_data->it_handle, 1.000000f); aUserVarInc(0); if (qMathAddInt(qUserVarValueInt(0), qUserVarValueInt(1)) >= 3) { - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("FoundAllBypassConns")); aGoalCompleted(Goal_indexes[0], 1); } else { - aShowHUDMessage(Message_strings[6]); + aShowHUDMessage(TXT("FoundBypassConn")); } // Increment the script action counter @@ -2495,10 +2255,10 @@ int16_t CustomObjectScript_186D::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[1], event_data->it_handle, 1.000000f); aUserVarInc(0); if (qMathAddInt(qUserVarValueInt(0), qUserVarValueInt(1)) >= 3) { - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("FoundAllBypassConns")); aGoalCompleted(Goal_indexes[0], 1); } else { - aShowHUDMessage(Message_strings[6]); + aShowHUDMessage(TXT("FoundBypassConn")); } // Increment the script action counter @@ -2521,10 +2281,10 @@ int16_t CustomObjectScript_08D3::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[1], event_data->it_handle, 1.000000f); aUserVarInc(0); if (qMathAddInt(qUserVarValueInt(0), qUserVarValueInt(1)) >= 3) { - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("FoundAllBypassConns")); aGoalCompleted(Goal_indexes[0], 1); } else { - aShowHUDMessage(Message_strings[6]); + aShowHUDMessage(TXT("FoundBypassConn")); } // Increment the script action counter @@ -2546,7 +2306,7 @@ int16_t CustomObjectScript_188F::CallEvent(int event, tOSIRISEventInfo *data) { aDoorLockUnlock(0, Door_handles[0]); aAddObjectToInventory(data->me_handle, event_data->it_handle, 0); aSoundPlayObject(Sound_indexes[1], event_data->it_handle, 1.000000f); - aShowHUDMessage(Message_strings[7]); + aShowHUDMessage(TXT("FoundEquipRmKey")); aGoalCompleted(Goal_indexes[1], 1); // Increment the script action counter @@ -2566,22 +2326,22 @@ int16_t CustomObjectScript_0888::CallEvent(int event, tOSIRISEventInfo *data) { // Script 005: Bumped Emitter Room Data Link if (qObjIsPlayer(event_data->it_handle) == true) { if (qUserFlag(7) == true) { - aShowHUDMessageObj(Message_strings[8], event_data->it_handle); + aShowHUDMessageObj(TXT("DataLinkAlreadyActive"), event_data->it_handle); } else { if (qUserVarValue(0) > 0.000000f) { aGoalItemCompleted(Goal_indexes[2], 3, 1); aObjPlayAnim(data->me_handle, 0, 10, 3.000000f, 0); aSoundPlayObject(Sound_indexes[2], data->me_handle, 1.000000f); - aShowHUDMessageObj(Message_strings[9], event_data->it_handle); + aShowHUDMessageObj(TXT("DataLinkFixed"), event_data->it_handle); aUserVarInc(1); aUserVarDec(0); aUserFlagSet(7, 1); if (qUserVarValue(1) == 3.000000f) { - aShowHUDMessage(Message_strings[10]); + aShowHUDMessage(TXT("SystemStarting")); aSetLevelTimer(0.100000f, 1); } } else { - aShowHUDMessageObj(Message_strings[11], event_data->it_handle); + aShowHUDMessageObj(TXT("DataLinkError"), event_data->it_handle); } } @@ -2602,22 +2362,22 @@ int16_t CustomObjectScript_204F::CallEvent(int event, tOSIRISEventInfo *data) { // Script 036: Bumped West Dock Data Link if (qObjIsPlayer(event_data->it_handle) == true) { if (qUserFlag(8) == true) { - aShowHUDMessageObj(Message_strings[8], event_data->it_handle); + aShowHUDMessageObj(TXT("DataLinkAlreadyActive"), event_data->it_handle); } else { if (qUserVarValue(0) > 0.000000f) { aGoalItemCompleted(Goal_indexes[2], 1, 1); aObjPlayAnim(data->me_handle, 0, 10, 3.000000f, 0); aSoundPlayObject(Sound_indexes[2], data->me_handle, 1.000000f); - aShowHUDMessageObj(Message_strings[9], event_data->it_handle); + aShowHUDMessageObj(TXT("DataLinkFixed"), event_data->it_handle); aUserVarInc(1); aUserVarDec(0); aUserFlagSet(8, 1); if (qUserVarValue(1) == 3.000000f) { - aShowHUDMessage(Message_strings[10]); + aShowHUDMessage(TXT("SystemStarting")); aSetLevelTimer(0.100000f, 1); } } else { - aShowHUDMessageObj(Message_strings[11], event_data->it_handle); + aShowHUDMessageObj(TXT("DataLinkError"), event_data->it_handle); } } @@ -2638,22 +2398,22 @@ int16_t CustomObjectScript_2870::CallEvent(int event, tOSIRISEventInfo *data) { // Script 037: Bumped Control Room Data Link if (qObjIsPlayer(event_data->it_handle) == true) { if (qUserFlag(9) == true) { - aShowHUDMessageObj(Message_strings[8], event_data->it_handle); + aShowHUDMessageObj(TXT("DataLinkAlreadyActive"), event_data->it_handle); } else { if (qUserVarValue(0) > 0.000000f) { aGoalItemCompleted(Goal_indexes[2], 2, 1); aObjPlayAnim(data->me_handle, 0, 10, 3.000000f, 0); aSoundPlayObject(Sound_indexes[2], data->me_handle, 1.000000f); - aShowHUDMessageObj(Message_strings[9], event_data->it_handle); + aShowHUDMessageObj(TXT("DataLinkFixed"), event_data->it_handle); aUserVarInc(1); aUserVarDec(0); aUserFlagSet(9, 1); if (qUserVarValue(1) == 3.000000f) { - aShowHUDMessage(Message_strings[10]); + aShowHUDMessage(TXT("SystemStarting")); aSetLevelTimer(0.100000f, 1); } } else { - aShowHUDMessageObj(Message_strings[11], event_data->it_handle); + aShowHUDMessageObj(TXT("DataLinkError"), event_data->it_handle); } } @@ -2701,7 +2461,7 @@ int16_t CustomObjectScript_1025::CallEvent(int event, tOSIRISEventInfo *data) { aUserVarSet(3, 1.000000f); } } else { - aShowHUDMessageObj(Message_strings[18], event_data->it_handle); + aShowHUDMessageObj(TXT("BumpDialError"), event_data->it_handle); } // Increment the script action counter @@ -2725,15 +2485,15 @@ int16_t CustomObjectScript_08A0::CallEvent(int event, tOSIRISEventInfo *data) { (qUserFlag(10) == false)) { aObjPlayAnim(data->me_handle, 0, 4, 2.000000f, 0); aSoundPlayObject(Sound_indexes[0], data->me_handle, 1.000000f); - aShowHUDMessage(Message_strings[19]); + aShowHUDMessage(TXT("DialCodeEntered")); aSetTextureForMonitors(Texture_indexes[11]); aUserFlagSet(10, 1); aGoalCompleted(Goal_indexes[4], 1); } else { - aShowHUDMessageObj(Message_strings[20], event_data->it_handle); + aShowHUDMessageObj(TXT("DialCodeIncorrect"), event_data->it_handle); } } else { - aShowHUDMessageObj(Message_strings[21], event_data->it_handle); + aShowHUDMessageObj(TXT("DialSwitchError"), event_data->it_handle); } // Increment the script action counter @@ -2756,7 +2516,7 @@ int16_t CustomObjectScript_189E::CallEvent(int event, tOSIRISEventInfo *data) { ((qObjAnimFrame(data->me_handle) == 0.000000f) || (qObjAnimFrame(data->me_handle) == 20.000000f))) { if (qUserFlag(0) == 0) { aUserFlagSet(0, 1); - aShowHUDMessage(Message_strings[22]); + aShowHUDMessage(TXT("ShieldCodeSeqStart")); aSetLevelTimer(15.000000f, 0); } aObjPlayAnim(data->me_handle, 0, 10, 2.000000f, 0); @@ -2788,7 +2548,7 @@ int16_t CustomObjectScript_109B::CallEvent(int event, tOSIRISEventInfo *data) { ((qObjAnimFrame(data->me_handle) == 0.000000f) || (qObjAnimFrame(data->me_handle) == 20.000000f))) { if (qUserFlag(0) == 0) { aUserFlagSet(0, 1); - aShowHUDMessage(Message_strings[22]); + aShowHUDMessage(TXT("ShieldCodeSeqStart")); aSetLevelTimer(15.000000f, 0); } aObjPlayAnim(data->me_handle, 0, 10, 2.000000f, 0); @@ -2820,7 +2580,7 @@ int16_t CustomObjectScript_109D::CallEvent(int event, tOSIRISEventInfo *data) { ((qObjAnimFrame(data->me_handle) == 0.000000f) || (qObjAnimFrame(data->me_handle) == 20.000000f))) { if (qUserFlag(0) == 0) { aUserFlagSet(0, 1); - aShowHUDMessage(Message_strings[22]); + aShowHUDMessage(TXT("ShieldCodeSeqStart")); aSetLevelTimer(15.000000f, 0); } aObjPlayAnim(data->me_handle, 0, 10, 2.000000f, 0); @@ -2852,7 +2612,7 @@ int16_t CustomObjectScript_409A::CallEvent(int event, tOSIRISEventInfo *data) { ((qObjAnimFrame(data->me_handle) == 0.000000f) || (qObjAnimFrame(data->me_handle) == 20.000000f))) { if (qUserFlag(0) == 0) { aUserFlagSet(0, 1); - aShowHUDMessage(Message_strings[22]); + aShowHUDMessage(TXT("ShieldCodeSeqStart")); aSetLevelTimer(15.000000f, 0); } aObjPlayAnim(data->me_handle, 0, 10, 2.000000f, 0); @@ -2886,10 +2646,10 @@ int16_t CustomObjectScript_309C::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[0], data->me_handle, 1.000000f); aUserFlagSet(2, 1); aUserFlagSet(0, 0); - aShowHUDMessage(Message_strings[24]); + aShowHUDMessage(TXT("ShieldDeactivated")); aGoalCompleted(Goal_indexes[5], 1); } else { - aShowHUDMessageObj(Message_strings[25], event_data->it_handle); + aShowHUDMessageObj(TXT("ShieldCodeIncorrect"), event_data->it_handle); } // Increment the script action counter @@ -3214,7 +2974,7 @@ int16_t CustomObjectScript_2880::CallEvent(int event, tOSIRISEventInfo *data) { aRoomSetWind(Room_indexes[2], 0.000000f, 0.000000f, -1.000000f, 0.000000f); aAIGoalFollowPath(Object_handles[27], Path_indexes[3], 1, 4, 1, 3, 131332, 2); aAISetMaxSpeed(Object_handles[27], 100.000000f); - aShowHUDMessage(Message_strings[26]); + aShowHUDMessage(TXT("ShuttleFreed")); aMiscShakeArea(Object_handles[27], 100.000000f, 500.000000f); aGoalCompleted(Goal_indexes[7], 1); @@ -3281,27 +3041,27 @@ int16_t CustomObjectScript_4089::CallEvent(int event, tOSIRISEventInfo *data) { aGoalCompleted(Goal_indexes[8], 1); aSetLevelTimer(60.000000f, 6); aSetLevelTimer(10.000000f, 7); - aShowHUDMessage(Message_strings[27]); + aShowHUDMessage(TXT("BeamIgnited")); aUserFlagSet(17, 1); } else { - aShowHUDMessage(Message_strings[28]); + aShowHUDMessage(TXT("BeamIgniteError6")); } } else { - aShowHUDMessage(Message_strings[29]); + aShowHUDMessage(TXT("BeamIgniteError5")); } } else { - aShowHUDMessage(Message_strings[30]); + aShowHUDMessage(TXT("BeamIgniteError4")); } } else { - aShowHUDMessage(Message_strings[31]); + aShowHUDMessage(TXT("BeamIgniteError3")); aGoalCompleted(Goal_indexes[9], 0); aGoalEnableDisable(1, Goal_indexes[9]); } } else { - aShowHUDMessage(Message_strings[32]); + aShowHUDMessage(TXT("BeamIgniteError2")); } } else { - aShowHUDMessage(Message_strings[33]); + aShowHUDMessage(TXT("BeamIgniteError1")); } // Increment the script action counter @@ -3322,7 +3082,7 @@ int16_t CustomObjectScript_406F::CallEvent(int event, tOSIRISEventInfo *data) { if ((qObjIsPlayer(event_data->it_handle) == true) && (qUserFlag(16) == false)) { aAddObjectToInventory(data->me_handle, event_data->it_handle, 0); aSoundPlayObject(Sound_indexes[1], event_data->it_handle, 1.000000f); - aShowHUDMessageObj(Message_strings[36], event_data->it_handle); + aShowHUDMessageObj(TXT("GotSpareLens"), event_data->it_handle); aGoalCompleted(Goal_indexes[10], 1); // Increment the script action counter @@ -3341,18 +3101,18 @@ int16_t CustomObjectScript_406F::CallEvent(int event, tOSIRISEventInfo *data) { aMoveObjectToPositionClipboard(data->me_handle); aObjGhostSet(0, data->me_handle); aSetLevelTimer(15.000000f, 8); - aShowHUDMessage(Message_strings[37]); + aShowHUDMessage(TXT("UseLensCompleted")); aUserFlagSet(16, 1); aGoalCompleted(Goal_indexes[11], 1); } else { aObjGhostSet(0, data->me_handle); aAddObjectToInventory(data->me_handle, event_data->it_handle, 0); - aShowHUDMessageObj(Message_strings[38], event_data->it_handle); + aShowHUDMessageObj(TXT("UseLensFailed2"), event_data->it_handle); } } else { aObjGhostSet(0, data->me_handle); aAddObjectToInventory(data->me_handle, event_data->it_handle, 0); - aShowHUDMessageObj(Message_strings[39], event_data->it_handle); + aShowHUDMessageObj(TXT("UseLensFailed1"), event_data->it_handle); } // Increment the script action counter @@ -3373,7 +3133,7 @@ int16_t CustomObjectScript_1082::CallEvent(int event, tOSIRISEventInfo *data) { if (qObjIsPlayer(event_data->it_handle) == true) { aObjDelete(data->me_handle); aSoundPlayObject(Sound_indexes[1], event_data->it_handle, 1.000000f); - aAddGameMessage(Message_strings[43], Message_strings[44]); + aAddGameMessage(TXT("JournalBeamGame"), TXT("JournalBeamHUD")); // Increment the script action counter if (ScriptActionCtr_058 < MAX_ACTION_CTR_VALUE) @@ -3393,7 +3153,7 @@ int16_t CustomObjectScript_10D5::CallEvent(int event, tOSIRISEventInfo *data) { if (qObjIsPlayer(event_data->it_handle) == true) { aObjDelete(data->me_handle); aSoundPlayObject(Sound_indexes[1], event_data->it_handle, 1.000000f); - aAddGameMessage(Message_strings[45], Message_strings[46]); + aAddGameMessage(TXT("JournalShieldGame"), TXT("JournalShieldHUD")); // Increment the script action counter if (ScriptActionCtr_059 < MAX_ACTION_CTR_VALUE) @@ -3413,7 +3173,7 @@ int16_t CustomObjectScript_10D4::CallEvent(int event, tOSIRISEventInfo *data) { if (qObjIsPlayer(event_data->it_handle) == true) { aObjDelete(data->me_handle); aSoundPlayObject(Sound_indexes[1], event_data->it_handle, 1.000000f); - aAddGameMessage(Message_strings[47], Message_strings[48]); + aAddGameMessage(TXT("JournalVirusGame"), TXT("JournalVirusHUD")); // Increment the script action counter if (ScriptActionCtr_060 < MAX_ACTION_CTR_VALUE) @@ -3433,7 +3193,7 @@ int16_t CustomObjectScript_10D6::CallEvent(int event, tOSIRISEventInfo *data) { if (qObjIsPlayer(event_data->it_handle) == true) { aObjDelete(data->me_handle); aSoundPlayObject(Sound_indexes[1], event_data->it_handle, 1.000000f); - aAddGameMessage(Message_strings[49], Message_strings[50]); + aAddGameMessage(TXT("JournalPowerGame"), TXT("JournalPowerHUD")); // Increment the script action counter if (ScriptActionCtr_061 < MAX_ACTION_CTR_VALUE) @@ -3453,7 +3213,7 @@ int16_t CustomObjectScript_0917::CallEvent(int event, tOSIRISEventInfo *data) { if (qObjIsPlayer(event_data->it_handle) == true) { aObjDelete(data->me_handle); aSoundPlayObject(Sound_indexes[1], event_data->it_handle, 1.000000f); - aAddGameMessage(Message_strings[51], Message_strings[52]); + aAddGameMessage(TXT("JournalRobotGame"), TXT("JournalRobotHUD")); // Increment the script action counter if (ScriptActionCtr_062 < MAX_ACTION_CTR_VALUE) @@ -3473,7 +3233,7 @@ int16_t CustomObjectScript_10D7::CallEvent(int event, tOSIRISEventInfo *data) { if (qObjIsPlayer(event_data->it_handle) == true) { aObjDelete(data->me_handle); aSoundPlayObject(Sound_indexes[1], event_data->it_handle, 1.000000f); - aAddGameMessage(Message_strings[53], Message_strings[54]); + aAddGameMessage(TXT("JournalDialGame"), TXT("JournalDialHUD")); // Increment the script action counter if (ScriptActionCtr_063 < MAX_ACTION_CTR_VALUE) diff --git a/scripts/Level14_FRN.msg b/scripts/level14_FRN.msg similarity index 100% rename from scripts/Level14_FRN.msg rename to scripts/level14_FRN.msg diff --git a/scripts/level14_Ger.msg b/scripts/level14_GER.msg similarity index 100% rename from scripts/level14_Ger.msg rename to scripts/level14_GER.msg diff --git a/scripts/Level14_ITN.msg b/scripts/level14_ITN.msg similarity index 100% rename from scripts/Level14_ITN.msg rename to scripts/level14_ITN.msg diff --git a/scripts/level17.cpp b/scripts/level17.cpp index ba09b5dda..10f008588 100644 --- a/scripts/level17.cpp +++ b/scripts/level17.cpp @@ -22,10 +22,10 @@ // Filename: Level17.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -1481,180 +1481,12 @@ void RestoreGlobalActionCtrs(void *file_ptr) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; +std::map Messages; - return (s); -} - -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -1820,12 +1652,6 @@ const char *Goal_names[NUM_GOAL_NAMES] = {"Destroy Red Key Forcefield Generators "Destroy the Research Center"}; int Goal_indexes[NUM_GOAL_NAMES]; -#define NUM_MESSAGE_NAMES 10 -const char *Message_names[NUM_MESSAGE_NAMES] = {"FlameDeactivated", "RedKeyFF", "BlueKeyFF", "NameRedKey", - "NameBlueKey", "ReactorFF", "ReactorDestroyed", "RedDoor", - "BlueDoor", "IntroCam"}; -const char *Message_strings[NUM_MESSAGE_NAMES]; - // =============== // InitializeDLL() // =============== @@ -1839,26 +1665,16 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "Level17.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { mprintf(0, "ERROR: Could not load message file - %s\n", filename); @@ -1905,10 +1721,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } @@ -3325,7 +3137,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 140: IntroCam if (1 == true) { - aCinematicIntro(Path_indexes[0], Message_strings[9], Object_handles[38], Path_indexes[1], 10.000000f); + aCinematicIntro(Path_indexes[0], TXT("IntroCam"), Object_handles[38], Path_indexes[1], 10.000000f); // Increment the script action counter if (ScriptActionCtr_140 < MAX_ACTION_CTR_VALUE) @@ -3370,7 +3182,7 @@ int16_t CustomObjectScript_0821::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_062 < 1) && (qObjIsPlayerWeapon(event_data->it_handle) == true)) { aObjPlayAnim(data->me_handle, 0, 3, 3.000000f, 0); aSoundPlayObject(Sound_indexes[2], data->me_handle, 1.000000f); - aShowHUDMessage(Message_strings[0]); + aShowHUDMessage(TXT("FlameDeactivated")); aTurnOffSpew(3); aRoomSetDamage(Room_indexes[56], 0.000000f, 0); @@ -3392,7 +3204,7 @@ int16_t CustomObjectScript_0820::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_061 < 1) && (qObjIsPlayerWeapon(event_data->it_handle) == true)) { aObjPlayAnim(data->me_handle, 0, 3, 3.000000f, 0); aSoundPlayObject(Sound_indexes[2], data->me_handle, 1.000000f); - aShowHUDMessage(Message_strings[0]); + aShowHUDMessage(TXT("FlameDeactivated")); aTurnOffSpew(2); aRoomSetDamage(Room_indexes[55], 0.000000f, 0); @@ -3414,7 +3226,7 @@ int16_t CustomObjectScript_181E::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_060 < 1) && (qObjIsPlayerWeapon(event_data->it_handle) == true)) { aObjPlayAnim(data->me_handle, 0, 3, 3.000000f, 0); aSoundPlayObject(Sound_indexes[2], data->me_handle, 1.000000f); - aShowHUDMessage(Message_strings[0]); + aShowHUDMessage(TXT("FlameDeactivated")); aTurnOffSpew(1); aRoomSetDamage(Room_indexes[58], 0.000000f, 0); @@ -3436,7 +3248,7 @@ int16_t CustomObjectScript_081F::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_059 < 1) && (qObjIsPlayerWeapon(event_data->it_handle) == true)) { aObjPlayAnim(data->me_handle, 0, 3, 3.000000f, 0); aSoundPlayObject(Sound_indexes[2], data->me_handle, 1.000000f); - aShowHUDMessage(Message_strings[0]); + aShowHUDMessage(TXT("FlameDeactivated")); aTurnOffSpew(0); aRoomSetDamage(Room_indexes[57], 0.000000f, 0); @@ -3522,7 +3334,7 @@ int16_t CustomObjectScript_0816::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_065 < 1) && (1)) { aGoalCompleted(Goal_indexes[0], 1); aPortalRenderSet(0, 0, Room_indexes[59], 1); - aShowHUDMessage(Message_strings[1]); + aShowHUDMessage(TXT("RedKeyFF")); // Increment the script action counter if (ScriptActionCtr_065 < MAX_ACTION_CTR_VALUE) @@ -3606,7 +3418,7 @@ int16_t CustomObjectScript_0817::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_068 < 1) && (1)) { aGoalCompleted(Goal_indexes[1], 1); aPortalRenderSet(0, 0, Room_indexes[60], 1); - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("BlueKeyFF")); // Increment the script action counter if (ScriptActionCtr_068 < MAX_ACTION_CTR_VALUE) @@ -3627,7 +3439,7 @@ int16_t CustomObjectScript_1024::CallEvent(int event, tOSIRISEventInfo *data) { aMusicSetRegion(2, event_data->it_handle); aGoalCompleted(Goal_indexes[2], 1); aSoundPlayObject(Sound_indexes[3], data->me_handle, 1.000000f); - aObjectPlayerGiveKey(event_data->it_handle, data->me_handle, 2, Message_strings[3], 1); + aObjectPlayerGiveKey(event_data->it_handle, data->me_handle, 2, TXT("NameRedKey"), 1); // Increment the script action counter if (ScriptActionCtr_070 < MAX_ACTION_CTR_VALUE) @@ -3648,7 +3460,7 @@ int16_t CustomObjectScript_0826::CallEvent(int event, tOSIRISEventInfo *data) { aMusicSetRegion(1, event_data->it_handle); aGoalCompleted(Goal_indexes[3], 1); aSoundPlayObject(Sound_indexes[3], data->me_handle, 1.000000f); - aObjectPlayerGiveKey(event_data->it_handle, data->me_handle, 1, Message_strings[4], 1); + aObjectPlayerGiveKey(event_data->it_handle, data->me_handle, 1, TXT("NameBlueKey"), 1); // Increment the script action counter if (ScriptActionCtr_069 < MAX_ACTION_CTR_VALUE) @@ -3781,7 +3593,7 @@ int16_t CustomObjectScript_1025::CallEvent(int event, tOSIRISEventInfo *data) { aMusicSetRegionAll(4); aGoalCompleted(Goal_indexes[5], 1); aSoundPlay2D(Sound_indexes[4], 1.000000f); - aShowHUDMessage(Message_strings[6]); + aShowHUDMessage(TXT("ReactorDestroyed")); aPortalRenderSet(0, 0, Room_indexes[30], 1); aSetObjectTimer(Object_handles[69], 0.500000f, -1); aTurnOnSpew(Object_handles[69], -1, 8, 0.000000f, 0.000000f, 65536, 0, 1.000000f, 0.120000f, 25.000000f, @@ -3800,7 +3612,7 @@ int16_t CustomObjectScript_1025::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_073 < 1) && (1)) { aGoalCompleted(Goal_indexes[4], 1); aPortalRenderSet(0, 0, Room_indexes[61], 1); - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ReactorFF")); // Increment the script action counter if (ScriptActionCtr_073 < MAX_ACTION_CTR_VALUE) @@ -4028,10 +3840,10 @@ int16_t CustomObjectScript_1004::CallEvent(int event, tOSIRISEventInfo *data) { // Script 087: RedDoor-2 Lock Message if ((ScriptActionCtr_070 > 0) == false) { if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[7], event_data->it_handle); + aShowHUDMessageObj(TXT("RedDoor"), event_data->it_handle); } else { if (qObjIsPlayerWeapon(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[7], qObjParent(event_data->it_handle)); + aShowHUDMessageObj(TXT("RedDoor"), qObjParent(event_data->it_handle)); } } @@ -4052,10 +3864,10 @@ int16_t CustomObjectScript_1003::CallEvent(int event, tOSIRISEventInfo *data) { // Script 086: RedDoor-1 Lock Message if ((ScriptActionCtr_070 > 0) == false) { if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[7], event_data->it_handle); + aShowHUDMessageObj(TXT("RedDoor"), event_data->it_handle); } else { if (qObjIsPlayerWeapon(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[7], qObjParent(event_data->it_handle)); + aShowHUDMessageObj(TXT("RedDoor"), qObjParent(event_data->it_handle)); } } @@ -4076,10 +3888,10 @@ int16_t CustomObjectScript_100E::CallEvent(int event, tOSIRISEventInfo *data) { // Script 085: BlueDoor Lock Message if ((ScriptActionCtr_069 > 0) == false) { if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[8], event_data->it_handle); + aShowHUDMessageObj(TXT("BlueDoor"), event_data->it_handle); } else { if (qObjIsPlayerWeapon(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[8], qObjParent(event_data->it_handle)); + aShowHUDMessageObj(TXT("BlueDoor"), qObjParent(event_data->it_handle)); } } diff --git a/scripts/Level1_FRN.msg b/scripts/level1_FRN.msg similarity index 100% rename from scripts/Level1_FRN.msg rename to scripts/level1_FRN.msg diff --git a/scripts/level1_Ger.msg b/scripts/level1_GER.msg similarity index 100% rename from scripts/level1_Ger.msg rename to scripts/level1_GER.msg diff --git a/scripts/Level1_ITN.msg b/scripts/level1_ITN.msg similarity index 100% rename from scripts/Level1_ITN.msg rename to scripts/level1_ITN.msg diff --git a/scripts/level2.cpp b/scripts/level2.cpp index 0f5bd5ff5..78d5fb8b5 100644 --- a/scripts/level2.cpp +++ b/scripts/level2.cpp @@ -22,10 +22,10 @@ // Filename: Level2.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -1018,180 +1018,12 @@ void RestoreGlobalActionCtrs(void *file_ptr) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} +std::map Messages; -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -1369,44 +1201,6 @@ const char *Goal_names[NUM_GOAL_NAMES] = {"Gain entry to the Supply Hangar", "Destroy all Prison Records Databanks"}; int Goal_indexes[NUM_GOAL_NAMES]; -#define NUM_MESSAGE_NAMES 35 -const char *Message_names[NUM_MESSAGE_NAMES] = {"OneTurretDown", - "IncomingMessage", - "AnotherTurretGone", - "InnerTowerForcefields", - "Empty", - "EndLevel", - "X1OldSecurityPassD", - "R1MaxSecurityPassC", - "G1MinSecurityPassB", - "Y1MedSecurityPassA", - "SupplyAlarm", - "1stInvalidPassOffense", - "2ndInvalidPassOffense", - "SecurityPassNotUsableHere", - "MaximumSecurityClearance", - "MediumSecurityClearance", - "MinimumSecurityClearance", - "IntroMessage", - "DontShootMe", - "SPUDisBorn", - "ChemicalReactionSwitches", - "SPUDkilled", - "SPUDscores", - "SPUDhasTheBall", - "ChemicalReactionAlert", - "WhatTheHell", - "SweitzerMINLockedOut", - "SweitzerMAX", - "ShuttleUnderAttack", - "LoadingSweitzer", - "LoadedSweitzer", - "RecordsNodeDestroyed", - "ComputerDestroyed", - "ShuttleMoveToTower", - "EscortShuttle"}; -const char *Message_strings[NUM_MESSAGE_NAMES]; - // =============== // InitializeDLL() // =============== @@ -1420,26 +1214,16 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "Level2.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { mprintf(0, "ERROR: Could not load message file - %s\n", filename); @@ -1486,10 +1270,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } @@ -2201,7 +1981,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { ((qObjCanSeePlayerAdvancedWithStore(3, 360, Object_handles[61], 80.000000f, 1048585) == true) && (qUserFlag(7) == true) && (qObjCanSeeObjAdvanced(Object_handles[61], 60, qObjSavedHandle(3), 1048585) == true))) { - aAddGameMessage(Message_strings[26], Message_strings[1]); + aAddGameMessage(TXT("SweitzerMINLockedOut"), TXT("IncomingMessage")); aUserFlagSet(9, 1); aRoomSetLightingPulse(Room_indexes[54], 3.000000f, 0.000000f); aGoalCompleted(Goal_indexes[13], 1); @@ -2218,7 +1998,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { ((qObjCanSeePlayerAdvancedWithStore(2, 360, Object_handles[60], 80.000000f, 1048585) == true) && (qUserFlag(5) == true) && (qObjCanSeeObjAdvanced(Object_handles[60], 60, qObjSavedHandle(2), 1048585) == true))) { - aAddGameMessage(Message_strings[27], Message_strings[1]); + aAddGameMessage(TXT("SweitzerMAX"), TXT("IncomingMessage")); aRoomSetLightingPulse(Room_indexes[47], 3.000000f, 0.000000f); aGoalCompleted(Goal_indexes[12], 1); aGoalEnableDisable(1, Goal_indexes[14]); @@ -2257,7 +2037,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 057: End Level Sequence if ((ScriptActionCtr_057 < 1) && ((qUserFlag(13) == true) && (qUserFlag(14) == true) && (1 == false))) { - aStartEndlevelSequencePath(Path_indexes[17], Path_indexes[18], 10.000000f, Message_strings[5]); + aStartEndlevelSequencePath(Path_indexes[17], Path_indexes[18], 10.000000f, TXT("EndLevel")); // Increment the script action counter if (ScriptActionCtr_057 < MAX_ACTION_CTR_VALUE) @@ -2330,7 +2110,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 020: Intro Camera Sequence if (1) { - aCinematicIntro(Path_indexes[13], Message_strings[17], Object_handles[21], Path_indexes[14], 10.000000f); + aCinematicIntro(Path_indexes[13], TXT("IntroMessage"), Object_handles[21], Path_indexes[14], 10.000000f); aSetLevelTimer(15.000000f, 9); // Increment the script action counter @@ -2474,7 +2254,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aDestroyAllRobotsSpareHandle(Object_handles[10]); aDestroyAllRobotsSpareHandle(Object_handles[11]); aDestroyAllRobotsEnd(); - aCinematicSimple(Path_indexes[1], Message_strings[4], Object_handles[12], 12.000000f, 1); + aCinematicSimple(Path_indexes[1], TXT("Empty"), Object_handles[12], 12.000000f, 1); aSetLevelTimer(2.000000f, 16); // Increment the script action counter @@ -2537,7 +2317,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aObjGhostSet(0, Object_handles[57]); aObjGhostSet(0, Object_handles[58]); aObjGhostSet(0, Object_handles[59]); - aAddGameMessage(Message_strings[25], Message_strings[1]); + aAddGameMessage(TXT("WhatTheHell"), TXT("IncomingMessage")); aGoalEnableDisable(1, Goal_indexes[13]); aGoalCompleted(Goal_indexes[14], 1); aSetLevelTimer(3.000000f, 11); @@ -2598,7 +2378,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[3], Object_handles[0], 1.000000f); aObjPlayAnim(Object_handles[0], 0, 2, 3.000000f, 0); aSetLevelTimer(7.300000f, 5); - aShowHUDMessage(Message_strings[29]); + aShowHUDMessage(TXT("LoadingSweitzer")); // Increment the script action counter if (ScriptActionCtr_052 < MAX_ACTION_CTR_VALUE) @@ -2609,7 +2389,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { if (5 == event_data->id) { aSoundPlayObject(Sound_indexes[3], Object_handles[0], 1.000000f); aObjPlayAnim(Object_handles[0], 2, 4, 3.000000f, 0); - aShowHUDMessage(Message_strings[30]); + aShowHUDMessage(TXT("LoadedSweitzer")); aSetLevelTimer(3.000000f, 6); aObjGhostSet(1, Object_handles[11]); aUnAttachObject(Object_handles[0]); @@ -2632,7 +2412,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 101: Perimeter Secure Forcefield Down if (7 == event_data->id) { - aAddGameMessage(Message_strings[33], Message_strings[1]); + aAddGameMessage(TXT("ShuttleMoveToTower"), TXT("IncomingMessage")); // Increment the script action counter if (ScriptActionCtr_101 < MAX_ACTION_CTR_VALUE) @@ -2641,7 +2421,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 102: ESCORT SHUTTLE WARNING! if ((qAIIsObjectAware(Object_handles[0]) == false) && (8 == event_data->id)) { - aShowHUDMessage(Message_strings[34]); + aShowHUDMessage(TXT("EscortShuttle")); aSetLevelTimer(5.000000f, 8); // Increment the script action counter @@ -2699,7 +2479,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 014: Supply Hangar Alarm Switch if (6 == event_data->goal_uid) { - aShowHUDMessage(Message_strings[10]); + aShowHUDMessage(TXT("SupplyAlarm")); aMatcenSetState(1, Matcen_indexes[1]); aSetLevelTimer(9.000000f, 14); @@ -2716,7 +2496,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aMatcenSetState(0, Matcen_indexes[6]); aObjDelete(qObjSavedHandle(1)); aObjDelete(qObjSavedHandle(0)); - aShowHUDMessage(Message_strings[22]); + aShowHUDMessage(TXT("SPUDscores")); // Increment the script action counter if (ScriptActionCtr_027 < MAX_ACTION_CTR_VALUE) @@ -2726,7 +2506,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 026: Chemical Droid Ball Pickup if (0 == event_data->goal_uid) { aAIGoalGotoRoom(event_data->it_handle, Room_indexes[9], 3, 4352, 1); - aShowHUDMessage(Message_strings[23]); + aShowHUDMessage(TXT("SPUDhasTheBall")); // Increment the script action counter if (ScriptActionCtr_026 < MAX_ACTION_CTR_VALUE) @@ -2856,9 +2636,9 @@ int16_t CustomObjectScript_082D::CallEvent(int event, tOSIRISEventInfo *data) { aGoalCompleted(Goal_indexes[1], 1); } else { if (qUserVarValue(0) == 1.000000f) { - aAddGameMessage(Message_strings[0], Message_strings[1]); + aAddGameMessage(TXT("OneTurretDown"), TXT("IncomingMessage")); } else { - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("AnotherTurretGone")); } } @@ -2892,9 +2672,9 @@ int16_t CustomObjectScript_082E::CallEvent(int event, tOSIRISEventInfo *data) { aGoalCompleted(Goal_indexes[1], 1); } else { if (qUserVarValue(0) == 1.000000f) { - aAddGameMessage(Message_strings[0], Message_strings[1]); + aAddGameMessage(TXT("OneTurretDown"), TXT("IncomingMessage")); } else { - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("AnotherTurretGone")); } } @@ -2928,9 +2708,9 @@ int16_t CustomObjectScript_082F::CallEvent(int event, tOSIRISEventInfo *data) { aGoalCompleted(Goal_indexes[1], 1); } else { if (qUserVarValue(0) == 1.000000f) { - aAddGameMessage(Message_strings[0], Message_strings[1]); + aAddGameMessage(TXT("OneTurretDown"), TXT("IncomingMessage")); } else { - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("AnotherTurretGone")); } } @@ -2964,9 +2744,9 @@ int16_t CustomObjectScript_0830::CallEvent(int event, tOSIRISEventInfo *data) { aGoalCompleted(Goal_indexes[1], 1); } else { if (qUserVarValue(0) == 1.000000f) { - aAddGameMessage(Message_strings[0], Message_strings[1]); + aAddGameMessage(TXT("OneTurretDown"), TXT("IncomingMessage")); } else { - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("AnotherTurretGone")); } } @@ -3000,9 +2780,9 @@ int16_t CustomObjectScript_0831::CallEvent(int event, tOSIRISEventInfo *data) { aGoalCompleted(Goal_indexes[1], 1); } else { if (qUserVarValue(0) == 1.000000f) { - aAddGameMessage(Message_strings[0], Message_strings[1]); + aAddGameMessage(TXT("OneTurretDown"), TXT("IncomingMessage")); } else { - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("AnotherTurretGone")); } } @@ -3032,7 +2812,7 @@ int16_t CustomObjectScript_2112::CallEvent(int event, tOSIRISEventInfo *data) { aObjPlayAnim(Object_handles[7], 0, 2, 2.000000f, 0); aPortalRenderSet(0, 0, Room_indexes[1], 1); aPortalRenderSet(0, 1, Room_indexes[1], 1); - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("InnerTowerForcefields")); aUserFlagSet(0, 1); } aSetLevelTimer(2.000000f, 15); @@ -3062,7 +2842,7 @@ int16_t CustomObjectScript_11F2::CallEvent(int event, tOSIRISEventInfo *data) { aObjGhostSet(0, Object_handles[0]); aAISetMaxSpeed(Object_handles[0], 16.000000f); aAIGoalFollowPath(Object_handles[0], Path_indexes[2], 11, 17, 11, 3, 1048832, -1); - aCinematicSimple(Path_indexes[3], Message_strings[4], Object_handles[14], 9.000000f, 1); + aCinematicSimple(Path_indexes[3], TXT("Empty"), Object_handles[14], 9.000000f, 1); // Increment the script action counter if (ScriptActionCtr_115 < MAX_ACTION_CTR_VALUE) @@ -3085,7 +2865,7 @@ int16_t CustomObjectScript_11F4::CallEvent(int event, tOSIRISEventInfo *data) { aMoveObjectToPositionClipboard(Object_handles[0]); aObjGhostSet(0, Object_handles[0]); aAIGoalFollowPath(Object_handles[0], Path_indexes[2], 32, 34, 32, 3, 1048832, 3); - aCinematicSimple(Path_indexes[4], Message_strings[4], Object_handles[16], 10.000000f, 1); + aCinematicSimple(Path_indexes[4], TXT("Empty"), Object_handles[16], 10.000000f, 1); // Increment the script action counter if (ScriptActionCtr_117 < MAX_ACTION_CTR_VALUE) @@ -3108,7 +2888,7 @@ int16_t CustomObjectScript_11F6::CallEvent(int event, tOSIRISEventInfo *data) { aAISetState(1, Object_handles[8]); aObjSetMovementType(Object_handles[8], 0); aObjPlayAnim(Object_handles[8], 60, 88, 4.000000f, 0); - aCinematicSimple(Path_indexes[5], Message_strings[4], Object_handles[17], 6.000000f, 1); + aCinematicSimple(Path_indexes[5], TXT("Empty"), Object_handles[17], 6.000000f, 1); // Increment the script action counter if (ScriptActionCtr_116 < MAX_ACTION_CTR_VALUE) @@ -3129,7 +2909,7 @@ int16_t CustomObjectScript_19F7::CallEvent(int event, tOSIRISEventInfo *data) { aObjSetMovementType(Object_handles[8], 2); aObjPlayAnim(Object_handles[8], 0, 9, 2.000000f, 0); aAIGoalFollowPathSimple(Object_handles[8], Path_indexes[6], 4352, 7, 3); - aCinematicSimple(Path_indexes[7], Message_strings[4], Object_handles[18], 3.700000f, 1); + aCinematicSimple(Path_indexes[7], TXT("Empty"), Object_handles[18], 3.700000f, 1); // Increment the script action counter if (ScriptActionCtr_122 < MAX_ACTION_CTR_VALUE) @@ -3167,7 +2947,7 @@ int16_t CustomObjectScript_1211::CallEvent(int event, tOSIRISEventInfo *data) { if (1) { aObjGhostSet(1, Object_handles[8]); aAISetMaxSpeed(Object_handles[0], 10.000000f); - aCinematicSimple(Path_indexes[8], Message_strings[4], Object_handles[0], 10.000000f, 1); + aCinematicSimple(Path_indexes[8], TXT("Empty"), Object_handles[0], 10.000000f, 1); // Increment the script action counter if (ScriptActionCtr_118 < MAX_ACTION_CTR_VALUE) @@ -3185,7 +2965,7 @@ int16_t CustomObjectScript_0885::CallEvent(int event, tOSIRISEventInfo *data) { // Script 021: Rescue Shuttle Don't Shoot Me! if (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[18]); + aShowHUDMessage(TXT("DontShootMe")); aObjSetShields(Object_handles[0], 9999999.000000f); // Increment the script action counter @@ -3195,7 +2975,7 @@ int16_t CustomObjectScript_0885::CallEvent(int event, tOSIRISEventInfo *data) { // Script 040: Shuttle Taking Enemy Fire if ((qObjIsType(event_data->it_handle, 5) == true) && (qObjIsType(qObjParent(event_data->it_handle), 2) == true)) { - aShowHUDMessage(Message_strings[28]); + aShowHUDMessage(TXT("ShuttleUnderAttack")); aObjSetShields(Object_handles[0], 9999999.000000f); // Increment the script action counter @@ -3242,7 +3022,7 @@ int16_t CustomObjectScript_0885::CallEvent(int event, tOSIRISEventInfo *data) { aObjGhostSet(0, Object_handles[0]); aAISetMaxSpeed(Object_handles[0], 44.000000f); aAIGoalFollowPath(Object_handles[0], Path_indexes[9], 1, 8, 1, 3, 1048832, -1); - aStartEndlevelSequencePath(Path_indexes[10], Path_indexes[11], 15.000000f, Message_strings[5]); + aStartEndlevelSequencePath(Path_indexes[10], Path_indexes[11], 15.000000f, TXT("EndLevel")); // Increment the script action counter if (ScriptActionCtr_119 < MAX_ACTION_CTR_VALUE) @@ -3285,7 +3065,7 @@ int16_t CustomObjectScript_09EC::CallEvent(int event, tOSIRISEventInfo *data) { aObjPlayAnim(Object_handles[7], 0, 2, 2.000000f, 0); aPortalRenderSet(0, 0, Room_indexes[1], 1); aPortalRenderSet(0, 1, Room_indexes[1], 1); - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("InnerTowerForcefields")); aUserFlagSet(0, 1); aSetLevelTimer(7.000000f, 14); } @@ -3306,7 +3086,7 @@ int16_t CustomObjectScript_11EB::CallEvent(int event, tOSIRISEventInfo *data) { // Script 011: X-1 Old Security Pass D if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[6]); + aShowHUDMessage(TXT("X1OldSecurityPassD")); aAddObjectToInventory(Object_handles[21], event_data->it_handle, 0); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); aGoalEnableDisable(1, Goal_indexes[4]); @@ -3324,7 +3104,7 @@ int16_t CustomObjectScript_11EB::CallEvent(int event, tOSIRISEventInfo *data) { if (qObjIsPlayer(event_data->it_handle) == true) { if ((qObjRoom(event_data->it_handle) == Room_indexes[3]) && (qUserFlag(5) == false)) { if (qUserVarValue(3) < 1.000000f) { - aShowHUDMessage(Message_strings[11]); + aShowHUDMessage(TXT("1stInvalidPassOffense")); aRoomSetFaceTexture(Room_indexes[3], 30, Texture_indexes[1]); aAISetState(1, Object_handles[28]); aPortalRenderSet(0, 2, Room_indexes[4], 1); @@ -3334,7 +3114,7 @@ int16_t CustomObjectScript_11EB::CallEvent(int event, tOSIRISEventInfo *data) { aAddObjectToInventory(Object_handles[21], event_data->it_handle, 0); aSoundPlaySteaming("VoxL02SpecificC.osf", 1.000000f); } else { - aShowHUDMessage(Message_strings[12]); + aShowHUDMessage(TXT("2ndInvalidPassOffense")); aRoomSetFaceTexture(Room_indexes[3], 30, Texture_indexes[2]); aMatcenSetState(1, Matcen_indexes[2]); aUserFlagSet(12, 1); @@ -3346,7 +3126,7 @@ int16_t CustomObjectScript_11EB::CallEvent(int event, tOSIRISEventInfo *data) { } else { if ((qObjRoom(event_data->it_handle) == Room_indexes[5]) && (qUserFlag(4) == false)) { if (qUserVarValue(2) < 1.000000f) { - aShowHUDMessage(Message_strings[11]); + aShowHUDMessage(TXT("1stInvalidPassOffense")); aRoomSetFaceTexture(Room_indexes[5], 30, Texture_indexes[1]); aAISetState(1, Object_handles[27]); aPortalRenderSet(0, 2, Room_indexes[6], 1); @@ -3356,7 +3136,7 @@ int16_t CustomObjectScript_11EB::CallEvent(int event, tOSIRISEventInfo *data) { aAddObjectToInventory(Object_handles[21], event_data->it_handle, 0); aSoundPlaySteaming("VoxL02SpecificC.osf", 1.000000f); } else { - aShowHUDMessage(Message_strings[12]); + aShowHUDMessage(TXT("2ndInvalidPassOffense")); aRoomSetFaceTexture(Room_indexes[5], 30, Texture_indexes[2]); aMatcenSetState(1, Matcen_indexes[3]); aUserFlagSet(11, 1); @@ -3368,7 +3148,7 @@ int16_t CustomObjectScript_11EB::CallEvent(int event, tOSIRISEventInfo *data) { } else { aObjGhostSet(0, Object_handles[21]); aAddObjectToInventory(Object_handles[21], event_data->it_handle, 0); - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("SecurityPassNotUsableHere")); } } @@ -3388,7 +3168,7 @@ int16_t CustomObjectScript_19E9::CallEvent(int event, tOSIRISEventInfo *data) { // Script 010: R-1 Maximum Security Pass C if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[7]); + aShowHUDMessage(TXT("R1MaxSecurityPassC")); aAddObjectToInventory(Object_handles[22], event_data->it_handle, 0); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); aGoalCompleted(Goal_indexes[6], 1); @@ -3405,7 +3185,7 @@ int16_t CustomObjectScript_19E9::CallEvent(int event, tOSIRISEventInfo *data) { // Script 018: R-1 Security Pass Useage Matrix if (qObjIsPlayer(event_data->it_handle) == true) { if (qObjRoom(event_data->it_handle) == Room_indexes[3]) { - aShowHUDMessage(Message_strings[14]); + aShowHUDMessage(TXT("MaximumSecurityClearance")); aPortalRenderSet(0, 0, Room_indexes[4], 1); aRoomSetFaceTexture(Room_indexes[3], 30, Texture_indexes[3]); aUserFlagSet(5, 1); @@ -3416,7 +3196,7 @@ int16_t CustomObjectScript_19E9::CallEvent(int event, tOSIRISEventInfo *data) { } else { if ((qObjRoom(event_data->it_handle) == Room_indexes[5]) && (qUserFlag(4) == false)) { if (qUserVarValue(2) < 1.000000f) { - aShowHUDMessage(Message_strings[11]); + aShowHUDMessage(TXT("1stInvalidPassOffense")); aRoomSetFaceTexture(Room_indexes[5], 30, Texture_indexes[1]); aAISetState(1, Object_handles[27]); aPortalRenderSet(0, 2, Room_indexes[6], 1); @@ -3426,7 +3206,7 @@ int16_t CustomObjectScript_19E9::CallEvent(int event, tOSIRISEventInfo *data) { aAddObjectToInventory(Object_handles[22], event_data->it_handle, 0); aSoundPlaySteaming("VoxL02SpecificC.osf", 1.000000f); } else { - aShowHUDMessage(Message_strings[12]); + aShowHUDMessage(TXT("2ndInvalidPassOffense")); aRoomSetFaceTexture(Room_indexes[5], 30, Texture_indexes[2]); aMatcenSetState(1, Matcen_indexes[3]); aUserFlagSet(11, 1); @@ -3438,7 +3218,7 @@ int16_t CustomObjectScript_19E9::CallEvent(int event, tOSIRISEventInfo *data) { } else { if ((qObjRoom(event_data->it_handle) == Room_indexes[7]) && (qUserFlag(3) == false)) { if (qUserVarValue(1) < 1.000000f) { - aShowHUDMessage(Message_strings[11]); + aShowHUDMessage(TXT("1stInvalidPassOffense")); aRoomSetFaceTexture(Room_indexes[7], 30, Texture_indexes[1]); aAISetState(1, Object_handles[26]); aPortalRenderSet(0, 2, Room_indexes[8], 1); @@ -3448,7 +3228,7 @@ int16_t CustomObjectScript_19E9::CallEvent(int event, tOSIRISEventInfo *data) { aAddObjectToInventory(Object_handles[22], event_data->it_handle, 0); aSoundPlaySteaming("VoxL02SpecificC.osf", 1.000000f); } else { - aShowHUDMessage(Message_strings[12]); + aShowHUDMessage(TXT("2ndInvalidPassOffense")); aRoomSetFaceTexture(Room_indexes[7], 30, Texture_indexes[2]); aMatcenSetState(1, Matcen_indexes[4]); aUserFlagSet(10, 1); @@ -3460,7 +3240,7 @@ int16_t CustomObjectScript_19E9::CallEvent(int event, tOSIRISEventInfo *data) { } else { aObjGhostSet(0, Object_handles[22]); aAddObjectToInventory(Object_handles[22], event_data->it_handle, 0); - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("SecurityPassNotUsableHere")); } } } @@ -3481,7 +3261,7 @@ int16_t CustomObjectScript_19E8::CallEvent(int event, tOSIRISEventInfo *data) { // Script 009: G-1 Minimum Security Pass B if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[8]); + aShowHUDMessage(TXT("G1MinSecurityPassB")); aAddObjectToInventory(Object_handles[23], event_data->it_handle, 0); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); aGoalEnableDisable(1, Goal_indexes[8]); @@ -3498,7 +3278,7 @@ int16_t CustomObjectScript_19E8::CallEvent(int event, tOSIRISEventInfo *data) { // Script 016: G-1 Security Pass Useage Matrix if (qObjIsPlayer(event_data->it_handle) == true) { if (qObjRoom(event_data->it_handle) == Room_indexes[7]) { - aShowHUDMessage(Message_strings[16]); + aShowHUDMessage(TXT("MinimumSecurityClearance")); aPortalRenderSet(0, 0, Room_indexes[8], 1); aRoomSetFaceTexture(Room_indexes[7], 30, Texture_indexes[3]); aUserFlagSet(3, 1); @@ -3510,7 +3290,7 @@ int16_t CustomObjectScript_19E8::CallEvent(int event, tOSIRISEventInfo *data) { } else { aObjGhostSet(0, Object_handles[23]); aAddObjectToInventory(Object_handles[23], event_data->it_handle, 0); - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("SecurityPassNotUsableHere")); } // Increment the script action counter @@ -3529,7 +3309,7 @@ int16_t CustomObjectScript_19EA::CallEvent(int event, tOSIRISEventInfo *data) { // Script 008: Y-1 Medium Security Pass A if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[9]); + aShowHUDMessage(TXT("Y1MedSecurityPassA")); aAddObjectToInventory(Object_handles[24], event_data->it_handle, 0); aSoundPlay2DObj(Sound_indexes[0], event_data->it_handle, 1.000000f); aGoalEnableDisable(1, Goal_indexes[4]); @@ -3546,7 +3326,7 @@ int16_t CustomObjectScript_19EA::CallEvent(int event, tOSIRISEventInfo *data) { // Script 017: Y-1 Security Pass Useage Matrix if (qObjIsPlayer(event_data->it_handle) == true) { if (qObjRoom(event_data->it_handle) == Room_indexes[5]) { - aShowHUDMessage(Message_strings[15]); + aShowHUDMessage(TXT("MediumSecurityClearance")); aPortalRenderSet(0, 0, Room_indexes[6], 1); aRoomSetFaceTexture(Room_indexes[5], 30, Texture_indexes[3]); aUserFlagSet(4, 1); @@ -3557,7 +3337,7 @@ int16_t CustomObjectScript_19EA::CallEvent(int event, tOSIRISEventInfo *data) { } else { aObjGhostSet(0, Object_handles[24]); aAddObjectToInventory(Object_handles[24], event_data->it_handle, 0); - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("SecurityPassNotUsableHere")); } // Increment the script action counter @@ -3577,14 +3357,14 @@ int16_t CustomObjectScript_09E7::CallEvent(int event, tOSIRISEventInfo *data) { // Script 022: Chemical Droid Start Switch if (qObjIsPlayerWeapon(event_data->it_handle) == true) { if ((qUserFlag(6) == false) && (qUserFlag(7) == false)) { - aShowHUDMessage(Message_strings[19]); + aShowHUDMessage(TXT("SPUDisBorn")); aObjPlayAnim(Object_handles[35], 0, 10, 1.000000f, 0); aMatcenSetState(1, Matcen_indexes[5]); aMatcenSetState(1, Matcen_indexes[6]); aUserFlagSet(6, 1); } else { if (qUserFlag(7) == true) { - aShowHUDMessage(Message_strings[20]); + aShowHUDMessage(TXT("ChemicalReactionSwitches")); } else { } } @@ -3606,7 +3386,7 @@ int16_t CustomObjectScript_09E6::CallEvent(int event, tOSIRISEventInfo *data) { // Script 023: Chemical Droid KILL Switch if (qObjIsPlayerWeapon(event_data->it_handle) == true) { if ((qUserFlag(6) == true) && (qUserFlag(7) == false)) { - aShowHUDMessage(Message_strings[21]); + aShowHUDMessage(TXT("SPUDkilled")); aObjPlayAnim(Object_handles[36], 0, 20, 1.000000f, 0); aMatcenSetState(0, Matcen_indexes[5]); aMatcenSetState(0, Matcen_indexes[6]); @@ -3615,7 +3395,7 @@ int16_t CustomObjectScript_09E6::CallEvent(int event, tOSIRISEventInfo *data) { aObjPlayAnim(Object_handles[35], 10, 20, 1.000000f, 0); } else { if (qUserFlag(7) == true) { - aShowHUDMessage(Message_strings[20]); + aShowHUDMessage(TXT("ChemicalReactionSwitches")); } else { } } @@ -3640,7 +3420,7 @@ int16_t CustomObjectScript_11BB::CallEvent(int event, tOSIRISEventInfo *data) { // Script 088: Novak Prison Records Node H Destroyed if (1) { - aShowHUDMessage(Message_strings[31]); + aShowHUDMessage(TXT("RecordsNodeDestroyed")); aUserVarInc(5); aUserVarInc(4); if (qUserVarValue(5) > 7.000000f) { @@ -3671,7 +3451,7 @@ int16_t CustomObjectScript_09BC::CallEvent(int event, tOSIRISEventInfo *data) { // Script 087: Novak Prison Records Node G Destroyed if (1) { - aShowHUDMessage(Message_strings[31]); + aShowHUDMessage(TXT("RecordsNodeDestroyed")); aUserVarInc(5); aUserVarInc(4); if (qUserVarValue(5) > 7.000000f) { @@ -3702,7 +3482,7 @@ int16_t CustomObjectScript_09BD::CallEvent(int event, tOSIRISEventInfo *data) { // Script 086: Novak Prison Records Node F Destroyed if (1) { - aShowHUDMessage(Message_strings[31]); + aShowHUDMessage(TXT("RecordsNodeDestroyed")); aUserVarInc(5); aUserVarInc(4); if (qUserVarValue(5) > 7.000000f) { @@ -3733,7 +3513,7 @@ int16_t CustomObjectScript_09BE::CallEvent(int event, tOSIRISEventInfo *data) { // Script 085: Novak Prison Records Node E Destroyed if (1) { - aShowHUDMessage(Message_strings[31]); + aShowHUDMessage(TXT("RecordsNodeDestroyed")); aUserVarInc(5); aUserVarInc(4); if (qUserVarValue(5) > 7.000000f) { @@ -3764,7 +3544,7 @@ int16_t CustomObjectScript_11BF::CallEvent(int event, tOSIRISEventInfo *data) { // Script 084: Novak Prison Records Node D Destroyed if (1) { - aShowHUDMessage(Message_strings[31]); + aShowHUDMessage(TXT("RecordsNodeDestroyed")); aUserVarInc(5); aUserVarInc(4); if (qUserVarValue(5) > 7.000000f) { @@ -3795,7 +3575,7 @@ int16_t CustomObjectScript_09C0::CallEvent(int event, tOSIRISEventInfo *data) { // Script 083: Novak Prison Records Node C Destroyed if (1) { - aShowHUDMessage(Message_strings[31]); + aShowHUDMessage(TXT("RecordsNodeDestroyed")); aUserVarInc(5); aUserVarInc(4); if (qUserVarValue(5) > 7.000000f) { @@ -3826,7 +3606,7 @@ int16_t CustomObjectScript_11C1::CallEvent(int event, tOSIRISEventInfo *data) { // Script 082: Novak Prison Records Node B Destroyed if (1) { - aShowHUDMessage(Message_strings[31]); + aShowHUDMessage(TXT("RecordsNodeDestroyed")); aUserVarInc(5); aUserVarInc(4); if (qUserVarValue(5) > 7.000000f) { @@ -3857,7 +3637,7 @@ int16_t CustomObjectScript_11BA::CallEvent(int event, tOSIRISEventInfo *data) { // Script 044: Novak Prison Records Node A Destroyed if (1) { - aShowHUDMessage(Message_strings[31]); + aShowHUDMessage(TXT("RecordsNodeDestroyed")); aUserVarInc(5); aUserVarInc(4); if (qUserVarValue(5) > 7.000000f) { @@ -3888,7 +3668,7 @@ int16_t CustomObjectScript_09C9::CallEvent(int event, tOSIRISEventInfo *data) { // Script 096: Novak Prison Records Node P Destroyed if (1) { - aShowHUDMessage(Message_strings[31]); + aShowHUDMessage(TXT("RecordsNodeDestroyed")); aUserVarInc(6); aUserVarInc(4); if (qUserVarValue(6) > 7.000000f) { @@ -3919,7 +3699,7 @@ int16_t CustomObjectScript_09C8::CallEvent(int event, tOSIRISEventInfo *data) { // Script 095: Novak Prison Records Node O Destroyed if (1) { - aShowHUDMessage(Message_strings[31]); + aShowHUDMessage(TXT("RecordsNodeDestroyed")); aUserVarInc(6); aUserVarInc(4); if (qUserVarValue(6) > 7.000000f) { @@ -3950,7 +3730,7 @@ int16_t CustomObjectScript_09C7::CallEvent(int event, tOSIRISEventInfo *data) { // Script 094: Novak Prison Records Node N Destroyed if (1) { - aShowHUDMessage(Message_strings[31]); + aShowHUDMessage(TXT("RecordsNodeDestroyed")); aUserVarInc(6); aUserVarInc(4); if (qUserVarValue(6) > 7.000000f) { @@ -3981,7 +3761,7 @@ int16_t CustomObjectScript_09C6::CallEvent(int event, tOSIRISEventInfo *data) { // Script 093: Novak Prison Records Node M Destroyed if (1) { - aShowHUDMessage(Message_strings[31]); + aShowHUDMessage(TXT("RecordsNodeDestroyed")); aUserVarInc(6); aUserVarInc(4); if (qUserVarValue(6) > 7.000000f) { @@ -4012,7 +3792,7 @@ int16_t CustomObjectScript_09C5::CallEvent(int event, tOSIRISEventInfo *data) { // Script 092: Novak Prison Records Node L Destroyed if (1) { - aShowHUDMessage(Message_strings[31]); + aShowHUDMessage(TXT("RecordsNodeDestroyed")); aUserVarInc(6); aUserVarInc(4); if (qUserVarValue(6) > 7.000000f) { @@ -4043,7 +3823,7 @@ int16_t CustomObjectScript_09C4::CallEvent(int event, tOSIRISEventInfo *data) { // Script 091: Novak Prison Records Node K Destroyed if (1) { - aShowHUDMessage(Message_strings[31]); + aShowHUDMessage(TXT("RecordsNodeDestroyed")); aUserVarInc(6); aUserVarInc(4); if (qUserVarValue(6) > 7.000000f) { @@ -4074,7 +3854,7 @@ int16_t CustomObjectScript_09C3::CallEvent(int event, tOSIRISEventInfo *data) { // Script 090: Novak Prison Records Node J Destroyed if (1) { - aShowHUDMessage(Message_strings[31]); + aShowHUDMessage(TXT("RecordsNodeDestroyed")); aUserVarInc(6); aUserVarInc(4); if (qUserVarValue(6) > 7.000000f) { @@ -4105,7 +3885,7 @@ int16_t CustomObjectScript_09C2::CallEvent(int event, tOSIRISEventInfo *data) { // Script 089: Novak Prison Records Node I Destroyed if (1) { - aShowHUDMessage(Message_strings[31]); + aShowHUDMessage(TXT("RecordsNodeDestroyed")); aUserVarInc(6); aUserVarInc(4); if (qUserVarValue(6) > 7.000000f) { @@ -4136,7 +3916,7 @@ int16_t CustomObjectScript_094E::CallEvent(int event, tOSIRISEventInfo *data) { // Script 043: Novak Super Computer Destroyed if (1) { - aShowHUDMessage(Message_strings[32]); + aShowHUDMessage(TXT("ComputerDestroyed")); aUserFlagSet(15, 1); aRoomSetFaceTexture(Room_indexes[57], 158, Texture_indexes[11]); aRoomSetFaceTexture(Room_indexes[57], 157, Texture_indexes[11]); @@ -4277,7 +4057,7 @@ int16_t TriggerScript_0001::CallEvent(int event, tOSIRISEventInfo *data) { aMatcenSetState(1, Matcen_indexes[11]); aMatcenSetState(1, Matcen_indexes[12]); aSetLevelTimer(10.000000f, 0); - aShowHUDMessage(Message_strings[24]); + aShowHUDMessage(TXT("ChemicalReactionAlert")); aObjMakeVulnerable(Object_handles[40]); aSetLevelTimer(3.000000f, 10); diff --git a/scripts/Level2_FRN.msg b/scripts/level2_FRN.msg similarity index 100% rename from scripts/Level2_FRN.msg rename to scripts/level2_FRN.msg diff --git a/scripts/level2_Ger.msg b/scripts/level2_GER.msg similarity index 100% rename from scripts/level2_Ger.msg rename to scripts/level2_GER.msg diff --git a/scripts/Level2_ITN.msg b/scripts/level2_ITN.msg similarity index 100% rename from scripts/Level2_ITN.msg rename to scripts/level2_ITN.msg diff --git a/scripts/level3.cpp b/scripts/level3.cpp index b5b536982..5dc53e181 100644 --- a/scripts/level3.cpp +++ b/scripts/level3.cpp @@ -22,10 +22,10 @@ // Filename: level3.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -953,180 +953,12 @@ void RestoreGlobalActionCtrs(void *file_ptr) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} +std::map Messages; -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -1258,7 +1090,6 @@ const char *Message_names[NUM_MESSAGE_NAMES] = {"IntroMessage", "ForceFieldDea "TempGetData", "EndLevel", "LTSelfDestruct", "UploadNode", "SecurityDoor"}; -const char *Message_strings[NUM_MESSAGE_NAMES]; // =============== // InitializeDLL() @@ -1273,26 +1104,16 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "level3.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { mprintf(0, "ERROR: Could not load message file - %s\n", filename); @@ -1339,10 +1160,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } @@ -2074,7 +1891,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 071: IntroCam if (1 == true) { - aCinematicIntro(Path_indexes[0], Message_strings[0], Object_handles[8], Path_indexes[1], 15.000000f); + aCinematicIntro(Path_indexes[0], TXT("IntroMessage"), Object_handles[8], Path_indexes[1], 15.000000f); // Increment the script action counter if (ScriptActionCtr_071 < MAX_ACTION_CTR_VALUE) @@ -2120,8 +1937,8 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aGoalCompleted(Goal_indexes[2], 1); aRoomSetFaceTexture(Room_indexes[3], 42, Texture_indexes[4]); aPortalRenderSet(0, 0, Room_indexes[4], 1); - aShowHUDMessage(Message_strings[5]); - aShowHUDMessage(Message_strings[6]); + aShowHUDMessage(TXT("All4Radio")); + aShowHUDMessage(TXT("All4Radio2")); aUserVarSet(4, 1.000000f); aSoundPlaySteaming("VoxDispatcher.osf", 0.500000f); @@ -2155,7 +1972,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aTurnOnSpew(Object_handles[41], -1, 16, 0.000000f, 0.000000f, 65536, 0, 1.000000f, 0.090000f, 8.000000f, 3.000000f, 30.000000f, 0, -1); aObjSpark(Object_handles[3], 50.000000f, 5.000000f); - aCinematicSimple(Path_indexes[2], Message_strings[8], Object_handles[2], 17.500000f, 1); + aCinematicSimple(Path_indexes[2], TXT("SuperIntro"), Object_handles[2], 17.500000f, 1); aSetLevelTimer(5.000000f, 11); // Increment the script action counter @@ -2213,7 +2030,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aPortalBreakGlass(9, Room_indexes[5]); aPortalBreakGlass(10, Room_indexes[5]); aPortalBreakGlass(11, Room_indexes[5]); - aStartEndlevelSequencePath(Path_indexes[6], Path_indexes[7], 10.000000f, Message_strings[19]); + aStartEndlevelSequencePath(Path_indexes[6], Path_indexes[7], 10.000000f, TXT("EndLevel")); // Increment the script action counter if (ScriptActionCtr_005 < MAX_ACTION_CTR_VALUE) @@ -2241,7 +2058,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { if ((qObjExists(qObjSavedHandle(5)) == false) && (qObjExists(qObjSavedHandle(6)) == false) && (qObjExists(qObjSavedHandle(7)) == false) && (qObjExists(qObjSavedHandle(8)) == false)) { aGoalCompleted(Goal_indexes[10], 1); - aShowHUDMessage(Message_strings[20]); + aShowHUDMessage(TXT("LTSelfDestruct")); aObjSpark(Object_handles[10], 50.000000f, 20.000000f); aSetScriptedDeath(Object_handles[10], 1); } else { @@ -2367,7 +2184,7 @@ int16_t CustomObjectScript_2109::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[0], data->me_handle, 1.000000f); aObjPlayAnim(data->me_handle, 0, 4, 2.000000f, 0); aPortalRenderSet(0, 1, Room_indexes[0], 1); - aShowHUDMessage(Message_strings[1]); + aShowHUDMessage(TXT("ForceFieldDeactivated")); // Increment the script action counter if (ScriptActionCtr_001 < MAX_ACTION_CTR_VALUE) @@ -2410,7 +2227,7 @@ int16_t CustomObjectScript_1AE9::CallEvent(int event, tOSIRISEventInfo *data) { aTurnOnSpew(Object_handles[11], 0, 8, 0.000000f, 0.000000f, 65536, 0, 1.200000f, 0.130000f, -1.000000f, 4.000000f, 20.000000f, 0, -1); aPortalRenderSet(0, 0, Room_indexes[1], 1); - aShowHUDMessage(Message_strings[1]); + aShowHUDMessage(TXT("ForceFieldDeactivated")); // Increment the script action counter if (ScriptActionCtr_015 < MAX_ACTION_CTR_VALUE) @@ -2435,7 +2252,7 @@ int16_t CustomObjectScript_206D::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlayObject(Sound_indexes[0], data->me_handle, 1.000000f); aObjPlayAnim(data->me_handle, 0, 4, 2.000000f, 0); aPortalRenderSet(0, 0, Room_indexes[2], 1); - aShowHUDMessage(Message_strings[1]); + aShowHUDMessage(TXT("ForceFieldDeactivated")); // Increment the script action counter if (ScriptActionCtr_004 < MAX_ACTION_CTR_VALUE) @@ -2453,9 +2270,9 @@ int16_t CustomObjectScript_117F::CallEvent(int event, tOSIRISEventInfo *data) { // Script 016: KeyCard2 if (qObjIsPlayer(event_data->it_handle) == true) { - aObjectPlayerGiveKey(event_data->it_handle, data->me_handle, 1, Message_strings[2], 0); + aObjectPlayerGiveKey(event_data->it_handle, data->me_handle, 1, TXT("MainKeyCard"), 0); aGoalCompleted(Goal_indexes[1], 1); - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("MainKeyCard")); aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); // Increment the script action counter @@ -2479,11 +2296,11 @@ int16_t CustomObjectScript_184A::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_017 > 0) == true) { aMatcenSetState(1, Matcen_indexes[0]); aCreatePopupView(0, Object_handles[14], 8.000000f, 1.000000f); - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("RadioRoomUnlock")); aDoorLockUnlock(0, Door_handles[0]); aDoorSetPos(Door_handles[0], 1.000000f); } else { - aShowHUDMessage(Message_strings[4]); + aShowHUDMessage(TXT("RadioRoomFirst")); } // Increment the script action counter @@ -2507,11 +2324,11 @@ int16_t CustomObjectScript_4049::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_009 > 0) == true) { aMatcenSetState(1, Matcen_indexes[0]); aCreatePopupView(0, Object_handles[14], 8.000000f, 1.000000f); - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("RadioRoomUnlock")); aDoorLockUnlock(0, Door_handles[0]); aDoorSetPos(Door_handles[0], 1.000000f); } else { - aShowHUDMessage(Message_strings[4]); + aShowHUDMessage(TXT("RadioRoomFirst")); } // Increment the script action counter @@ -3311,7 +3128,7 @@ int16_t CustomObjectScript_202B::CallEvent(int event, tOSIRISEventInfo *data) { // Script 111: OctaStore (First Time) (THIEF BACKUP) if ((ScriptActionCtr_111 < 1) && (((ScriptActionCtr_092 > 0) == false) && (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true))) { - aShowHUDMessage(Message_strings[7]); + aShowHUDMessage(TXT("ThiefGotIt")); aAISetMaxSpeed(Object_handles[0], 55.000000f); // Increment the script action counter @@ -3328,7 +3145,7 @@ int16_t CustomObjectScript_202B::CallEvent(int event, tOSIRISEventInfo *data) { // Script 061: ThiefDestroyed if (1) { - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("DestroyedThief")); aStoreObjectInPositionClipboard(data->me_handle); aMoveObjectToPositionClipboard(Object_handles[4]); aObjGhostSet(0, Object_handles[4]); @@ -3352,7 +3169,7 @@ int16_t CustomObjectScript_18D6::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_092 < 1) && ((qDoorLocked(data->me_handle) == false) && (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) && ((ScriptActionCtr_111 > 0) == false))) { - aShowHUDMessage(Message_strings[7]); + aShowHUDMessage(TXT("ThiefGotIt")); aAISetMaxSpeed(Object_handles[0], 55.000000f); // Increment the script action counter @@ -3375,7 +3192,7 @@ int16_t CustomObjectScript_202D::CallEvent(int event, tOSIRISEventInfo *data) { // Script 087: SuperThiefDestroyed if (1) { - aShowHUDMessage(Message_strings[10]); + aShowHUDMessage(TXT("DestroyedSuper")); aStoreObjectInPositionClipboard(data->me_handle); aMoveObjectToPositionClipboard(Object_handles[3]); aObjGhostSet(0, Object_handles[3]); @@ -3391,7 +3208,7 @@ int16_t CustomObjectScript_202D::CallEvent(int event, tOSIRISEventInfo *data) { // Script 089: ThiefIntro Done if ((ScriptActionCtr_089 < 1) && (1)) { aSoundPlaySteaming("VoxL03SpecificD.osf", 1.000000f); - aShowHUDMessage(Message_strings[9]); + aShowHUDMessage(TXT("KillSuper")); // Increment the script action counter if (ScriptActionCtr_089 < MAX_ACTION_CTR_VALUE) @@ -3409,7 +3226,7 @@ int16_t CustomObjectScript_21CD::CallEvent(int event, tOSIRISEventInfo *data) { // Script 090: False Data Transfer if ((qObjIsPlayerWeapon(event_data->it_handle) == true) && (qUserFlag(9) == false)) { - aShowHUDMessage(Message_strings[11]); + aShowHUDMessage(TXT("FalseTransfer")); // Increment the script action counter if (ScriptActionCtr_090 < MAX_ACTION_CTR_VALUE) @@ -3420,7 +3237,7 @@ int16_t CustomObjectScript_21CD::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_060 < 1) && ((qObjIsPlayerWeapon(event_data->it_handle) == true) && (qUserFlag(9) == true))) { aGoalCompleted(Goal_indexes[3], 1); aGoalEnableDisable(1, Goal_indexes[4]); - aShowHUDMessage(Message_strings[12]); + aShowHUDMessage(TXT("Uploading")); aSetLevelTimer(3.000000f, 10); aSoundPlayObject(Sound_indexes[4], data->me_handle, 1.000000f); aObjPlayAnim(data->me_handle, 0, 3, 3.000000f, 0); @@ -3443,7 +3260,7 @@ int16_t CustomObjectScript_182E::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_049 < 1) && ((qObjIsPlayer(event_data->it_handle) == true) && (qObjExists(Object_handles[2]) == false) && (qUserFlag(9) == true))) { aGoalCompleted(Goal_indexes[4], 1); - aShowHUDMessage(Message_strings[14]); + aShowHUDMessage(TXT("DataFinal")); aSoundPlaySteamingObj("VoxL03EndLevel.osf", event_data->it_handle, 1.000000f); aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); aObjSaveHandle(event_data->it_handle, 17); @@ -3484,7 +3301,7 @@ int16_t CustomObjectScript_31CC::CallEvent(int event, tOSIRISEventInfo *data) { aGoalEnableDisable(1, Goal_indexes[3]); aGoalEnableDisable(1, Goal_indexes[5]); aGoalCompleted(Goal_indexes[6], 1); - aShowHUDMessage(Message_strings[15]); + aShowHUDMessage(TXT("DataOriginal")); aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); aAddObjectToInventory(data->me_handle, event_data->it_handle, 0); @@ -3500,12 +3317,12 @@ int16_t CustomObjectScript_31CC::CallEvent(int event, tOSIRISEventInfo *data) { if (1) { if (qObjGetDistance(event_data->it_handle, Object_handles[3]) < 30.000000f) { aGoalCompleted(Goal_indexes[5], 1); - aShowHUDMessage(Message_strings[16]); + aShowHUDMessage(TXT("PlaceCartridge")); aUserFlagSet(9, 1); aStoreObjectInPositionClipboard(Object_handles[3]); aObjGhostSet(0, Object_handles[3]); } else { - aShowHUDMessage(Message_strings[17]); + aShowHUDMessage(TXT("DataNodes")); aObjGhostSet(0, data->me_handle); aAddObjectToInventory(data->me_handle, event_data->it_handle, 0); } @@ -3607,9 +3424,9 @@ int16_t CustomObjectScript_100C::CallEvent(int event, tOSIRISEventInfo *data) { // Script 106: SecurityDoor if ((qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) && ((ScriptActionCtr_016 > 0) == false)) { if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[22], event_data->it_handle); + aShowHUDMessageObj(TXT("SecurityDoor"), event_data->it_handle); } else { - aShowHUDMessageObj(Message_strings[22], qObjParent(event_data->it_handle)); + aShowHUDMessageObj(TXT("SecurityDoor"), qObjParent(event_data->it_handle)); } // Increment the script action counter @@ -4173,7 +3990,7 @@ int16_t TriggerScript_001C::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlaySteaming("VoxL03SpecificB.osf", 1.000000f); aGoalCompleted(Goal_indexes[7], 1); aSetWaypoint(8); - aShowHUDMessage(Message_strings[18]); + aShowHUDMessage(TXT("TempGetData")); // Increment the script action counter if (ScriptActionCtr_029 < MAX_ACTION_CTR_VALUE) @@ -4191,7 +4008,7 @@ int16_t TriggerScript_001E::CallEvent(int event, tOSIRISEventInfo *data) { // Script 105: Upload Node Description if ((ScriptActionCtr_105 < 1) && (1)) { - aShowHUDMessage(Message_strings[21]); + aShowHUDMessage(TXT("UploadNode")); // Increment the script action counter if (ScriptActionCtr_105 < MAX_ACTION_CTR_VALUE) diff --git a/scripts/Level3_FRN.msg b/scripts/level3_FRN.msg similarity index 100% rename from scripts/Level3_FRN.msg rename to scripts/level3_FRN.msg diff --git a/scripts/level3_Ger.msg b/scripts/level3_GER.msg similarity index 100% rename from scripts/level3_Ger.msg rename to scripts/level3_GER.msg diff --git a/scripts/Level3_ITN.msg b/scripts/level3_ITN.msg similarity index 100% rename from scripts/Level3_ITN.msg rename to scripts/level3_ITN.msg diff --git a/scripts/level4.cpp b/scripts/level4.cpp index f0d614914..5f9b9231b 100644 --- a/scripts/level4.cpp +++ b/scripts/level4.cpp @@ -22,10 +22,10 @@ // Filename: level4.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -435,180 +435,12 @@ void RestoreGlobalActionCtrs(void *file_ptr) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} +std::map Messages; -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -662,12 +494,6 @@ const char *Goal_names[NUM_GOAL_NAMES] = {"Upload the data to Suzuki", "Defeat t "Give the Data to Suzuki and Return Safely"}; int Goal_indexes[NUM_GOAL_NAMES]; -#define NUM_MESSAGE_NAMES 8 -const char *Message_names[NUM_MESSAGE_NAMES] = {"CinematicIntroCam", "PutTheCartridge", "CinematicDataCart", - "CartridgeError", "GetOut", "CinematicAmbush", - "BPDefeated", "CinematicEndCam"}; -const char *Message_strings[NUM_MESSAGE_NAMES]; - // =============== // InitializeDLL() // =============== @@ -681,26 +507,16 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "level4.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { mprintf(0, "ERROR: Could not load message file - %s\n", filename); @@ -747,10 +563,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } @@ -1009,7 +821,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 033: Level Start Intro Cam if (1 == true) { - aCinematicIntro(Path_indexes[0], Message_strings[0], Object_handles[0], Path_indexes[1], 10.000000f); + aCinematicIntro(Path_indexes[0], TXT("CinematicIntroCam"), Object_handles[0], Path_indexes[1], 10.000000f); // Increment the script action counter if (ScriptActionCtr_033 < MAX_ACTION_CTR_VALUE) @@ -1620,7 +1432,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aCloakObject(Object_handles[30], 10.000000f); aAISetMaxSpeed(Object_handles[30], 40.000000f); aAIGoalFollowPathSimple(Object_handles[30], Path_indexes[10], 4352, -1, 3); - aStartEndlevelSequencePath(Path_indexes[11], Path_indexes[12], 10.000000f, Message_strings[7]); + aStartEndlevelSequencePath(Path_indexes[11], Path_indexes[12], 10.000000f, TXT("CinematicEndCam")); // Increment the script action counter if (ScriptActionCtr_037 < MAX_ACTION_CTR_VALUE) @@ -1833,7 +1645,7 @@ int16_t CustomObjectScript_08B3::CallEvent(int event, tOSIRISEventInfo *data) { // Script 031: Data Cartridge USE if (1) { if (qObjGetDistance(Object_handles[15], event_data->it_handle) < 35.000000f) { - aCinematicSimple(Path_indexes[6], Message_strings[2], Object_handles[15], 10.000000f, 1); + aCinematicSimple(Path_indexes[6], TXT("CinematicDataCart"), Object_handles[15], 10.000000f, 1); aStoreObjectInPositionClipboard(Object_handles[16]); aMoveObjectToPositionClipboard(data->me_handle); aObjGhostSet(0, data->me_handle); @@ -1861,7 +1673,7 @@ int16_t CustomObjectScript_08B3::CallEvent(int event, tOSIRISEventInfo *data) { } else { aObjGhostSet(0, data->me_handle); aAddObjectToInventory(data->me_handle, event_data->it_handle, 0); - aShowHUDMessageObj(Message_strings[3], event_data->it_handle); + aShowHUDMessageObj(TXT("CartridgeError"), event_data->it_handle); } // Increment the script action counter @@ -1880,7 +1692,7 @@ int16_t CustomObjectScript_08AE::CallEvent(int event, tOSIRISEventInfo *data) { // Script 032: After Upload Movie if (1) { - aShowHUDMessage(Message_strings[4]); + aShowHUDMessage(TXT("GetOut")); // Increment the script action counter if (ScriptActionCtr_032 < MAX_ACTION_CTR_VALUE) @@ -1903,7 +1715,7 @@ int16_t CustomObjectScript_1213::CallEvent(int event, tOSIRISEventInfo *data) { // Script 039: Merc Died 2 if (qObjExists(Object_handles[32]) == false) { aGoalCompleted(Goal_indexes[1], 1); - aShowHUDMessage(Message_strings[6]); + aShowHUDMessage(TXT("BPDefeated")); aSetLevelTimer(3.000000f, 5); // Increment the script action counter @@ -1927,7 +1739,7 @@ int16_t CustomObjectScript_117D::CallEvent(int event, tOSIRISEventInfo *data) { // Script 038: Merc Died 1 if (qObjExists(Object_handles[33]) == false) { aGoalCompleted(Goal_indexes[1], 1); - aShowHUDMessage(Message_strings[6]); + aShowHUDMessage(TXT("BPDefeated")); aSetLevelTimer(3.000000f, 5); // Increment the script action counter @@ -1946,7 +1758,7 @@ int16_t TriggerScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 029: Entered Suzuki if ((ScriptActionCtr_029 < 1) && (1)) { - aShowHUDMessage(Message_strings[1]); + aShowHUDMessage(TXT("PutTheCartridge")); // Increment the script action counter if (ScriptActionCtr_029 < MAX_ACTION_CTR_VALUE) @@ -1970,7 +1782,7 @@ int16_t TriggerScript_0001::CallEvent(int event, tOSIRISEventInfo *data) { aObjGhostSet(0, Object_handles[32]); aAIGoalFollowPathSimple(Object_handles[33], Path_indexes[7], 1048832, 4, 3); aAIGoalFollowPathSimple(Object_handles[32], Path_indexes[8], 1048832, 5, 3); - aCinematicSimple(Path_indexes[9], Message_strings[5], Object_handles[31], 5.000000f, 1); + aCinematicSimple(Path_indexes[9], TXT("CinematicAmbush"), Object_handles[31], 5.000000f, 1); // Increment the script action counter if (ScriptActionCtr_035 < MAX_ACTION_CTR_VALUE) diff --git a/scripts/Level4_FRN.msg b/scripts/level4_FRN.msg similarity index 100% rename from scripts/Level4_FRN.msg rename to scripts/level4_FRN.msg diff --git a/scripts/level4_Ger.msg b/scripts/level4_GER.msg similarity index 100% rename from scripts/level4_Ger.msg rename to scripts/level4_GER.msg diff --git a/scripts/Level4_ITN.msg b/scripts/level4_ITN.msg similarity index 100% rename from scripts/Level4_ITN.msg rename to scripts/level4_ITN.msg diff --git a/scripts/level5.cpp b/scripts/level5.cpp index 3f941c54b..1b8c10dc0 100644 --- a/scripts/level5.cpp +++ b/scripts/level5.cpp @@ -23,10 +23,9 @@ // Version: 3 ///////////////////////////////////////////////////////////////////// #include -#include -#include -#include -#include +#include +#include +#include #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -597,6 +596,17 @@ void RestoreGlobalActionCtrs(void *file_ptr) { ScriptActionCtr_030 = File_ReadInt(file_ptr); } +// ================= +// Message File Data +// ================= + +// Global storage for level script messages +std::map Messages; + +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) + // =============================================================== // Start of Custom Script Block - DO NOT EDIT ANYTHING BEFORE THIS // =============================================================== @@ -620,8 +630,6 @@ float Reactor_initial_shields[NUM_REACTORS]; int Reactor_shields_percent[NUM_REACTORS]; const char *Reactor_text; -const char *GetMessage(const char *name); - /* $$ACTION Custom @@ -646,7 +654,7 @@ void aCustomReactorDisplayInit() { Reactor_shields_percent[i] = -1; // Force update first time } - Reactor_text = GetMessage("ReactorHUDLabel"); + Reactor_text = TXT("ReactorHUDLabel"); } /* @@ -707,7 +715,7 @@ void dsCustomRestore(void *fileptr) { Reactor_shields_percent[i] = File_ReadInt(fileptr); } - Reactor_text = GetMessage("ReactorHUDLabel"); + Reactor_text = TXT("ReactorHUDLabel"); } /**{CUSTOM_SCRIPT_BLOCK_END}**** DO NOT EDIT! **/ @@ -715,185 +723,6 @@ void dsCustomRestore(void *fileptr) { // End of Custom Script Block - DO NOT EDIT ANYTHING AFTER THIS // ============================================================ -// ================= -// Message File Data -// ================= - -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - -// Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} - -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} - //====================== // Name List Arrays //====================== @@ -972,20 +801,6 @@ const char *Goal_names[NUM_GOAL_NAMES] = {"Keep Reactor 5 Alive", "Keep Rea "Escape from Red Acropolis", "Keep 3 of the 5 reactors alive"}; int Goal_indexes[NUM_GOAL_NAMES]; -#define NUM_MESSAGE_NAMES 21 -const char *Message_names[NUM_MESSAGE_NAMES] = {"IntroMessage", "DefendThoseReactors2", - "IncomingMessage", "DefendReactorsShort", - "Reactor5Status", "Health75", - "Reactor4Status", "Reactor3Status", - "Reactor2Status", "Reactor1Status", - "Health50", "Health25", - "Destroyed", "HITPOINTS", - "BLANK", "OOPS", - "WereGettinOut", "SelfDestruct", - "ExitOnly", "EntranceDoorMessage", - "30SecondsLeft"}; -const char *Message_strings[NUM_MESSAGE_NAMES]; - // =============== // InitializeDLL() // =============== @@ -999,26 +814,16 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "level5.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { mprintf(0, "ERROR: Could not load message file - %s\n", filename); @@ -1065,10 +870,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } @@ -1508,7 +1309,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 036: 3 Reactors Dead if ((ScriptActionCtr_036 < 1) && ((qUserVarValueInt(1) >= 3) && ((ScriptActionCtr_069 > 0) == false))) { - aAddGameMessage(Message_strings[15], Message_strings[2]); + aAddGameMessage(TXT("OOPS"), TXT("IncomingMessage")); aGoalFailed(Goal_indexes[7], 1); aSetLevelTimer(3.000000f, 5); @@ -1542,7 +1343,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 001: StartIntroMovie if (1) { - aCinematicIntro(Path_indexes[8], Message_strings[0], Object_handles[5], Path_indexes[9], 10.000000f); + aCinematicIntro(Path_indexes[8], TXT("IntroMessage"), Object_handles[5], Path_indexes[9], 10.000000f); aSetLevelTimer(2.000000f, 1); // Increment the script action counter @@ -1604,10 +1405,10 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aGoalEnableDisable(0, Goal_indexes[2]); aGoalEnableDisable(0, Goal_indexes[3]); aGoalEnableDisable(0, Goal_indexes[4]); - aAddGameMessage(Message_strings[16], Message_strings[2]); + aAddGameMessage(TXT("WereGettinOut"), TXT("IncomingMessage")); aDoorLockUnlock(0, Door_handles[0]); aDoorSetPos(Door_handles[0], 1.000000f); - aShowHUDMessage(Message_strings[17]); + aShowHUDMessage(TXT("SelfDestruct")); aSetLevelTimer(60.000000f, 13); // Increment the script action counter @@ -1662,7 +1463,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 029: 30Seconds Left if ((event_data->id == 13) && (qUserVarValue(8) == 0.000000f)) { - aShowHUDMessage(Message_strings[20]); + aShowHUDMessage(TXT("30SecondsLeft")); aSetLevelTimer(30.000000f, 3); aTimerShow(3); @@ -1676,7 +1477,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlay2D(Sound_indexes[2], 1.000000f); aSoundPlay2D(Sound_indexes[3], 1.000000f); aSoundPlay2D(Sound_indexes[4], 1.000000f); - aFadeWhiteAndEndlevel(3.000000f, Message_strings[14]); + aFadeWhiteAndEndlevel(3.000000f, TXT("BLANK")); // Increment the script action counter if (ScriptActionCtr_039 < MAX_ACTION_CTR_VALUE) @@ -1849,8 +1650,8 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aObjPlayAnim(Object_handles[2], 0, 32, 4.000000f, 1); aObjPlayAnim(Object_handles[1], 0, 32, 4.000000f, 1); aObjPlayAnim(Object_handles[0], 0, 32, 4.000000f, 1); - aAddGameMessage(Message_strings[1], Message_strings[2]); - aShowHUDMessage(Message_strings[3]); + aAddGameMessage(TXT("DefendThoseReactors2"), TXT("IncomingMessage")); + aShowHUDMessage(TXT("DefendReactorsShort")); // Increment the script action counter if (ScriptActionCtr_009 < MAX_ACTION_CTR_VALUE) @@ -1859,7 +1660,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 031: Exit Sequence Part 2 if ((ScriptActionCtr_011 > 0) == true) { - aStartEndlevelSequencePath(Path_indexes[10], Path_indexes[11], 9.000000f, Message_strings[14]); + aStartEndlevelSequencePath(Path_indexes[10], Path_indexes[11], 9.000000f, TXT("BLANK")); // Increment the script action counter if (ScriptActionCtr_031 < MAX_ACTION_CTR_VALUE) @@ -1877,8 +1678,8 @@ int16_t CustomObjectScript_200D::CallEvent(int event, tOSIRISEventInfo *data) { // Script 027: Reactor5Status75percent if ((ScriptActionCtr_027 < 1) && ((qObjShields(data->me_handle) < 22500.000000f) && (1))) { - aShowHUDMessage(Message_strings[4]); - aShowColoredHUDMessage(255, 255, 0, Message_strings[5]); + aShowHUDMessage(TXT("Reactor5Status")); + aShowColoredHUDMessage(255, 255, 0, TXT("Health75")); aRoomSetFaceTexture(Room_indexes[0], 3, Texture_indexes[0]); // Increment the script action counter @@ -1888,8 +1689,8 @@ int16_t CustomObjectScript_200D::CallEvent(int event, tOSIRISEventInfo *data) { // Script 023: Reactor5Status50percent if ((ScriptActionCtr_023 < 1) && ((qObjShields(data->me_handle) < 15000.000000f) && (1))) { - aShowHUDMessage(Message_strings[4]); - aShowColoredHUDMessage(255, 255, 0, Message_strings[10]); + aShowHUDMessage(TXT("Reactor5Status")); + aShowColoredHUDMessage(255, 255, 0, TXT("Health50")); aRoomSetFaceTexture(Room_indexes[0], 3, Texture_indexes[1]); // Increment the script action counter @@ -1899,8 +1700,8 @@ int16_t CustomObjectScript_200D::CallEvent(int event, tOSIRISEventInfo *data) { // Script 019: Reactor5Status25percent if ((ScriptActionCtr_019 < 1) && ((qObjShields(data->me_handle) < 7500.000000f) && (1))) { - aShowHUDMessage(Message_strings[4]); - aShowColoredHUDMessage(255, 0, 0, Message_strings[11]); + aShowHUDMessage(TXT("Reactor5Status")); + aShowColoredHUDMessage(255, 0, 0, TXT("Health25")); aRoomSetFaceTexture(Room_indexes[0], 3, Texture_indexes[2]); // Increment the script action counter @@ -1911,8 +1712,8 @@ int16_t CustomObjectScript_200D::CallEvent(int event, tOSIRISEventInfo *data) { // Script 014: Reactor5StatusDestroyed if ((ScriptActionCtr_014 < 1) && ((qObjShields(data->me_handle) <= 0.000000f) && (1))) { aAISetTeam(196608, data->me_handle); - aShowHUDMessage(Message_strings[4]); - aShowColoredHUDMessage(255, 0, 0, Message_strings[12]); + aShowHUDMessage(TXT("Reactor5Status")); + aShowColoredHUDMessage(255, 0, 0, TXT("Destroyed")); aUserVarInc(1); aObjPlayAnim(data->me_handle, 0, 0, 1.000000f, 0); aObjSpark(data->me_handle, 40.000000f, 99999.000000f); @@ -1928,7 +1729,7 @@ int16_t CustomObjectScript_200D::CallEvent(int event, tOSIRISEventInfo *data) { // Script 002: Debug Script for Reactor 1 if (0 == true) { - aShowHUDMessageF(Message_strings[13], qObjShields(Object_handles[4])); + aShowHUDMessageF(TXT("HITPOINTS"), qObjShields(Object_handles[4])); // Increment the script action counter if (ScriptActionCtr_002 < MAX_ACTION_CTR_VALUE) @@ -1946,8 +1747,8 @@ int16_t CustomObjectScript_281B::CallEvent(int event, tOSIRISEventInfo *data) { // Script 026: Reactor4Status75percent if ((ScriptActionCtr_026 < 1) && ((qObjShields(data->me_handle) < 22500.000000f) && (1))) { - aShowHUDMessage(Message_strings[6]); - aShowColoredHUDMessage(255, 255, 0, Message_strings[5]); + aShowHUDMessage(TXT("Reactor4Status")); + aShowColoredHUDMessage(255, 255, 0, TXT("Health75")); aRoomSetFaceTexture(Room_indexes[1], 3, Texture_indexes[0]); // Increment the script action counter @@ -1957,8 +1758,8 @@ int16_t CustomObjectScript_281B::CallEvent(int event, tOSIRISEventInfo *data) { // Script 022: Reactor4Status50percent if ((ScriptActionCtr_022 < 1) && ((qObjShields(data->me_handle) < 15000.000000f) && (1))) { - aShowHUDMessage(Message_strings[6]); - aShowColoredHUDMessage(255, 255, 0, Message_strings[10]); + aShowHUDMessage(TXT("Reactor4Status")); + aShowColoredHUDMessage(255, 255, 0, TXT("Health50")); aRoomSetFaceTexture(Room_indexes[1], 3, Texture_indexes[1]); // Increment the script action counter @@ -1968,8 +1769,8 @@ int16_t CustomObjectScript_281B::CallEvent(int event, tOSIRISEventInfo *data) { // Script 018: Reactor4Status25percent if ((ScriptActionCtr_018 < 1) && ((qObjShields(data->me_handle) < 7500.000000f) && (1))) { - aShowHUDMessage(Message_strings[6]); - aShowColoredHUDMessage(255, 0, 0, Message_strings[11]); + aShowHUDMessage(TXT("Reactor4Status")); + aShowColoredHUDMessage(255, 0, 0, TXT("Health25")); aRoomSetFaceTexture(Room_indexes[1], 3, Texture_indexes[2]); // Increment the script action counter @@ -1980,8 +1781,8 @@ int16_t CustomObjectScript_281B::CallEvent(int event, tOSIRISEventInfo *data) { // Script 013: Reactor4StatusDestroyed if ((ScriptActionCtr_013 < 1) && ((qObjShields(data->me_handle) <= 0.000000f) && (1))) { aAISetTeam(196608, data->me_handle); - aShowHUDMessage(Message_strings[6]); - aShowColoredHUDMessage(255, 0, 0, Message_strings[12]); + aShowHUDMessage(TXT("Reactor4Status")); + aShowColoredHUDMessage(255, 0, 0, TXT("Destroyed")); aUserVarInc(1); aObjPlayAnim(data->me_handle, 0, 0, 1.000000f, 0); aObjSpark(data->me_handle, 40.000000f, 99999.000000f); @@ -2006,8 +1807,8 @@ int16_t CustomObjectScript_3816::CallEvent(int event, tOSIRISEventInfo *data) { // Script 025: Reactor3Status75percent if ((ScriptActionCtr_025 < 1) && ((qObjShields(data->me_handle) < 22500.000000f) && (1))) { - aShowHUDMessage(Message_strings[7]); - aShowColoredHUDMessage(255, 255, 0, Message_strings[5]); + aShowHUDMessage(TXT("Reactor3Status")); + aShowColoredHUDMessage(255, 255, 0, TXT("Health75")); aRoomSetFaceTexture(Room_indexes[2], 3, Texture_indexes[0]); // Increment the script action counter @@ -2017,8 +1818,8 @@ int16_t CustomObjectScript_3816::CallEvent(int event, tOSIRISEventInfo *data) { // Script 021: Reactor3Status50percent if ((ScriptActionCtr_021 < 1) && ((qObjShields(data->me_handle) < 15000.000000f) && (1))) { - aShowHUDMessage(Message_strings[7]); - aShowColoredHUDMessage(255, 255, 0, Message_strings[10]); + aShowHUDMessage(TXT("Reactor3Status")); + aShowColoredHUDMessage(255, 255, 0, TXT("Health50")); aRoomSetFaceTexture(Room_indexes[2], 3, Texture_indexes[1]); // Increment the script action counter @@ -2028,8 +1829,8 @@ int16_t CustomObjectScript_3816::CallEvent(int event, tOSIRISEventInfo *data) { // Script 016: Reactor3Status25percent if ((ScriptActionCtr_016 < 1) && ((qObjShields(data->me_handle) < 7500.000000f) && (1))) { - aShowHUDMessage(Message_strings[7]); - aShowColoredHUDMessage(255, 0, 0, Message_strings[11]); + aShowHUDMessage(TXT("Reactor3Status")); + aShowColoredHUDMessage(255, 0, 0, TXT("Health25")); aRoomSetFaceTexture(Room_indexes[2], 3, Texture_indexes[2]); // Increment the script action counter @@ -2040,8 +1841,8 @@ int16_t CustomObjectScript_3816::CallEvent(int event, tOSIRISEventInfo *data) { // Script 012: Reactor3StatusDestroyed if ((ScriptActionCtr_012 < 1) && ((qObjShields(data->me_handle) <= 0.000000f) && (1))) { aAISetTeam(196608, data->me_handle); - aShowHUDMessage(Message_strings[7]); - aShowColoredHUDMessage(255, 0, 0, Message_strings[12]); + aShowHUDMessage(TXT("Reactor3Status")); + aShowColoredHUDMessage(255, 0, 0, TXT("Destroyed")); aUserVarInc(1); aObjPlayAnim(data->me_handle, 0, 0, 1.000000f, 0); aObjSpark(data->me_handle, 40.000000f, 99999.000000f); @@ -2066,8 +1867,8 @@ int16_t CustomObjectScript_1012::CallEvent(int event, tOSIRISEventInfo *data) { // Script 024: Reactor2Status75percent if ((ScriptActionCtr_024 < 1) && ((qObjShields(data->me_handle) < 22500.000000f) && (1))) { - aShowHUDMessage(Message_strings[8]); - aShowColoredHUDMessage(255, 255, 0, Message_strings[5]); + aShowHUDMessage(TXT("Reactor2Status")); + aShowColoredHUDMessage(255, 255, 0, TXT("Health75")); aRoomSetFaceTexture(Room_indexes[3], 3, Texture_indexes[0]); // Increment the script action counter @@ -2077,8 +1878,8 @@ int16_t CustomObjectScript_1012::CallEvent(int event, tOSIRISEventInfo *data) { // Script 020: Reactor2Status50percent if ((ScriptActionCtr_020 < 1) && ((qObjShields(data->me_handle) < 15000.000000f) && (1))) { - aShowHUDMessage(Message_strings[8]); - aShowColoredHUDMessage(255, 255, 0, Message_strings[10]); + aShowHUDMessage(TXT("Reactor2Status")); + aShowColoredHUDMessage(255, 255, 0, TXT("Health50")); aRoomSetFaceTexture(Room_indexes[3], 3, Texture_indexes[1]); // Increment the script action counter @@ -2088,8 +1889,8 @@ int16_t CustomObjectScript_1012::CallEvent(int event, tOSIRISEventInfo *data) { // Script 015: Reactor2Status25percent if ((ScriptActionCtr_015 < 1) && ((qObjShields(data->me_handle) < 7500.000000f) && (1))) { - aShowHUDMessage(Message_strings[8]); - aShowColoredHUDMessage(255, 0, 0, Message_strings[11]); + aShowHUDMessage(TXT("Reactor2Status")); + aShowColoredHUDMessage(255, 0, 0, TXT("Health25")); aRoomSetFaceTexture(Room_indexes[3], 3, Texture_indexes[2]); // Increment the script action counter @@ -2100,8 +1901,8 @@ int16_t CustomObjectScript_1012::CallEvent(int event, tOSIRISEventInfo *data) { // Script 008: Reactor2StatusDestroyed if ((ScriptActionCtr_008 < 1) && ((qObjShields(data->me_handle) <= 0.000000f) && (1))) { aAISetTeam(196608, data->me_handle); - aShowHUDMessage(Message_strings[8]); - aShowColoredHUDMessage(255, 0, 0, Message_strings[12]); + aShowHUDMessage(TXT("Reactor2Status")); + aShowColoredHUDMessage(255, 0, 0, TXT("Destroyed")); aUserVarInc(1); aObjPlayAnim(data->me_handle, 0, 0, 1.000000f, 0); aObjSpark(data->me_handle, 40.000000f, 99999.000000f); @@ -2126,8 +1927,8 @@ int16_t CustomObjectScript_181C::CallEvent(int event, tOSIRISEventInfo *data) { // Script 005: Reactor1Status75percent if ((ScriptActionCtr_005 < 1) && ((qObjShields(data->me_handle) < 22500.000000f) && (1))) { - aShowHUDMessage(Message_strings[9]); - aShowColoredHUDMessage(255, 255, 0, Message_strings[5]); + aShowHUDMessage(TXT("Reactor1Status")); + aShowColoredHUDMessage(255, 255, 0, TXT("Health75")); aRoomSetFaceTexture(Room_indexes[4], 3, Texture_indexes[0]); // Increment the script action counter @@ -2137,8 +1938,8 @@ int16_t CustomObjectScript_181C::CallEvent(int event, tOSIRISEventInfo *data) { // Script 006: Reactor1Status50percent if ((ScriptActionCtr_006 < 1) && ((qObjShields(data->me_handle) < 15000.000000f) && (1))) { - aShowHUDMessage(Message_strings[9]); - aShowColoredHUDMessage(255, 255, 0, Message_strings[10]); + aShowHUDMessage(TXT("Reactor1Status")); + aShowColoredHUDMessage(255, 255, 0, TXT("Health50")); aRoomSetFaceTexture(Room_indexes[4], 3, Texture_indexes[1]); // Increment the script action counter @@ -2148,8 +1949,8 @@ int16_t CustomObjectScript_181C::CallEvent(int event, tOSIRISEventInfo *data) { // Script 007: Reactor1Status25percent if ((ScriptActionCtr_007 < 1) && ((qObjShields(data->me_handle) < 7500.000000f) && (1))) { - aShowHUDMessage(Message_strings[9]); - aShowColoredHUDMessage(255, 0, 0, Message_strings[11]); + aShowHUDMessage(TXT("Reactor1Status")); + aShowColoredHUDMessage(255, 0, 0, TXT("Health25")); aRoomSetFaceTexture(Room_indexes[4], 3, Texture_indexes[2]); // Increment the script action counter @@ -2160,8 +1961,8 @@ int16_t CustomObjectScript_181C::CallEvent(int event, tOSIRISEventInfo *data) { // Script 010: Reactor1StatusDestroyed if ((ScriptActionCtr_010 < 1) && ((qObjShields(data->me_handle) <= 0.000000f) && (1))) { aAISetTeam(196608, data->me_handle); - aShowHUDMessage(Message_strings[9]); - aShowColoredHUDMessage(255, 0, 0, Message_strings[12]); + aShowHUDMessage(TXT("Reactor1Status")); + aShowColoredHUDMessage(255, 0, 0, TXT("Destroyed")); aUserVarInc(1); aObjPlayAnim(data->me_handle, 0, 0, 1.000000f, 0); aObjSpark(data->me_handle, 40.000000f, 99999.000000f); @@ -2186,7 +1987,7 @@ int16_t CustomObjectScript_0820::CallEvent(int event, tOSIRISEventInfo *data) { // Script 038: ExitDoorMessage if (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[18]); + aShowHUDMessage(TXT("ExitOnly")); aSoundPlay2DObj(Sound_indexes[1], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -2207,7 +2008,7 @@ int16_t CustomObjectScript_1044::CallEvent(int event, tOSIRISEventInfo *data) { // Script 067: EntranceDoorMessage if (qObjIsPlayerOrPlayerWeapon(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[19]); + aShowHUDMessage(TXT("EntranceDoorMessage")); aSoundPlay2DObj(Sound_indexes[1], event_data->it_handle, 1.000000f); // Increment the script action counter @@ -2230,7 +2031,7 @@ int16_t TriggerScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_011 < 1) && (qObjIsPlayer(event_data->it_handle) == 1)) { aGoalCompleted(Goal_indexes[5], 1); aGoalCompleted(Goal_indexes[6], 1); - aCinematicIntro(Path_indexes[12], Message_strings[14], Object_handles[6], Path_indexes[13], 6.500000f); + aCinematicIntro(Path_indexes[12], TXT("BLANK"), Object_handles[6], Path_indexes[13], 6.500000f); // Increment the script action counter if (ScriptActionCtr_011 < MAX_ACTION_CTR_VALUE) diff --git a/scripts/Level5_FRN.msg b/scripts/level5_FRN.msg similarity index 100% rename from scripts/Level5_FRN.msg rename to scripts/level5_FRN.msg diff --git a/scripts/level5_Ger.msg b/scripts/level5_GER.msg similarity index 100% rename from scripts/level5_Ger.msg rename to scripts/level5_GER.msg diff --git a/scripts/Level5_ITN.msg b/scripts/level5_ITN.msg similarity index 100% rename from scripts/Level5_ITN.msg rename to scripts/level5_ITN.msg diff --git a/scripts/level7.cpp b/scripts/level7.cpp index d96bddb86..64c9997f8 100644 --- a/scripts/level7.cpp +++ b/scripts/level7.cpp @@ -22,10 +22,10 @@ // Filename: level7.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -839,180 +839,12 @@ void RestoreGlobalActionCtrs(void *file_ptr) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} +std::map Messages; -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -1133,7 +965,6 @@ const char *Message_names[NUM_MESSAGE_NAMES] = { "SuperHeaterShutdown", "Virus2Collected", "Virus1Collected", "SteamRelease", "CameraActivation", "Finished", "IntroMessage", "VirusDescription", "Controller", "TurretsInvuln"}; -const char *Message_strings[NUM_MESSAGE_NAMES]; // =============== // InitializeDLL() @@ -1148,26 +979,16 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "level7.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { mprintf(0, "ERROR: Could not load message file - %s\n", filename); @@ -1214,10 +1035,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } @@ -1944,7 +1761,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 045: IntroCam if (1 == true) { - aCinematicIntro(Path_indexes[1], Message_strings[18], Object_handles[29], Path_indexes[2], 20.000000f); + aCinematicIntro(Path_indexes[1], TXT("IntroMessage"), Object_handles[29], Path_indexes[2], 20.000000f); // Increment the script action counter if (ScriptActionCtr_045 < MAX_ACTION_CTR_VALUE) @@ -2001,7 +1818,7 @@ int16_t CustomObjectScript_1097::CallEvent(int event, tOSIRISEventInfo *data) { // Script 000: Turn off Turrets if ((ScriptActionCtr_000 < 1) && (1)) { aMusicSetRegionAll(2); - aShowHUDMessage(Message_strings[1]); + aShowHUDMessage(TXT("TurretsDeactivated")); aPortalRenderSet(0, 0, Room_indexes[0], 1); aPortalRenderSet(0, 0, Room_indexes[1], 1); aPortalRenderSet(0, 0, Room_indexes[2], 1); @@ -2033,7 +1850,7 @@ int16_t CustomObjectScript_1097::CallEvent(int event, tOSIRISEventInfo *data) { // Script 054: Primary Control if ((ScriptActionCtr_054 < 1) && (1)) { - aShowHUDMessage(Message_strings[0]); + aShowHUDMessage(TXT("ControlVulnerable")); aObjSetLightingDist(data->me_handle, 50.000000f); aObjMakeVulnerable(data->me_handle); aSoundPlayObject(Sound_indexes[0], data->me_handle, 1.000000f); @@ -2164,7 +1981,7 @@ int16_t CustomObjectScript_1901::CallEvent(int event, tOSIRISEventInfo *data) { aObjSpark(Object_handles[16], 30.000000f, 999999.000000f); aSoundPlaySteaming("VoxL07SpecificA.osf", 1.000000f); aObjSetLightingDist(Object_handles[16], 0.000000f); - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("CoolersAllGone")); aTurnOnSpew(Object_handles[12], 0, 8, 1.000000f, 0.100000f, 65664, 0, 1.000000f, 0.100000f, 0.000000f, 3.000000f, 20.000000f, 0, 0); aTurnOnSpew(Object_handles[11], 0, 8, 1.000000f, 0.100000f, 65664, 0, 1.000000f, 0.100000f, 0.000000f, 3.000000f, @@ -2295,7 +2112,7 @@ int16_t CustomObjectScript_090C::CallEvent(int event, tOSIRISEventInfo *data) { // Script 004: Unlock Magnet Control Door (2) if ((ScriptActionCtr_004 < 1) && (qObjIsPlayerWeapon(event_data->it_handle) == true)) { if ((ScriptActionCtr_003 > 0) == true) { - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("MagnetTubeDoorUnlock")); aDoorLockUnlock(0, Door_handles[0]); } aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); @@ -2318,7 +2135,7 @@ int16_t CustomObjectScript_110D::CallEvent(int event, tOSIRISEventInfo *data) { // Script 003: Unlock Magnet Control Door (1) if ((ScriptActionCtr_003 < 1) && (qObjIsPlayerWeapon(event_data->it_handle) == true)) { if ((ScriptActionCtr_004 > 0) == true) { - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("MagnetTubeDoorUnlock")); aDoorLockUnlock(0, Door_handles[0]); } aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); @@ -2340,7 +2157,7 @@ int16_t CustomObjectScript_090B::CallEvent(int event, tOSIRISEventInfo *data) { // Script 006: Manual Activation Message (Magnet) if ((qObjIsPlayerWeapon(event_data->it_handle) == true) && ((ScriptActionCtr_007 > 0) == false)) { - aShowHUDMessage(Message_strings[4]); + aShowHUDMessage(TXT("ManualActivation")); // Increment the script action counter if (ScriptActionCtr_006 < MAX_ACTION_CTR_VALUE) @@ -2352,7 +2169,7 @@ int16_t CustomObjectScript_090B::CallEvent(int event, tOSIRISEventInfo *data) { aSetLevelTimer(10.000000f, 3); aGoalCompleted(Goal_indexes[0], 1); aSetWaypoint(2); - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("MagnetActivated")); aObjPlayAnim(data->me_handle, 0, 36, 5.000000f, 0); aSoundPlayObject(Sound_indexes[2], data->me_handle, 1.000000f); aTurnOnSpew(Object_handles[26], 0, 7, 1.000000f, 0.100000f, 65664, 0, 1.500000f, 0.150000f, -1.000000f, 4.000000f, @@ -2380,7 +2197,7 @@ int16_t CustomObjectScript_30A8::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_009 < 1) && (qObjIsPlayer(event_data->it_handle) == true)) { aSoundPlayObject(Sound_indexes[3], data->me_handle, 1.000000f); aObjDelete(data->me_handle); - aShowHUDMessage(Message_strings[6]); + aShowHUDMessage(TXT("FFKeyPickup")); // Increment the script action counter if (ScriptActionCtr_009 < MAX_ACTION_CTR_VALUE) @@ -2403,11 +2220,11 @@ int16_t CustomObjectScript_0940::CallEvent(int event, tOSIRISEventInfo *data) { aObjPlayAnim(data->me_handle, 0, 2, 2.000000f, 0); if ((ScriptActionCtr_011 > 0) == true) { aGoalCompleted(Goal_indexes[1], 1); - aShowHUDMessage(Message_strings[7]); + aShowHUDMessage(TXT("FFDisabled")); aPortalRenderSet(0, 2, Room_indexes[6], 1); aPortalRenderSet(0, 1, Room_indexes[6], 1); } else { - aShowHUDMessage(Message_strings[8]); + aShowHUDMessage(TXT("FFDisable1")); } // Increment the script action counter @@ -2417,7 +2234,7 @@ int16_t CustomObjectScript_0940::CallEvent(int event, tOSIRISEventInfo *data) { // Script 012: Need Key FF Switch (1) if (((ScriptActionCtr_009 > 0) == false) && (qObjIsPlayerWeapon(event_data->it_handle) == true)) { - aShowHUDMessage(Message_strings[9]); + aShowHUDMessage(TXT("NeedFFKey")); // Increment the script action counter if (ScriptActionCtr_012 < MAX_ACTION_CTR_VALUE) @@ -2440,11 +2257,11 @@ int16_t CustomObjectScript_0941::CallEvent(int event, tOSIRISEventInfo *data) { aObjPlayAnim(data->me_handle, 0, 2, 2.000000f, 0); if ((ScriptActionCtr_010 > 0) == true) { aGoalCompleted(Goal_indexes[1], 1); - aShowHUDMessage(Message_strings[7]); + aShowHUDMessage(TXT("FFDisabled")); aPortalRenderSet(0, 1, Room_indexes[6], 1); aPortalRenderSet(0, 2, Room_indexes[6], 1); } else { - aShowHUDMessage(Message_strings[8]); + aShowHUDMessage(TXT("FFDisable1")); } // Increment the script action counter @@ -2454,7 +2271,7 @@ int16_t CustomObjectScript_0941::CallEvent(int event, tOSIRISEventInfo *data) { // Script 013: Need Key FF Switch (2) if (((ScriptActionCtr_009 > 0) == false) && (qObjIsPlayerWeapon(event_data->it_handle) == true)) { - aShowHUDMessage(Message_strings[9]); + aShowHUDMessage(TXT("NeedFFKey")); // Increment the script action counter if (ScriptActionCtr_013 < MAX_ACTION_CTR_VALUE) @@ -2473,12 +2290,12 @@ int16_t CustomObjectScript_0944::CallEvent(int event, tOSIRISEventInfo *data) { // Script 014: Upper Magnet Tube Activation if ((ScriptActionCtr_014 < 1) && (qObjIsPlayerWeapon(event_data->it_handle) == true)) { aGoalCompleted(Goal_indexes[2], 1); - aShowHUDMessage(Message_strings[10]); + aShowHUDMessage(TXT("UpperTubeActivate")); aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); aObjPlayAnim(data->me_handle, 0, 4, 2.000000f, 0); if (((ScriptActionCtr_034 > 0) == true) && ((ScriptActionCtr_016 > 0) == true)) { aDoorLockUnlock(0, Door_handles[2]); - aShowHUDMessage(Message_strings[11]); + aShowHUDMessage(TXT("ContainmentDoorUnlocked")); } // Increment the script action counter @@ -2544,7 +2361,7 @@ int16_t CustomObjectScript_0943::CallEvent(int event, tOSIRISEventInfo *data) { aAISetState(0, Object_handles[33]); aTurnOnSpew(Object_handles[33], 0, 8, 0.000000f, 0.000000f, 65536, 0, 2.000000f, 0.100000f, 8.000000f, 5.000000f, 40.000000f, 0, -1); - aShowHUDMessage(Message_strings[12]); + aShowHUDMessage(TXT("SuperHeaterShutdown")); // Increment the script action counter if (ScriptActionCtr_032 < MAX_ACTION_CTR_VALUE) @@ -2569,7 +2386,7 @@ int16_t CustomObjectScript_0942::CallEvent(int event, tOSIRISEventInfo *data) { aAISetState(0, Object_handles[34]); aTurnOnSpew(Object_handles[34], 0, 8, 0.000000f, 0.000000f, 65536, 0, 2.000000f, 0.100000f, 8.000000f, 5.000000f, 40.000000f, 0, -1); - aShowHUDMessage(Message_strings[12]); + aShowHUDMessage(TXT("SuperHeaterShutdown")); // Increment the script action counter if (ScriptActionCtr_015 < MAX_ACTION_CTR_VALUE) @@ -2591,13 +2408,13 @@ int16_t CustomObjectScript_18B8::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlaySteaming("VoxL07EndLevel.osf", 1.000000f); aGoalCompleted(Goal_indexes[3], 1); aGoalCompleted(Goal_indexes[4], 1); - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("Virus2Collected")); if ((ScriptActionCtr_014 > 0) == true) { aDoorLockUnlock(0, Door_handles[2]); - aShowHUDMessage(Message_strings[11]); + aShowHUDMessage(TXT("ContainmentDoorUnlocked")); } } else { - aShowHUDMessage(Message_strings[14]); + aShowHUDMessage(TXT("Virus1Collected")); } aSoundPlayObject(Sound_indexes[5], data->me_handle, 1.000000f); aObjDelete(data->me_handle); @@ -2622,13 +2439,13 @@ int16_t CustomObjectScript_20B1::CallEvent(int event, tOSIRISEventInfo *data) { aSoundPlaySteaming("VoxL07EndLevel.osf", 1.000000f); aGoalCompleted(Goal_indexes[3], 1); aGoalCompleted(Goal_indexes[4], 1); - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("Virus2Collected")); if ((ScriptActionCtr_014 > 0) == true) { aDoorLockUnlock(0, Door_handles[2]); - aShowHUDMessage(Message_strings[11]); + aShowHUDMessage(TXT("ContainmentDoorUnlocked")); } } else { - aShowHUDMessage(Message_strings[14]); + aShowHUDMessage(TXT("Virus1Collected")); } aSoundPlayObject(Sound_indexes[5], data->me_handle, 1.000000f); aObjDelete(data->me_handle); @@ -2679,7 +2496,7 @@ int16_t CustomObjectScript_0945::CallEvent(int event, tOSIRISEventInfo *data) { 20.000000f, 0, -1); aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); aObjPlayAnim(data->me_handle, 0, 4, 2.000000f, 0); - aShowHUDMessage(Message_strings[15]); + aShowHUDMessage(TXT("SteamRelease")); aRoomSetFog(Room_indexes[8], 0.600000f, 0.600000f, 0.600000f, 3000.000000f); aRoomFogSetState(1, Room_indexes[8]); aRoomChangeFog(Room_indexes[8], 0.600000f, 0.600000f, 0.600000f, 400.000000f, 30.000000f); @@ -2803,7 +2620,7 @@ int16_t CustomObjectScript_1021::CallEvent(int event, tOSIRISEventInfo *data) { // Script 022: Camera Switch (1) if ((ScriptActionCtr_022 < 1) && ((qObjIsPlayer(event_data->it_handle) == true) && (qObjExists(Object_handles[48]) == true))) { - aShowHUDMessage(Message_strings[16]); + aShowHUDMessage(TXT("CameraActivation")); aCreatePopupView(0, Object_handles[48], 10.000000f, 1.800000f); // Increment the script action counter @@ -2823,7 +2640,7 @@ int16_t CustomObjectScript_092C::CallEvent(int event, tOSIRISEventInfo *data) { // Script 042: Camera Switch (3) if ((ScriptActionCtr_042 < 1) && ((qObjIsPlayer(event_data->it_handle) == true) && (qObjExists(Object_handles[50]) == true))) { - aShowHUDMessage(Message_strings[16]); + aShowHUDMessage(TXT("CameraActivation")); aCreatePopupView(0, Object_handles[50], 10.000000f, 1.800000f); // Increment the script action counter @@ -2843,7 +2660,7 @@ int16_t CustomObjectScript_112D::CallEvent(int event, tOSIRISEventInfo *data) { // Script 041: Camera Switch (2) if ((ScriptActionCtr_041 < 1) && ((qObjIsPlayer(event_data->it_handle) == true) && (qObjExists(Object_handles[52]) == true))) { - aShowHUDMessage(Message_strings[16]); + aShowHUDMessage(TXT("CameraActivation")); aCreatePopupView(0, Object_handles[52], 10.000000f, 1.800000f); // Increment the script action counter @@ -2864,7 +2681,7 @@ int16_t CustomObjectScript_0861::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_053 < 1) && (qObjIsPlayerWeapon(event_data->it_handle) == true)) { aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); aObjPlayAnim(data->me_handle, 0, 4, 2.000000f, 0); - aShowHUDMessage(Message_strings[20]); + aShowHUDMessage(TXT("Controller")); aUserVarInc(2); if (qUserVarValue(2) == 4.000000f) { aSetObjectTimer(Object_handles[0], 0.000000f, 1); @@ -2888,7 +2705,7 @@ int16_t CustomObjectScript_0862::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_052 < 1) && (qObjIsPlayerWeapon(event_data->it_handle) == true)) { aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); aObjPlayAnim(data->me_handle, 0, 4, 2.000000f, 0); - aShowHUDMessage(Message_strings[20]); + aShowHUDMessage(TXT("Controller")); aUserVarInc(2); if (qUserVarValue(2) == 4.000000f) { aSetObjectTimer(Object_handles[0], 0.000000f, 1); @@ -2912,7 +2729,7 @@ int16_t CustomObjectScript_186B::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_051 < 1) && (qObjIsPlayerWeapon(event_data->it_handle) == true)) { aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); aObjPlayAnim(data->me_handle, 0, 4, 2.000000f, 0); - aShowHUDMessage(Message_strings[20]); + aShowHUDMessage(TXT("Controller")); aUserVarInc(2); if (qUserVarValue(2) == 4.000000f) { aSetObjectTimer(Object_handles[0], 0.000000f, 1); @@ -2936,7 +2753,7 @@ int16_t CustomObjectScript_2071::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_001 < 1) && (qObjIsPlayerWeapon(event_data->it_handle) == true)) { aSoundPlayObject(Sound_indexes[1], data->me_handle, 1.000000f); aObjPlayAnim(data->me_handle, 0, 4, 2.000000f, 0); - aShowHUDMessage(Message_strings[20]); + aShowHUDMessage(TXT("Controller")); aUserVarInc(2); if (qUserVarValue(2) == 4.000000f) { aSetObjectTimer(Object_handles[0], 0.000000f, 1); @@ -2971,7 +2788,7 @@ int16_t CustomObjectScript_2148::CallEvent(int event, tOSIRISEventInfo *data) { // Script 081: TurretMessage if ((ScriptActionCtr_081 < 3) && (1)) { - aShowHUDMessage(Message_strings[21]); + aShowHUDMessage(TXT("TurretsInvuln")); // Increment the script action counter if (ScriptActionCtr_081 < MAX_ACTION_CTR_VALUE) @@ -3107,7 +2924,7 @@ int16_t TriggerScript_0003::CallEvent(int event, tOSIRISEventInfo *data) { // Script 043: EndLevel!!! if ((ScriptActionCtr_043 < 1) && (1)) { aSoundPlayObject(Sound_indexes[6], event_data->it_handle, 1.000000f); - aStartEndlevelSequence(Object_handles[53], Path_indexes[0], 5.000000f, Message_strings[17]); + aStartEndlevelSequence(Object_handles[53], Path_indexes[0], 5.000000f, TXT("Finished")); // Increment the script action counter if (ScriptActionCtr_043 < MAX_ACTION_CTR_VALUE) @@ -3144,7 +2961,7 @@ int16_t TriggerScript_0007::CallEvent(int event, tOSIRISEventInfo *data) { // Script 049: VirusCam(2) if ((ScriptActionCtr_049 < 1) && (((ScriptActionCtr_048 > 0) == false) && ((ScriptActionCtr_011 > 0) == true) && ((ScriptActionCtr_010 > 0) == true))) { - aShowHUDMessage(Message_strings[19]); + aShowHUDMessage(TXT("VirusDescription")); // Increment the script action counter if (ScriptActionCtr_049 < MAX_ACTION_CTR_VALUE) @@ -3172,7 +2989,7 @@ int16_t TriggerScript_0006::CallEvent(int event, tOSIRISEventInfo *data) { // Script 048: VirusCam(1) if ((ScriptActionCtr_048 < 1) && (((ScriptActionCtr_010 > 0) == true) && ((ScriptActionCtr_011 > 0) == true) && ((ScriptActionCtr_049 > 0) == false))) { - aShowHUDMessage(Message_strings[19]); + aShowHUDMessage(TXT("VirusDescription")); // Increment the script action counter if (ScriptActionCtr_048 < MAX_ACTION_CTR_VALUE) diff --git a/scripts/Level7_FRN.msg b/scripts/level7_FRN.msg similarity index 100% rename from scripts/Level7_FRN.msg rename to scripts/level7_FRN.msg diff --git a/scripts/level7_Ger.msg b/scripts/level7_GER.msg similarity index 100% rename from scripts/level7_Ger.msg rename to scripts/level7_GER.msg diff --git a/scripts/Level7_ITN.msg b/scripts/level7_ITN.msg similarity index 100% rename from scripts/Level7_ITN.msg rename to scripts/level7_ITN.msg diff --git a/scripts/level8.cpp b/scripts/level8.cpp index 52fbaf66c..3cf18cc6b 100644 --- a/scripts/level8.cpp +++ b/scripts/level8.cpp @@ -22,10 +22,10 @@ // Filename: level8.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -857,180 +857,12 @@ void RestoreGlobalActionCtrs(void *file_ptr) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} +std::map Messages; -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -1207,7 +1039,6 @@ const char *Message_names[NUM_MESSAGE_NAMES] = {"IntroCamera", "WeaponsPlantData", "FoundSecretData", "FrigateSaved"}; -const char *Message_strings[NUM_MESSAGE_NAMES]; // =============== // InitializeDLL() @@ -1222,26 +1053,16 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "level8.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { mprintf(0, "ERROR: Could not load message file - %s\n", filename); @@ -1288,10 +1109,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } @@ -1954,7 +1771,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 029: Medical Frigate Mayday! if ((qRoomHasPlayer(Room_indexes[21]) == true) && (qUserFlag(10) == false)) { - aAddGameMessage(Message_strings[10], Message_strings[11]); + aAddGameMessage(TXT("Mayday"), TXT("MessageFromFrigate")); aUserFlagSet(10, 1); aGoalEnableDisable(1, Goal_indexes[6]); aSoundPlaySteaming("VoxL08SpecificA.osf", 1.000000f); @@ -1990,7 +1807,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 001: Intro Camera Sequence if (1) { - aCinematicIntro(Path_indexes[0], Message_strings[0], Object_handles[0], Path_indexes[1], 10.000000f); + aCinematicIntro(Path_indexes[0], TXT("IntroCamera"), Object_handles[0], Path_indexes[1], 10.000000f); aSoundPlaySteaming("VoxL08StartLevel.osf", 1.000000f); // Increment the script action counter @@ -2304,7 +2121,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 020: Core Temperature Above Normal! if (3 == event_data->id) { aMiscViewerShake(75.000000f); - aShowHUDMessage(Message_strings[6]); + aShowHUDMessage(TXT("CoreTempAboveNormal")); aSetLevelTimer(60.000000f, 4); aSoundPlay2D(Sound_indexes[0], 1.000000f); @@ -2338,7 +2155,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 077: Frigate Waits For Elevator Timer if (6 == event_data->id) { - aAddGameMessage(Message_strings[20], Message_strings[11]); + aAddGameMessage(TXT("FrigateSaved"), TXT("MessageFromFrigate")); aPortalRenderSet(0, 0, Room_indexes[22], 1); aAIGoalFollowPathSimple(Object_handles[23], Path_indexes[6], 131328, 0, 3); aGoalCompleted(Goal_indexes[6], 1); @@ -2545,7 +2362,7 @@ int16_t CustomObjectScript_10FD::CallEvent(int event, tOSIRISEventInfo *data) { if (qUserFlag(4) == false) { aObjPlayAnim(Object_handles[4], 0, 2, 2.000000f, 0); aUserFlagSet(4, 1); - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("CoolingSystemEngaged")); aRoomSetFaceTexture(Room_indexes[13], 78, Texture_indexes[0]); aRoomSetFaceTexture(Room_indexes[13], 101, Texture_indexes[0]); aRoomSetFaceTexture(Room_indexes[14], 148, Texture_indexes[0]); @@ -2578,7 +2395,7 @@ int16_t CustomObjectScript_10FD::CallEvent(int event, tOSIRISEventInfo *data) { aGoalCompleted(Goal_indexes[0], 1); aGoalEnableDisable(1, Goal_indexes[1]); } else { - aShowHUDMessage(Message_strings[3]); + aShowHUDMessage(TXT("CoolingSystemClock")); } // Increment the script action counter @@ -2607,7 +2424,7 @@ int16_t CustomObjectScript_0839::CallEvent(int event, tOSIRISEventInfo *data) { aRoomSetFaceTexture(Room_indexes[14], 148, Texture_indexes[3]); aSetLevelTimer(20.000000f, 3); aRoomChangeFog(Room_indexes[13], 0.250000f, 0.500000f, 1.000000f, 2000.000000f, 120.000000f); - aShowHUDMessage(Message_strings[4]); + aShowHUDMessage(TXT("ALLHeatSinksDestroyed")); aGoalEnableDisable(1, Goal_indexes[2]); aGoalCompleted(Goal_indexes[3], 1); @@ -2673,7 +2490,7 @@ int16_t CustomObjectScript_0901::CallEvent(int event, tOSIRISEventInfo *data) { // Script 022: Cooling Duct Forcefield Disabled if ((qObjIsPlayerWeapon(event_data->it_handle) == true) && (qUserFlag(8) == false)) { - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ForcefieldDisabled")); aPortalRenderSet(0, 3, Room_indexes[15], 1); aUserFlagSet(8, 1); aObjPlayAnim(Object_handles[8], 0, 2, 2.000000f, 0); @@ -2694,7 +2511,7 @@ int16_t CustomObjectScript_0900::CallEvent(int event, tOSIRISEventInfo *data) { // Script 019: Inner Heat Sink Forcefield Disabled if ((qObjIsPlayerWeapon(event_data->it_handle) == true) && (qUserFlag(7) == false)) { - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ForcefieldDisabled")); aPortalRenderSet(0, 1, Room_indexes[16], 1); aUserFlagSet(7, 1); aObjPlayAnim(Object_handles[9], 0, 2, 2.000000f, 0); @@ -2715,7 +2532,7 @@ int16_t CustomObjectScript_08FF::CallEvent(int event, tOSIRISEventInfo *data) { // Script 018: Middle Heat Sink Forcefield Disabled if ((qObjIsPlayerWeapon(event_data->it_handle) == true) && (qUserFlag(6) == false)) { - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ForcefieldDisabled")); aPortalRenderSet(0, 1, Room_indexes[17], 1); aUserFlagSet(6, 1); aObjPlayAnim(Object_handles[10], 0, 2, 2.000000f, 0); @@ -2738,7 +2555,7 @@ int16_t CustomObjectScript_20FE::CallEvent(int event, tOSIRISEventInfo *data) { // Script 017: Outer Heat Sink Forcefield Disabled if ((qObjIsPlayerWeapon(event_data->it_handle) == true) && (qUserFlag(5) == false)) { - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ForcefieldDisabled")); aPortalRenderSet(0, 1, Room_indexes[18], 1); aUserFlagSet(5, 1); aObjPlayAnim(Object_handles[11], 0, 2, 2.000000f, 0); @@ -2771,7 +2588,7 @@ int16_t CustomObjectScript_083D::CallEvent(int event, tOSIRISEventInfo *data) { // Script 076: Deadly Fan Gets Shot By Player if (qObjIsPlayerWeapon(event_data->it_handle) == true) { aObjSetShields(Object_handles[12], 1000000000.000000f); - aShowHUDMessage(Message_strings[8]); + aShowHUDMessage(TXT("CoolFanInvulnerable")); // Increment the script action counter if (ScriptActionCtr_076 < MAX_ACTION_CTR_VALUE) @@ -2791,7 +2608,7 @@ int16_t CustomObjectScript_083D::CallEvent(int event, tOSIRISEventInfo *data) { aDoorLockUnlock(1, Door_handles[7]); aDoorLockUnlock(0, Door_handles[10]); aUserFlagSet(17, 1); - aShowHUDMessage(Message_strings[9]); + aShowHUDMessage(TXT("CoolFanDestroyed")); // Increment the script action counter if (ScriptActionCtr_025 < MAX_ACTION_CTR_VALUE) @@ -2813,7 +2630,7 @@ int16_t CustomObjectScript_09E3::CallEvent(int event, tOSIRISEventInfo *data) { aRoomChangeWind(Room_indexes[19], 0.000000f, 1.000000f, 0.000000f, 15.000000f, 10.000000f); aUserFlagSet(14, 1); aObjPlayAnim(Object_handles[13], 0, 1, 2.000000f, 0); - aShowHUDMessage(Message_strings[7]); + aShowHUDMessage(TXT("FanReverseSwitch")); } else { aRoomChangeWind(Room_indexes[19], 0.000000f, -1.000000f, 0.000000f, 15.000000f, 10.000000f); aUserFlagSet(14, 0); @@ -2879,7 +2696,7 @@ int16_t CustomObjectScript_08C1::CallEvent(int event, tOSIRISEventInfo *data) { // Script 027: Security Tower Forcefield if (1) { - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ForcefieldDisabled")); aPortalRenderSet(0, 6, Room_indexes[20], 1); aMatcenSetState(1, Matcen_indexes[0]); @@ -2904,7 +2721,7 @@ int16_t CustomObjectScript_090F::CallEvent(int event, tOSIRISEventInfo *data) { aSetLevelTimer(10.000000f, 6); aSoundPlaySteaming("VoxL08SpecificC.osf", 1.000000f); } else { - aAddGameMessage(Message_strings[12], Message_strings[11]); + aAddGameMessage(TXT("ElevatorNeedsDown"), TXT("MessageFromFrigate")); aUserFlagSet(18, 1); } aUserFlagSet(19, 1); @@ -2925,7 +2742,7 @@ int16_t CustomObjectScript_090E::CallEvent(int event, tOSIRISEventInfo *data) { // Script 035: Left Clamp Release Switch if (qObjIsPlayerWeapon(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("ClampNotInUse")); // Increment the script action counter if (ScriptActionCtr_035 < MAX_ACTION_CTR_VALUE) @@ -2943,7 +2760,7 @@ int16_t CustomObjectScript_0910::CallEvent(int event, tOSIRISEventInfo *data) { // Script 034: Right Clamp Release Switch if (qObjIsPlayerWeapon(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("ClampNotInUse")); // Increment the script action counter if (ScriptActionCtr_034 < MAX_ACTION_CTR_VALUE) @@ -2961,7 +2778,7 @@ int16_t CustomObjectScript_090C::CallEvent(int event, tOSIRISEventInfo *data) { // Script 033: Right Docking Clamp Switch if (qObjIsPlayerWeapon(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("ClampNotInUse")); // Increment the script action counter if (ScriptActionCtr_033 < MAX_ACTION_CTR_VALUE) @@ -2981,13 +2798,13 @@ int16_t CustomObjectScript_090B::CallEvent(int event, tOSIRISEventInfo *data) { if (qObjIsPlayerWeapon(event_data->it_handle) == true) { if (qUserFlag(12) == true) { aObjPlayAnim(Object_handles[21], 10, 20, 1.000000f, 0); - aShowHUDMessage(Message_strings[14]); + aShowHUDMessage(TXT("CenterClampDisengaged")); aUserFlagSet(12, 0); aSoundPlaySteaming("VoxL08SpecificB.osf", 1.000000f); } else { aObjPlayAnim(Object_handles[21], 0, 10, 1.000000f, 0); aUserFlagSet(12, 1); - aShowHUDMessage(Message_strings[15]); + aShowHUDMessage(TXT("EngagingCenterClamp")); } // Increment the script action counter @@ -3006,7 +2823,7 @@ int16_t CustomObjectScript_090A::CallEvent(int event, tOSIRISEventInfo *data) { // Script 032: Left Docking Clamp Switch if (qObjIsPlayerWeapon(event_data->it_handle) == true) { - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("ClampNotInUse")); // Increment the script action counter if (ScriptActionCtr_032 < MAX_ACTION_CTR_VALUE) @@ -3046,14 +2863,14 @@ int16_t CustomObjectScript_090D::CallEvent(int event, tOSIRISEventInfo *data) { aObjPlayAnim(Object_handles[24], 0, 1, 2.000000f, 0); aUserFlagSet(11, 1); aAIGoalFollowPathSimple(Object_handles[25], Path_indexes[5], 131328, -1, 3); - aShowHUDMessage(Message_strings[16]); + aShowHUDMessage(TXT("ElevatorDOWN")); if (qUserFlag(18) == true) { aSetLevelTimer(10.000000f, 6); aSoundPlaySteaming("VoxL08SpecificC.osf", 1.000000f); } else { } } else { - aShowHUDMessage(Message_strings[17]); + aShowHUDMessage(TXT("ElevatorAlreadyDown")); } // Increment the script action counter @@ -3073,7 +2890,7 @@ int16_t CustomObjectScript_19E2::CallEvent(int event, tOSIRISEventInfo *data) { // Script 043: Weapons Plant Secret Level Data if (qObjIsPlayer(event_data->it_handle) == true) { aAddObjectToInventory(Object_handles[0], event_data->it_handle, 0); - aAddGameMessage(Message_strings[18], Message_strings[19]); + aAddGameMessage(TXT("WeaponsPlantData"), TXT("FoundSecretData")); aSoundPlay2DObj(Sound_indexes[3], event_data->it_handle, 1.000000f); aMissionSetSecretFlag(1); aUserFlagSet(20, 1); @@ -3382,7 +3199,7 @@ int16_t TriggerScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 002: End Level Camera Sequence if (qObjIsPlayer(event_data->it_handle) == true) { - aStartEndlevelSequencePath(Path_indexes[2], Path_indexes[3], 13.000000f, Message_strings[1]); + aStartEndlevelSequencePath(Path_indexes[2], Path_indexes[3], 13.000000f, TXT("EndLevel")); if ((qUserFlag(11) == true) && (qUserFlag(19) == true)) { aSoundPlaySteaming("VoxL08EndAll.osf", 1.000000f); if (qUserFlag(20) == true) { diff --git a/scripts/Level8_FRN.msg b/scripts/level8_FRN.msg similarity index 100% rename from scripts/Level8_FRN.msg rename to scripts/level8_FRN.msg diff --git a/scripts/level8_Ger.msg b/scripts/level8_GER.msg similarity index 100% rename from scripts/level8_Ger.msg rename to scripts/level8_GER.msg diff --git a/scripts/Level8_ITN.msg b/scripts/level8_ITN.msg similarity index 100% rename from scripts/Level8_ITN.msg rename to scripts/level8_ITN.msg diff --git a/scripts/levelS2.cpp b/scripts/levelS2.cpp index b6e567dcd..3008f1f00 100644 --- a/scripts/levelS2.cpp +++ b/scripts/levelS2.cpp @@ -22,10 +22,10 @@ // Filename: levels2.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -1504,180 +1504,12 @@ void RestoreGlobalActionCtrs(void *file_ptr) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; +std::map Messages; - return (s); -} - -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -1855,12 +1687,6 @@ const char *Goal_names[NUM_GOAL_NAMES] = {"Destroy Red Key Forcefield Generators "Destroy the Research Center"}; int Goal_indexes[NUM_GOAL_NAMES]; -#define NUM_MESSAGE_NAMES 11 -const char *Message_names[NUM_MESSAGE_NAMES] = {"FlameDeactivated", "RedKeyFF", "BlueKeyFF", "NameRedKey", - "NameBlueKey", "ReactorFF", "ReactorDestroyed", "RedDoor", - "BlueDoor", "IntroCam", "ReactorPrimed"}; -const char *Message_strings[NUM_MESSAGE_NAMES]; - // =============== // InitializeDLL() // =============== @@ -1874,26 +1700,16 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "levels2.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { mprintf(0, "ERROR: Could not load message file - %s\n", filename); @@ -1940,10 +1756,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } @@ -3372,7 +3184,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 140: IntroCam if (1 == true) { - aCinematicIntro(Path_indexes[0], Message_strings[9], Object_handles[38], Path_indexes[1], 10.000000f); + aCinematicIntro(Path_indexes[0], TXT("IntroCam"), Object_handles[38], Path_indexes[1], 10.000000f); // Increment the script action counter if (ScriptActionCtr_140 < MAX_ACTION_CTR_VALUE) @@ -3426,7 +3238,7 @@ int16_t CustomObjectScript_0821::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_062 < 1) && (qObjIsPlayerWeapon(event_data->it_handle) == true)) { aObjPlayAnim(data->me_handle, 0, 3, 3.000000f, 0); aSoundPlayObject(Sound_indexes[2], data->me_handle, 1.000000f); - aShowHUDMessage(Message_strings[0]); + aShowHUDMessage(TXT("FlameDeactivated")); aTurnOffSpew(3); aRoomSetDamage(Room_indexes[56], 0.000000f, 0); @@ -3448,7 +3260,7 @@ int16_t CustomObjectScript_0820::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_061 < 1) && (qObjIsPlayerWeapon(event_data->it_handle) == true)) { aObjPlayAnim(data->me_handle, 0, 3, 3.000000f, 0); aSoundPlayObject(Sound_indexes[2], data->me_handle, 1.000000f); - aShowHUDMessage(Message_strings[0]); + aShowHUDMessage(TXT("FlameDeactivated")); aTurnOffSpew(2); aRoomSetDamage(Room_indexes[55], 0.000000f, 0); @@ -3470,7 +3282,7 @@ int16_t CustomObjectScript_181E::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_060 < 1) && (qObjIsPlayerWeapon(event_data->it_handle) == true)) { aObjPlayAnim(data->me_handle, 0, 3, 3.000000f, 0); aSoundPlayObject(Sound_indexes[2], data->me_handle, 1.000000f); - aShowHUDMessage(Message_strings[0]); + aShowHUDMessage(TXT("FlameDeactivated")); aTurnOffSpew(1); aRoomSetDamage(Room_indexes[58], 0.000000f, 0); @@ -3492,7 +3304,7 @@ int16_t CustomObjectScript_081F::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_059 < 1) && (qObjIsPlayerWeapon(event_data->it_handle) == true)) { aObjPlayAnim(data->me_handle, 0, 3, 3.000000f, 0); aSoundPlayObject(Sound_indexes[2], data->me_handle, 1.000000f); - aShowHUDMessage(Message_strings[0]); + aShowHUDMessage(TXT("FlameDeactivated")); aTurnOffSpew(0); aRoomSetDamage(Room_indexes[57], 0.000000f, 0); @@ -3578,7 +3390,7 @@ int16_t CustomObjectScript_0816::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_065 < 1) && (1)) { aGoalCompleted(Goal_indexes[0], 1); aPortalRenderSet(0, 0, Room_indexes[59], 1); - aShowHUDMessage(Message_strings[1]); + aShowHUDMessage(TXT("RedKeyFF")); // Increment the script action counter if (ScriptActionCtr_065 < MAX_ACTION_CTR_VALUE) @@ -3662,7 +3474,7 @@ int16_t CustomObjectScript_0817::CallEvent(int event, tOSIRISEventInfo *data) { if ((ScriptActionCtr_068 < 1) && (1)) { aGoalCompleted(Goal_indexes[1], 1); aPortalRenderSet(0, 0, Room_indexes[60], 1); - aShowHUDMessage(Message_strings[2]); + aShowHUDMessage(TXT("BlueKeyFF")); // Increment the script action counter if (ScriptActionCtr_068 < MAX_ACTION_CTR_VALUE) @@ -3683,7 +3495,7 @@ int16_t CustomObjectScript_1024::CallEvent(int event, tOSIRISEventInfo *data) { aMusicSetRegion(2, event_data->it_handle); aGoalCompleted(Goal_indexes[2], 1); aSoundPlayObject(Sound_indexes[3], data->me_handle, 1.000000f); - aObjectPlayerGiveKey(event_data->it_handle, data->me_handle, 2, Message_strings[3], 1); + aObjectPlayerGiveKey(event_data->it_handle, data->me_handle, 2, TXT("NameRedKey"), 1); // Increment the script action counter if (ScriptActionCtr_070 < MAX_ACTION_CTR_VALUE) @@ -3704,7 +3516,7 @@ int16_t CustomObjectScript_0826::CallEvent(int event, tOSIRISEventInfo *data) { aMusicSetRegion(1, event_data->it_handle); aGoalCompleted(Goal_indexes[3], 1); aSoundPlayObject(Sound_indexes[3], data->me_handle, 1.000000f); - aObjectPlayerGiveKey(event_data->it_handle, data->me_handle, 1, Message_strings[4], 1); + aObjectPlayerGiveKey(event_data->it_handle, data->me_handle, 1, TXT("NameBlueKey"), 1); // Increment the script action counter if (ScriptActionCtr_069 < MAX_ACTION_CTR_VALUE) @@ -3840,7 +3652,7 @@ int16_t CustomObjectScript_0829::CallEvent(int event, tOSIRISEventInfo *data) { 0.300000f, 5, 255, 30, 20, 0); aGoalCompleted(Goal_indexes[4], 1); aPortalRenderSet(0, 0, Room_indexes[61], 1); - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("ReactorFF")); // Increment the script action counter if (ScriptActionCtr_073 < MAX_ACTION_CTR_VALUE) @@ -3925,7 +3737,7 @@ int16_t CustomObjectScript_08C4::CallEvent(int event, tOSIRISEventInfo *data) { aMusicSetRegionAll(4); aGoalCompleted(Goal_indexes[5], 1); aSoundPlay2D(Sound_indexes[4], 1.000000f); - aShowHUDMessage(Message_strings[6]); + aShowHUDMessage(TXT("ReactorDestroyed")); aPortalRenderSet(0, 0, Room_indexes[30], 1); aSetObjectTimer(Object_handles[74], 0.500000f, -1); aTurnOnSpew(Object_handles[74], -1, 8, 0.000000f, 0.000000f, 65536, 0, 1.000000f, 0.120000f, 25.000000f, @@ -3943,7 +3755,7 @@ int16_t CustomObjectScript_08C4::CallEvent(int event, tOSIRISEventInfo *data) { // Script 143: ReactorStartCharge if (1) { if (qUserVarValue(4) > 6.000000f) { - aShowHUDMessage(Message_strings[10]); + aShowHUDMessage(TXT("ReactorPrimed")); aObjMakeVulnerable(data->me_handle); aObjDelete(Object_handles[73]); aObjDelete(Object_handles[72]); @@ -4179,10 +3991,10 @@ int16_t CustomObjectScript_1004::CallEvent(int event, tOSIRISEventInfo *data) { // Script 087: RedDoor-2 Lock Message if ((ScriptActionCtr_070 > 0) == false) { if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[7], event_data->it_handle); + aShowHUDMessageObj(TXT("RedDoor"), event_data->it_handle); } else { if (qObjIsPlayerWeapon(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[7], qObjParent(event_data->it_handle)); + aShowHUDMessageObj(TXT("RedDoor"), qObjParent(event_data->it_handle)); } } @@ -4203,10 +4015,10 @@ int16_t CustomObjectScript_1003::CallEvent(int event, tOSIRISEventInfo *data) { // Script 086: RedDoor-1 Lock Message if ((ScriptActionCtr_070 > 0) == false) { if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[7], event_data->it_handle); + aShowHUDMessageObj(TXT("RedDoor"), event_data->it_handle); } else { if (qObjIsPlayerWeapon(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[7], qObjParent(event_data->it_handle)); + aShowHUDMessageObj(TXT("RedDoor"), qObjParent(event_data->it_handle)); } } @@ -4227,10 +4039,10 @@ int16_t CustomObjectScript_100E::CallEvent(int event, tOSIRISEventInfo *data) { // Script 085: BlueDoor Lock Message if ((ScriptActionCtr_069 > 0) == false) { if (qObjIsPlayer(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[8], event_data->it_handle); + aShowHUDMessageObj(TXT("BlueDoor"), event_data->it_handle); } else { if (qObjIsPlayerWeapon(event_data->it_handle) == true) { - aShowHUDMessageObj(Message_strings[8], qObjParent(event_data->it_handle)); + aShowHUDMessageObj(TXT("BlueDoor"), qObjParent(event_data->it_handle)); } } diff --git a/scripts/LEVELS2_FRN.msg b/scripts/levelS2_FRN.msg similarity index 100% rename from scripts/LEVELS2_FRN.msg rename to scripts/levelS2_FRN.msg diff --git a/scripts/levelS2_Ger.msg b/scripts/levelS2_GER.msg similarity index 100% rename from scripts/levelS2_Ger.msg rename to scripts/levelS2_GER.msg diff --git a/scripts/LevelS2_ITN.msg b/scripts/levelS2_ITN.msg similarity index 100% rename from scripts/LevelS2_ITN.msg rename to scripts/levelS2_ITN.msg diff --git a/scripts/merc5.cpp b/scripts/merc5.cpp index 329fafdf6..74d71fd0a 100644 --- a/scripts/merc5.cpp +++ b/scripts/merc5.cpp @@ -22,10 +22,10 @@ // Filename: Merc5.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -993,180 +993,12 @@ void dsCustomRestore(void *fileptr) {} // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} - -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; +std::map Messages; - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -1403,14 +1235,6 @@ const char *Goal_names[NUM_GOAL_NAMES] = {"Blast Into the Laboratory", "In "Escape Before the System Reboots"}; int Goal_indexes[NUM_GOAL_NAMES]; -#define NUM_MESSAGE_NAMES 16 -const char *Message_names[NUM_MESSAGE_NAMES] = { - "VirusDeviceName", "IntroMessage", "EmptyMessage", "Watchout", - "LeftLabInitData", "LeftLabInfected", "LeftLabNotReady", "RightLabInfected", - "LeftLabVirusPlaced", "VirusInfectFail", "GetToPower", "RechargeSucceed", - "RechargeFail", "DeactivateSucceed", "DeactivateFail", "10Seconds"}; -const char *Message_strings[NUM_MESSAGE_NAMES]; - // =============== // InitializeDLL() // =============== @@ -1424,37 +1248,19 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - char english_filename[(_MAX_PATH + 32) * 2]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - snprintf(english_filename, sizeof(english_filename), "%s.msg", filename); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); - else if (lang_type == LANGUAGE_POLISH) - strcat(filename, "_POL"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "Merc5.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { - if (lang_type == LANGUAGE_ENGLISH) { - mprintf(0, "ERROR: Could not load message file - %s\n", filename); - } else if (!ReadMessageFile(english_filename)) { - mprintf(0, "ERROR: Could not load message file - %s\n", english_filename); - } + mprintf(0, "ERROR: Could not load message file - %s\n", filename); } int j; @@ -1498,10 +1304,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } @@ -2126,8 +1928,8 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 010: Level INIT (Player Inventory) if ((ScriptActionCtr_010 < 1) && (1)) { - aAddObjectToInventoryNamed(Object_handles[10], qPlayerClosest(Object_handles[11], 0), Message_strings[0], 0); - aAddObjectToInventoryNamed(Object_handles[12], qPlayerClosest(Object_handles[11], 0), Message_strings[0], 0); + aAddObjectToInventoryNamed(Object_handles[10], qPlayerClosest(Object_handles[11], 0), TXT("VirusDeviceName"), 0); + aAddObjectToInventoryNamed(Object_handles[12], qPlayerClosest(Object_handles[11], 0), TXT("VirusDeviceName"), 0); // Increment the script action counter if (ScriptActionCtr_010 < MAX_ACTION_CTR_VALUE) @@ -2165,7 +1967,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { if (1 == true) { aObjGhostSet(1, Object_handles[15]); aLightningTurnOn(0.100000f, 0.080000f); - aCinematicSimple(Path_indexes[2], Message_strings[1], Object_handles[16], 8.000000f, 1); + aCinematicSimple(Path_indexes[2], TXT("IntroMessage"), Object_handles[16], 8.000000f, 1); // Increment the script action counter if (ScriptActionCtr_072 < MAX_ACTION_CTR_VALUE) @@ -2382,7 +2184,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 034: End Level in 10 seconds! if (event_data->id == 14) { - aShowColoredHUDMessage(255, 0, 0, Message_strings[15]); + aShowColoredHUDMessage(255, 0, 0, TXT("10Seconds")); // Increment the script action counter if (ScriptActionCtr_034 < MAX_ACTION_CTR_VALUE) @@ -2402,7 +2204,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 039: End Level Failure if ((ScriptActionCtr_039 < 1) && (event_data->id == 16)) { aSetLevelTimer(3.800000f, 23); - aFadeWhiteAndEndlevel(4.000000f, Message_strings[2]); + aFadeWhiteAndEndlevel(4.000000f, TXT("EmptyMessage")); // Increment the script action counter if (ScriptActionCtr_039 < MAX_ACTION_CTR_VALUE) @@ -2424,7 +2226,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { // Script 041: Both Hubs Infected if ((ScriptActionCtr_041 < 1) && ((qUserFlag(1) == 1) && (qUserFlag(0) == 1))) { - aShowHUDMessage(Message_strings[10]); + aShowHUDMessage(TXT("GetToPower")); aDoorSetPos(Door_handles[0], 0.800000f); // Increment the script action counter @@ -2446,7 +2248,7 @@ int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { aObjSpark(Object_handles[171], 30.000000f, 10.000000f); aObjSpark(Object_handles[172], 30.000000f, 10.000000f); aObjSpark(Object_handles[173], 30.000000f, 10.000000f); - aStartEndlevelSequencePath(Path_indexes[12], Path_indexes[13], 8.000000f, Message_strings[2]); + aStartEndlevelSequencePath(Path_indexes[12], Path_indexes[13], 8.000000f, TXT("EmptyMessage")); // Increment the script action counter if (ScriptActionCtr_026 < MAX_ACTION_CTR_VALUE) @@ -2472,7 +2274,7 @@ int16_t CustomObjectScript_11C4::CallEvent(int event, tOSIRISEventInfo *data) { 5.000000f, 30.000000f, 0, -1); aTurnOnSpew(Object_handles[20], -1, 7, 0.000000f, 0.000000f, 65536, 0, 1.500000f, 0.100000f, 10.000000f, 5.000000f, 30.000000f, 0, -1); - aCinematicSimple(Path_indexes[4], Message_strings[2], Object_handles[21], 8.000000f, 1); + aCinematicSimple(Path_indexes[4], TXT("EmptyMessage"), Object_handles[21], 8.000000f, 1); // Increment the script action counter if (ScriptActionCtr_073 < MAX_ACTION_CTR_VALUE) @@ -2512,7 +2314,7 @@ int16_t CustomObjectScript_09C6::CallEvent(int event, tOSIRISEventInfo *data) { // Script 074: IntroCam-3 if (1) { - aCinematicSimple(Path_indexes[5], Message_strings[2], Object_handles[24], 9.000000f, 1); + aCinematicSimple(Path_indexes[5], TXT("EmptyMessage"), Object_handles[24], 9.000000f, 1); // Increment the script action counter if (ScriptActionCtr_074 < MAX_ACTION_CTR_VALUE) @@ -2534,7 +2336,7 @@ int16_t CustomObjectScript_11C5::CallEvent(int event, tOSIRISEventInfo *data) { aAISetState(0, Object_handles[25]); aObjSetVelocity(Object_handles[25], 0.000000f, 0.000000f, -1.000000f, 120.000000f); aPhysFlags(1, 58787840, Object_handles[25]); - aCinematicSimple(Path_indexes[6], Message_strings[2], Object_handles[26], 8.000000f, 1); + aCinematicSimple(Path_indexes[6], TXT("EmptyMessage"), Object_handles[26], 8.000000f, 1); // Increment the script action counter if (ScriptActionCtr_075 < MAX_ACTION_CTR_VALUE) @@ -2947,7 +2749,7 @@ int16_t CustomObjectScript_2885::CallEvent(int event, tOSIRISEventInfo *data) { aTurnOnSpew(Object_handles[78], 0, 7, 0.000000f, 0.000000f, 65536, 0, 1.200000f, 0.100000f, 3.000000f, 3.000000f, 15.000000f, 0, -1); aObjDelete(Object_handles[79]); - aShowHUDMessage(Message_strings[4]); + aShowHUDMessage(TXT("LeftLabInitData")); aSoundPlayObject(Sound_indexes[7], data->me_handle, 1.000000f); aObjPlayAnim(data->me_handle, 1, 5, 4.000000f, 0); @@ -3024,9 +2826,9 @@ int16_t CustomObjectScript_2885::CallEvent(int event, tOSIRISEventInfo *data) { 4.000000f, 20.000000f, 1, 9); aTurnOnSpew(Object_handles[110], -1, 7, 0.000000f, 0.000000f, 65536, 0, 1.500000f, 0.150000f, -1.000000f, 4.000000f, 20.000000f, 1, 10); - aShowHUDMessage(Message_strings[5]); + aShowHUDMessage(TXT("LeftLabInfected")); } else { - aShowHUDMessage(Message_strings[6]); + aShowHUDMessage(TXT("LeftLabNotReady")); } // Increment the script action counter @@ -3052,7 +2854,7 @@ int16_t CustomObjectScript_107E::CallEvent(int event, tOSIRISEventInfo *data) { aTurnOnSpew(Object_handles[112], 0, 7, 0.000000f, 0.000000f, 65536, 0, 1.200000f, 0.100000f, 3.000000f, 3.000000f, 15.000000f, 0, -1); aObjDelete(Object_handles[77]); - aShowHUDMessage(Message_strings[4]); + aShowHUDMessage(TXT("LeftLabInitData")); aSoundPlayObject(Sound_indexes[7], data->me_handle, 1.000000f); aObjPlayAnim(data->me_handle, 1, 5, 4.000000f, 0); @@ -3125,9 +2927,9 @@ int16_t CustomObjectScript_107E::CallEvent(int event, tOSIRISEventInfo *data) { 4.000000f, 20.000000f, 1, 22); aTurnOnSpew(Object_handles[138], -1, 7, 0.000000f, 0.000000f, 65536, 0, 1.500000f, 0.150000f, -1.000000f, 4.000000f, 20.000000f, 1, 23); - aShowHUDMessage(Message_strings[7]); + aShowHUDMessage(TXT("RightLabInfected")); } else { - aShowHUDMessage(Message_strings[6]); + aShowHUDMessage(TXT("LeftLabNotReady")); } // Increment the script action counter @@ -3146,7 +2948,7 @@ int16_t CustomObjectScript_1185::CallEvent(int event, tOSIRISEventInfo *data) { // Script 036: PICKUP Virus if (qObjIsPlayer(event_data->it_handle) == true) { - aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, Message_strings[0], 0); + aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, TXT("VirusDeviceName"), 0); // Increment the script action counter if (ScriptActionCtr_036 < MAX_ACTION_CTR_VALUE) @@ -3160,7 +2962,7 @@ int16_t CustomObjectScript_1185::CallEvent(int event, tOSIRISEventInfo *data) { if (1) { if ((qObjGetDistance(event_data->it_handle, Object_handles[80]) < 40.000000f) && (qUserFlag(14) == false) && ((ScriptActionCtr_078 > 0) == true)) { - aShowHUDMessage(Message_strings[8]); + aShowHUDMessage(TXT("LeftLabVirusPlaced")); aUserFlagSet(14, 1); aSoundPlayObject(Sound_indexes[8], Object_handles[80], 1.000000f); aObjGhostSet(0, Object_handles[80]); @@ -3168,15 +2970,15 @@ int16_t CustomObjectScript_1185::CallEvent(int event, tOSIRISEventInfo *data) { } else { if ((qObjGetDistance(event_data->it_handle, Object_handles[81]) < 40.000000f) && (qUserFlag(15) == false) && ((ScriptActionCtr_013 > 0) == true)) { - aShowHUDMessage(Message_strings[8]); + aShowHUDMessage(TXT("LeftLabVirusPlaced")); aUserFlagSet(15, 1); aSoundPlayObject(Sound_indexes[8], Object_handles[81], 1.000000f); aObjGhostSet(0, Object_handles[81]); aEmitSparks(80.000000f, Object_handles[81]); } else { aObjGhostSet(0, data->me_handle); - aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, Message_strings[0], 0); - aShowColoredHUDMessageObj(255, 0, 0, Message_strings[9], event_data->it_handle); + aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, TXT("VirusDeviceName"), 0); + aShowColoredHUDMessageObj(255, 0, 0, TXT("VirusInfectFail"), event_data->it_handle); } } @@ -3196,7 +2998,7 @@ int16_t CustomObjectScript_21B2::CallEvent(int event, tOSIRISEventInfo *data) { // Script 050: PICKUP Virus 2 if (qObjIsPlayer(event_data->it_handle) == true) { - aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, Message_strings[0], 0); + aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, TXT("VirusDeviceName"), 0); // Increment the script action counter if (ScriptActionCtr_050 < MAX_ACTION_CTR_VALUE) @@ -3210,7 +3012,7 @@ int16_t CustomObjectScript_21B2::CallEvent(int event, tOSIRISEventInfo *data) { if (1) { if ((qObjGetDistance(event_data->it_handle, Object_handles[80]) < 40.000000f) && (qUserFlag(14) == false) && ((ScriptActionCtr_078 > 0) == true)) { - aShowHUDMessage(Message_strings[8]); + aShowHUDMessage(TXT("LeftLabVirusPlaced")); aUserFlagSet(14, 1); aSoundPlayObject(Sound_indexes[8], Object_handles[80], 1.000000f); aObjGhostSet(0, Object_handles[80]); @@ -3218,15 +3020,15 @@ int16_t CustomObjectScript_21B2::CallEvent(int event, tOSIRISEventInfo *data) { } else { if ((qObjGetDistance(event_data->it_handle, Object_handles[81]) < 40.000000f) && (qUserFlag(15) == false) && ((ScriptActionCtr_013 > 0) == true)) { - aShowHUDMessage(Message_strings[8]); + aShowHUDMessage(TXT("LeftLabVirusPlaced")); aUserFlagSet(15, 1); aSoundPlayObject(Sound_indexes[8], Object_handles[81], 1.000000f); aObjGhostSet(0, Object_handles[81]); aEmitSparks(80.000000f, Object_handles[81]); } else { aObjGhostSet(0, data->me_handle); - aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, Message_strings[0], 0); - aShowColoredHUDMessageObj(255, 0, 0, Message_strings[9], event_data->it_handle); + aAddObjectToInventoryNamed(data->me_handle, event_data->it_handle, TXT("VirusDeviceName"), 0); + aShowColoredHUDMessageObj(255, 0, 0, TXT("VirusInfectFail"), event_data->it_handle); } } @@ -3447,12 +3249,12 @@ int16_t CustomObjectScript_09A1::CallEvent(int event, tOSIRISEventInfo *data) { aObjPlayAnim(Object_handles[4], 2, 3, 1.000000f, 0); aGoalCompleted(Goal_indexes[3], 1); aUserFlagSet(7, 1); - aShowHUDMessage(Message_strings[11]); + aShowHUDMessage(TXT("RechargeSucceed")); aSoundPlayObject(Sound_indexes[10], data->me_handle, 1.000000f); aObjPlayAnim(data->me_handle, 0, 3, 3.000000f, 0); } else { if (qUserFlag(7) == false) { - aShowHUDMessage(Message_strings[12]); + aShowHUDMessage(TXT("RechargeFail")); } } @@ -3534,14 +3336,14 @@ int16_t CustomObjectScript_19A0::CallEvent(int event, tOSIRISEventInfo *data) { aObjDelete(Object_handles[148]); aObjSpark(Object_handles[150], 30.000000f, 99999.000000f); aObjSpark(Object_handles[147], 30.000000f, 99999.000000f); - aShowHUDMessage(Message_strings[13]); + aShowHUDMessage(TXT("DeactivateSucceed")); aSoundPlayObject(Sound_indexes[4], Object_handles[158], 1.000000f); aSoundPlayObject(Sound_indexes[4], Object_handles[157], 1.000000f); aSoundPlayObject(Sound_indexes[10], data->me_handle, 1.000000f); aObjPlayAnim(data->me_handle, 0, 3, 3.000000f, 0); } else { if (qUserFlag(6) == false) { - aShowHUDMessage(Message_strings[14]); + aShowHUDMessage(TXT("DeactivateFail")); } } @@ -3589,7 +3391,7 @@ int16_t CustomObjectScript_09C9::CallEvent(int event, tOSIRISEventInfo *data) { 4.000000f, 30.000000f, 0, -1); aTurnOnSpew(Object_handles[168], -1, 7, 0.000000f, 0.000000f, 65536, 0, 1.200000f, 0.100000f, 3.000000f, 3.000000f, 20.000000f, 0, -1); - aCinematicIntro(Path_indexes[10], Message_strings[2], Object_handles[39], Path_indexes[11], 8.000000f); + aCinematicIntro(Path_indexes[10], TXT("EmptyMessage"), Object_handles[39], Path_indexes[11], 8.000000f); // Increment the script action counter if (ScriptActionCtr_025 < MAX_ACTION_CTR_VALUE) @@ -3649,7 +3451,7 @@ int16_t TriggerScript_000F::CallEvent(int event, tOSIRISEventInfo *data) { // Script 001: Rolling Ball Initiator if ((ScriptActionCtr_001 < 1) && (1)) { - aShowHUDMessageObj(Message_strings[3], event_data->it_handle); + aShowHUDMessageObj(TXT("Watchout"), event_data->it_handle); aSoundPlayObject(Sound_indexes[0], Object_handles[14], 1.000000f); aMiscViewerShake(60.000000f); aSetLevelTimer(1.000000f, 13); diff --git a/scripts/myPowerHouse.cpp b/scripts/myPowerHouse.cpp index a4eabcf0d..ff0a155af 100644 --- a/scripts/myPowerHouse.cpp +++ b/scripts/myPowerHouse.cpp @@ -22,10 +22,10 @@ // Filename: myPowerHouse.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include + #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -115,180 +115,12 @@ void RestoreGlobalActionCtrs(void *file_ptr) { ScriptActionCtr_000 = File_ReadIn // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} +std::map Messages; -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; - - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -332,10 +164,6 @@ int *Matcen_indexes = NULL; const char **Goal_names = NULL; int *Goal_indexes = NULL; -#define NUM_MESSAGE_NAMES 0 -const char **Message_names = NULL; -const char **Message_strings = NULL; - // =============== // InitializeDLL() // =============== @@ -349,26 +177,16 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "myPowerHouse.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { mprintf(0, "ERROR: Could not load message file - %s\n", filename); @@ -415,10 +233,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } diff --git a/scripts/orbital.cpp b/scripts/orbital.cpp index 4761cc8c9..2d1b2bbc9 100644 --- a/scripts/orbital.cpp +++ b/scripts/orbital.cpp @@ -22,10 +22,9 @@ // Filename: orbital.cpp // Version: 3 ///////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include #include "osiris_import.h" #include "osiris_common.h" #include "DallasFuncs.h" @@ -316,180 +315,12 @@ void aUpdateBypassConnDisplay(const char *text, int level) { // Message File Data // ================= -#define MAX_SCRIPT_MESSAGES 256 -#define MAX_MSG_FILEBUF_LEN 1024 -#define NO_MESSAGE_STRING "*Message Not Found*" -#define INV_MSGNAME_STRING "*Message Name Invalid*" -#define WHITESPACE_CHARS " \t\r\n" - -// Structure for storing a script message -struct tScriptMessage { - char *name; // the name of the message - char *message; // the actual message text -}; - // Global storage for level script messages -tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; -int num_messages; - -// ====================== -// Message File Functions -// ====================== - -// Initializes the Message List -void InitMessageList(void) { - for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) - message_list[j] = NULL; - num_messages = 0; -} - -// Clear the Message List -void ClearMessageList(void) { - for (int j = 0; j < num_messages; j++) { - free(message_list[j]->name); - free(message_list[j]->message); - free(message_list[j]); - message_list[j] = NULL; - } - num_messages = 0; -} - -// Adds a message to the list -int AddMessageToList(char *name, char *msg) { - int pos; - - // Make sure there is room in the list - if (num_messages >= MAX_SCRIPT_MESSAGES) - return false; - - // Allocate memory for this message entry - pos = num_messages; - message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); - if (message_list[pos] == NULL) - return false; - - // Allocate memory for the message name - message_list[pos]->name = (char *)malloc(strlen(name) + 1); - if (message_list[pos]->name == NULL) { - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->name, name); - - // Allocate memory for the message name - message_list[pos]->message = (char *)malloc(strlen(msg) + 1); - if (message_list[pos]->message == NULL) { - free(message_list[pos]->name); - free(message_list[pos]); - return false; - } - strcpy(message_list[pos]->message, msg); - num_messages++; - - return true; -} - -// Removes any whitespace padding from the end of a string -void RemoveTrailingWhitespace(char *s) { - int last_char_pos; - - last_char_pos = strlen(s) - 1; - while (last_char_pos >= 0 && isspace(s[last_char_pos])) { - s[last_char_pos] = '\0'; - last_char_pos--; - } -} - -// Returns a pointer to the first non-whitespace char in given string -char *SkipInitialWhitespace(char *s) { - while ((*s) != '\0' && isspace(*s)) - s++; - - return (s); -} - -// Read in the Messages -int ReadMessageFile(const char *filename) { - void *infile; - char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; - char *line, *msg_start; - int line_num; - bool next_msgid_found; +std::map Messages; - // Try to open the file for loading - infile = File_Open(filename, "rt"); - if (!infile) - return false; - - line_num = 0; - next_msgid_found = true; - - // Clear the message list - ClearMessageList(); - - // Read in and parse each line of the file - while (!File_eof(infile)) { - - // Clear the buffer - strcpy(filebuffer, ""); - - // Read in a line from the file - File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); - line_num++; - - // Remove whitespace padding at start and end of line - RemoveTrailingWhitespace(filebuffer); - line = SkipInitialWhitespace(filebuffer); - - // If line is a comment, or empty, discard it - if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) - continue; - - if (!next_msgid_found) { // Parse out the last message ID number - - // Grab the first keyword, make sure it's valid - line = strtok(line, WHITESPACE_CHARS); - if (line == NULL) - continue; - - // Grab the second keyword, and assign it as the next message ID - line = strtok(NULL, WHITESPACE_CHARS); - if (line == NULL) - continue; - - next_msgid_found = true; - } else { // Parse line as a message line - - // Find the start of message, and mark it - msg_start = strchr(line, '='); - if (msg_start == NULL) - continue; - msg_start[0] = '\0'; - msg_start++; - - // Add the message to the list - AddMessageToList(line, msg_start); - } - } - File_Close(infile); - - return true; -} - -// Find a message -const char *GetMessage(const char *name) { - // Make sure given name is valid - if (name == NULL) - return INV_MSGNAME_STRING; - - // Search message list for name - for (int j = 0; j < num_messages; j++) - if (strcmp(message_list[j]->name, name) == 0) - return (message_list[j]->message); - - // Couldn't find it - return NO_MESSAGE_STRING; -} +#define TXT(MSG) GetMessageNew(MSG, Messages) +#define ReadMessageFile(filename) CreateMessageMap(filename, Messages) +#define ClearMessageList() DestroyMessageMap(Messages) //====================== // Name List Arrays @@ -536,10 +367,6 @@ int *Matcen_indexes = NULL; const char **Goal_names = NULL; int *Goal_indexes = NULL; -#define NUM_MESSAGE_NAMES 0 -const char **Message_names = NULL; -const char **Message_strings = NULL; - // =============== // InitializeDLL() // =============== @@ -553,26 +380,16 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { ClearGlobalActionCtrs(); dfInit(); - InitMessageList(); // Build the filename of the message file char filename[_MAX_PATH + 32]; - int lang_type; - if (func_list->script_identifier != NULL) { - _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); - lang_type = Game_GetLanguage(); - if (lang_type == LANGUAGE_FRENCH) - strcat(filename, "_FRN"); - else if (lang_type == LANGUAGE_GERMAN) - strcat(filename, "_GER"); - else if (lang_type == LANGUAGE_ITALIAN) - strcat(filename, "_ITN"); - else if (lang_type == LANGUAGE_SPANISH) - strcat(filename, "_SPN"); + if (func_list->script_identifier != nullptr) { + _splitpath(func_list->script_identifier, nullptr, nullptr, filename, nullptr); + int lang_type = Game_GetLanguage(); + strcat(filename, lang_suffixes[lang_type].c_str()); strcat(filename, ".msg"); } else { strcpy(filename, "orbital.msg"); - lang_type = LANGUAGE_ENGLISH; } if (!ReadMessageFile(filename)) { mprintf(0, "ERROR: Could not load message file - %s\n", filename); @@ -619,10 +436,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { for (j = 0; j < NUM_GOAL_NAMES; j++) Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); - // Do Message Name lookups - for (j = 0; j < NUM_MESSAGE_NAMES; j++) - Message_strings[j] = GetMessage(Message_names[j]); - return 1; } diff --git a/scripts/osiris_common.h b/scripts/osiris_common.h index c6a53f2f4..1948c3632 100644 --- a/scripts/osiris_common.h +++ b/scripts/osiris_common.h @@ -1,5 +1,5 @@ /* -* Descent 3 +* Descent 3 * Copyright (C) 2024 Parallax Software * * This program is free software: you can redistribute it and/or modify @@ -335,10 +335,13 @@ #define __OSIRIS_COMMON_H_ #include +#include +#include #include "vecmat_external.h" #include "aistruct_external.h" #include "object_external.h" +#include "localization_external.h" #include "matcen_external.h" #include "robotfirestruct_external.h" #include "findintersection_external.h" @@ -406,16 +409,6 @@ typedef int OMMSHANDLE; -// ======================================================================= -// Language defines -// ======================================================================= -#define LANGUAGE_ENGLISH 0 -#define LANGUAGE_GERMAN 1 -#define LANGUAGE_SPANISH 2 -#define LANGUAGE_ITALIAN 3 -#define LANGUAGE_FRENCH 4 -#define LANGUAGE_POLISH 5 - // Player Accessories indices (for Player_Value function) #define ACCESSORY_CLOAK 0 #define ACCESSORY_INVULNERABILITY 1 @@ -976,8 +969,12 @@ struct gb_menu { // ======================================================================= struct tOSIRISModuleInit { + // IMPORTANT! Increment serial each time when tOSIRISModuleInit is changed + // (and update CHECKSUM define accordingly). + uint32_t serial_version = 1; + int32_t *fp[MAX_MODULEFUNCS]; - char **string_table; + std::vector string_table; int32_t string_count; int32_t module_identifier; @@ -1003,8 +1000,7 @@ struct tOSIRISEVTINTERVAL { float game_time; }; // struct for EVT_INTERVAL data -struct tOSIRISIEVTAIFRAME { -}; // struct for EVT_AI_FRAME data +struct tOSIRISIEVTAIFRAME {}; // struct for EVT_AI_FRAME data struct tOSIRISEVTDAMAGED { float damage; @@ -1017,12 +1013,11 @@ struct tOSIRISEVTCOLLIDE { int32_t it_handle; }; // struct for EVT_COLLIDE data -struct tOSIRISEVTCREATED { -}; // struct for EVT_CREATED data +struct tOSIRISEVTCREATED {}; // struct for EVT_CREATED data struct tOSIRISEVTDESTROY { - uint8_t is_dying; // if this is !=0 than the event is coming because it is - // really being destroyed. Else it is due to the level ending. + uint8_t is_dying; // if this is !=0 than the event is coming because it is + // really being destroyed. Else it is due to the level ending. }; // struct for EVT_DESTROY data struct tOSIRISEVTTIMER { @@ -1053,14 +1048,11 @@ struct tOSIRISEVTAINOTIFY { }; }; // struct for EVT_AI_NOTIFY data -struct tOSIRISEVTAIINIT { -}; // struct for EVT_AI_INIT data +struct tOSIRISEVTAIINIT {}; // struct for EVT_AI_INIT data -struct tOSIRISEVTLEVELSTART { -}; // struct for EVT_LEVELSTART data +struct tOSIRISEVTLEVELSTART {}; // struct for EVT_LEVELSTART data -struct tOSIRISEVTLEVELEND { -}; // struct for EVT_LEVELEND data +struct tOSIRISEVTLEVELEND {}; // struct for EVT_LEVELEND data struct tOSIRISEVTCHANGESEG { int32_t room_num; @@ -1085,11 +1077,9 @@ struct tOSIRISEVTMATCENCREATE { int32_t id; }; // struct for EVT_MATCEN_CREATE data -struct tOSIRISEVTDOORACTIVATE { -}; // struct for EVT_DOOR_ACTIVATE data +struct tOSIRISEVTDOORACTIVATE {}; // struct for EVT_DOOR_ACTIVATE data -struct tOSIRISEVTDOORCLOSE { -}; // struct for EVT_DOOR_CLOSE data +struct tOSIRISEVTDOORCLOSE {}; // struct for EVT_DOOR_CLOSE data struct tOSIRISEVTLEVELGOALCOMPLETE { int32_t level_goal_index; @@ -1099,14 +1089,11 @@ struct tOSIRISEVTLEVELGOALITEMCOMPLETE { int32_t level_goal_index; }; -struct tOSIRISEVTALLLEVELGOALSCOMPLETE { -}; +struct tOSIRISEVTALLLEVELGOALSCOMPLETE {}; -struct tOSIRISEVTPLAYERMOVIESTART { -}; +struct tOSIRISEVTPLAYERMOVIESTART {}; -struct tOSIRISEVTPLAYERMOVIEEND { -}; +struct tOSIRISEVTPLAYERMOVIEEND {}; struct tOSIRISEVTPLAYERRESPAWN { int32_t it_handle; // player respawning @@ -1163,7 +1150,7 @@ struct tOSIRISEventInfo { int32_t me_handle; void *extra_info; }; // contains the necessary data for all events - // to pass what they need to their event handlers. + // to pass what they need to their event handlers. #define OTF_REPEATER 0x0001 // this timer is to repeat repeat_count times #define OTF_TRIGGER 0x0002 // this timer is for a trigger, use trigger_number @@ -1313,7 +1300,6 @@ struct msafe_struct { // Second message char message2[MSAFE_MESSAGE_LENGTH]; - }; struct ray_info { diff --git a/scripts/osiris_import.cpp b/scripts/osiris_import.cpp index 18bc620bc..687856e81 100644 --- a/scripts/osiris_import.cpp +++ b/scripts/osiris_import.cpp @@ -1,3 +1,22 @@ +/* + * Descent 3 + * Copyright (C) 2024 Parallax Software + * Copyright (C) 2024 Descent Developers + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #include "osiris_import.h" mprintf_fp mprintf; @@ -124,131 +143,136 @@ AI_IsObjReachable_fp AI_IsObjReachable; Game_GetDiffLevel_fp Game_GetDiffLevel; Game_GetLanguage_fp Game_GetLanguage; Path_Value_fp Path_Value; +CreateMessageMap_fp CreateMessageMap; +DestroyMessageMap_fp DestroyMessageMap; +GetMessage_fp GetMessageNew; void osicommon_Initialize(tOSIRISModuleInit *mi) { - int i = 0; - mprintf = (mprintf_fp)mi->fp[i++]; - MSafe_CallFunction = (MSafe_CallFunction_fp)mi->fp[i++]; - MSafe_GetValue = (MSafe_GetValue_fp)mi->fp[i++]; - Obj_CallEvent = (Obj_CallEvent_fp)mi->fp[i++]; - Trgr_CallEvent = (Trgr_CallEvent_fp)mi->fp[i++]; - Sound_TouchFile = (Sound_TouchFile_fp)mi->fp[i++]; - Obj_FindID = (Obj_FindID_fp)mi->fp[i++]; - Wpn_FindID = (Wpn_FindID_fp)mi->fp[i++]; - Obj_GetTimeLived = (Obj_GetTimeLived_fp)mi->fp[i++]; - Obj_GetGunPosFP = (Obj_GetGunPos_fp)mi->fp[i++]; - Room_ValueFP = (Room_Value_fp)mi->fp[i++]; - Room_IsValid = (Room_IsValid_fp)mi->fp[i++]; - Obj_GetAttachParent = (Obj_GetAttachParent_fp)mi->fp[i++]; - Obj_GetNumAttachSlots = (Obj_GetNumAttachSlots_fp)mi->fp[i++]; - Obj_GetAttachChildHandle = (Obj_GetAttachChildHandle_fp)mi->fp[i++]; - Obj_AttachObjectAP = (Obj_AttachObjectAP_fp)mi->fp[i++]; - Obj_AttachObjectRad = (Obj_AttachObjectRad_fp)mi->fp[i++]; - Obj_UnattachFromParent = (Obj_UnattachFromParent_fp)mi->fp[i++]; - Obj_UnattachChild = (Obj_UnattachChild_fp)mi->fp[i++]; - Obj_UnattachChildren = (Obj_UnattachChildren_fp)mi->fp[i++]; - FVI_RayCast = (FVI_RayCast_fp)mi->fp[i++]; - AI_GetPathID = (AI_GetPathID_fp)mi->fp[i++]; - AI_GoalFollowPathSimpleFP = (AI_GoalFollowPathSimple_fp)mi->fp[i++]; - AI_PowerSwitch = (AI_PowerSwitch_fp)mi->fp[i++]; - AI_TurnTowardsVectors = (AI_TurnTowardsVectors_fp)mi->fp[i++]; - AI_SetType = (AI_SetType_fp)mi->fp[i++]; - AI_FindHidePos = (AI_FindHidePos_fp)mi->fp[i++]; - AI_GoalAddEnabler = (AI_GoalAddEnabler_fp)mi->fp[i++]; - AI_AddGoal = (AI_AddGoal_fp)mi->fp[i++]; - AI_ClearGoal = (AI_ClearGoal_fp)mi->fp[i++]; - AI_Value = (AI_Value_fp)mi->fp[i++]; - AI_FindObjOfTypeFP = (AI_FindObjOfType_fp)mi->fp[i++]; - AI_GetRoomPathPoint = (AI_GetRoomPathPoint_fp)mi->fp[i++]; - AI_FindEnergyCenter = (AI_FindEnergyCenter_fp)mi->fp[i++]; - AI_GetDistToObj = (AI_GetDistToObj_fp)mi->fp[i++]; - AI_SetGoalFlags = (AI_SetGoalFlags_fp)mi->fp[i++]; - AI_SetGoalCircleDist = (AI_SetGoalCircleDist_fp)mi->fp[i++]; - File_ReadBytes = (File_ReadBytes_fp)mi->fp[i++]; - File_ReadInt = (File_ReadInt_fp)mi->fp[i++]; - File_ReadShort = (File_ReadShort_fp)mi->fp[i++]; - File_ReadByte = (File_ReadByte_fp)mi->fp[i++]; - File_ReadFloat = (File_ReadFloat_fp)mi->fp[i++]; - File_ReadDouble = (File_ReadDouble_fp)mi->fp[i++]; - File_ReadString = (File_ReadString_fp)mi->fp[i++]; - File_WriteBytes = (File_WriteBytes_fp)mi->fp[i++]; - File_WriteString = (File_WriteString_fp)mi->fp[i++]; - File_WriteInt = (File_WriteInt_fp)mi->fp[i++]; - File_WriteShort = (File_WriteShort_fp)mi->fp[i++]; - File_WriteByte = (File_WriteByte_fp)mi->fp[i++]; - File_WriteFloat = (File_WriteFloat_fp)mi->fp[i++]; - File_WriteDouble = (File_WriteDouble_fp)mi->fp[i++]; - Scrpt_MemAlloc = (Scrpt_MemAlloc_fp)mi->fp[i++]; - Scrpt_MemFree = (Scrpt_MemFree_fp)mi->fp[i++]; - Scrpt_CancelTimer = (Scrpt_CancelTimer_fp)mi->fp[i++]; - Scrpt_CreateTimer = (Scrpt_CreateTimer_fp)mi->fp[i++]; - MSafe_DoPowerup = (MSafe_DoPowerup_fp)mi->fp[i++]; - Obj_CreateFP = (Obj_Create_fp)mi->fp[i++]; - Game_GetTime = (Game_GetTime_fp)mi->fp[i++]; - Game_GetFrameTime = (Game_GetFrameTime_fp)mi->fp[i++]; - Obj_WBValueFP = (Obj_WBValue_fp)mi->fp[i++]; - Scrpt_TimerExists = (Scrpt_TimerExists_fp)mi->fp[i++]; - Obj_ValueFP = (Obj_Value_fp)mi->fp[i++]; - Matcen_ValueFP = (Matcen_Value_fp)mi->fp[i++]; - Matcen_Reset = (Matcen_Reset_fp)mi->fp[i++]; - Matcen_Copy = (Matcen_Copy_fp)mi->fp[i++]; - Matcen_Create = (Matcen_Create_fp)mi->fp[i++]; - Matcen_FindID = (Matcen_FindID_fp)mi->fp[i++]; - Msn_FlagSet = (Msn_FlagSet_fp)mi->fp[i++]; - Msn_FlagGet = (Msn_FlagGet_fp)mi->fp[i++]; - Player_ValueFP = (Player_Value_fp)mi->fp[i++]; - Obj_SetCustomAnimFP = (Obj_SetCustomAnim_fp)mi->fp[i++]; - Player_AddHudMessage = (Player_AddHudMessage_fp)mi->fp[i++]; - Obj_Ghost = (Obj_Ghost_fp)mi->fp[i++]; - Obj_BurningFP = (Obj_Burning_fp)mi->fp[i++]; - Obj_IsEffect = (Obj_IsEffect_fp)mi->fp[i++]; - File_Open = (File_Open_fp)mi->fp[i++]; - File_Close = (File_Close_fp)mi->fp[i++]; - File_Tell = (File_Tell_fp)mi->fp[i++]; - File_eof = (File_eof_fp)mi->fp[i++]; - Sound_StopFP = (Sound_Stop_fp)mi->fp[i++]; - Sound_Play2dFP = (Sound_Play2d_fp)mi->fp[i++]; - Sound_Play3dFP = (Sound_Play3d_fp)mi->fp[i++]; - Sound_FindId = (Sound_FindId_fp)mi->fp[i++]; - AI_IsObjFriend = (AI_IsObjFriend_fp)mi->fp[i++]; - AI_IsObjEnemy = (AI_IsObjEnemy_fp)mi->fp[i++]; - AI_GoalValueFP = (AI_GoalValue_fp)mi->fp[i++]; - AI_GetNearbyObjsFP = (AI_GetNearbyObjs_fp)mi->fp[i++]; - AI_GetCurGoalIndex = (AI_GetCurGoalIndex_fp)mi->fp[i++]; - OMMS_Malloc = (OMMS_Malloc_fp)mi->fp[i++]; - OMMS_Attach = (OMMS_Attach_fp)mi->fp[i++]; - OMMS_Detach = (OMMS_Detach_fp)mi->fp[i++]; - OMMS_Free = (OMMS_Free_fp)mi->fp[i++]; - OMMS_Find = (OMMS_Find_fp)mi->fp[i++]; - OMMS_GetInfo = (OMMS_GetInfo_fp)mi->fp[i++]; - Cine_Start = (Cine_Start_fp)mi->fp[i++]; - Cine_Stop = (Cine_Stop_fp)mi->fp[i++]; - Scrpt_FindSoundName = (Scrpt_FindSoundName_fp)mi->fp[i++]; - Scrpt_FindRoomName = (Scrpt_FindRoomName_fp)mi->fp[i++]; - Scrpt_FindTriggerName = (Scrpt_FindTriggerName_fp)mi->fp[i++]; - Scrpt_FindObjectName = (Scrpt_FindObjectName_fp)mi->fp[i++]; - Scrpt_GetTriggerRoom = (Scrpt_GetTriggerRoom_fp)mi->fp[i++]; - Scrpt_GetTriggerFace = (Scrpt_GetTriggerFace_fp)mi->fp[i++]; - Scrpt_FindDoorName = (Scrpt_FindDoorName_fp)mi->fp[i++]; - Scrpt_FindTextureName = (Scrpt_FindTextureName_fp)mi->fp[i++]; - Game_CreateRandomSparksFP = (Game_CreateRandomSparks_fp)mi->fp[i++]; - Scrpt_CancelTimerID = (Scrpt_CancelTimerID_fp)mi->fp[i++]; - Obj_GetGroundPosFP = (Obj_GetGroundPos_fp)mi->fp[i++]; - Game_EnableShip = (Game_EnableShip_fp)mi->fp[i++]; - Game_IsShipEnabled = (Game_IsShipEnabled_fp)mi->fp[i++]; - Path_GetInformationFP = (Path_GetInformation_fp)mi->fp[i++]; - Cine_StartCanned = (Cine_StartCanned_fp)mi->fp[i++]; - Scrpt_FindMatcenName = (Scrpt_FindMatcenName_fp)mi->fp[i++]; - Scrpt_FindPathName = (Scrpt_FindPathName_fp)mi->fp[i++]; - Scrpt_FindLevelGoalName = (Scrpt_FindLevelGoalName_fp)mi->fp[i++]; - Obj_FindType = (Obj_FindType_fp)mi->fp[i++]; - LGoal_ValueFP = (LGoal_Value_fp)mi->fp[i++]; - Obj_MakeListOfType = (Obj_MakeListOfType_fp)mi->fp[i++]; - Obj_Kill = (Obj_Kill_fp)mi->fp[i++]; - // AI_AreRoomsReachable = (AI_AreRoomsReachable_fp)mi->fp[i++]; - AI_IsDestReachable = (AI_IsDestReachable_fp)mi->fp[i++]; - AI_IsObjReachable = (AI_IsObjReachable_fp)mi->fp[i++]; - Game_GetDiffLevel = (Game_GetDiffLevel_fp)mi->fp[i++]; - Game_GetLanguage = (Game_GetLanguage_fp)mi->fp[i++]; - Path_Value = (Path_Value_fp)mi->fp[i++]; + // Keep it in sync with OsirisLoadandBind.cpp + mprintf = (mprintf_fp)mi->fp[0]; + MSafe_CallFunction = (MSafe_CallFunction_fp)mi->fp[1]; + MSafe_GetValue = (MSafe_GetValue_fp)mi->fp[2]; + Obj_CallEvent = (Obj_CallEvent_fp)mi->fp[3]; + Trgr_CallEvent = (Trgr_CallEvent_fp)mi->fp[4]; + Sound_TouchFile = (Sound_TouchFile_fp)mi->fp[5]; + Obj_FindID = (Obj_FindID_fp)mi->fp[6]; + Wpn_FindID = (Wpn_FindID_fp)mi->fp[7]; + Obj_GetTimeLived = (Obj_GetTimeLived_fp)mi->fp[8]; + Obj_GetGunPosFP = (Obj_GetGunPos_fp)mi->fp[9]; + Room_ValueFP = (Room_Value_fp)mi->fp[10]; + Room_IsValid = (Room_IsValid_fp)mi->fp[11]; + Obj_GetAttachParent = (Obj_GetAttachParent_fp)mi->fp[12]; + Obj_GetNumAttachSlots = (Obj_GetNumAttachSlots_fp)mi->fp[13]; + Obj_GetAttachChildHandle = (Obj_GetAttachChildHandle_fp)mi->fp[14]; + Obj_AttachObjectAP = (Obj_AttachObjectAP_fp)mi->fp[15]; + Obj_AttachObjectRad = (Obj_AttachObjectRad_fp)mi->fp[16]; + Obj_UnattachFromParent = (Obj_UnattachFromParent_fp)mi->fp[17]; + Obj_UnattachChild = (Obj_UnattachChild_fp)mi->fp[18]; + Obj_UnattachChildren = (Obj_UnattachChildren_fp)mi->fp[19]; + FVI_RayCast = (FVI_RayCast_fp)mi->fp[20]; + AI_GetPathID = (AI_GetPathID_fp)mi->fp[21]; + AI_GoalFollowPathSimpleFP = (AI_GoalFollowPathSimple_fp)mi->fp[22]; + AI_PowerSwitch = (AI_PowerSwitch_fp)mi->fp[23]; + AI_TurnTowardsVectors = (AI_TurnTowardsVectors_fp)mi->fp[24]; + AI_SetType = (AI_SetType_fp)mi->fp[25]; + AI_FindHidePos = (AI_FindHidePos_fp)mi->fp[26]; + AI_GoalAddEnabler = (AI_GoalAddEnabler_fp)mi->fp[27]; + AI_AddGoal = (AI_AddGoal_fp)mi->fp[28]; + AI_ClearGoal = (AI_ClearGoal_fp)mi->fp[29]; + AI_Value = (AI_Value_fp)mi->fp[30]; + AI_FindObjOfTypeFP = (AI_FindObjOfType_fp)mi->fp[31]; + AI_GetRoomPathPoint = (AI_GetRoomPathPoint_fp)mi->fp[32]; + AI_FindEnergyCenter = (AI_FindEnergyCenter_fp)mi->fp[33]; + AI_GetDistToObj = (AI_GetDistToObj_fp)mi->fp[34]; + AI_SetGoalFlags = (AI_SetGoalFlags_fp)mi->fp[35]; + AI_SetGoalCircleDist = (AI_SetGoalCircleDist_fp)mi->fp[36]; + File_ReadBytes = (File_ReadBytes_fp)mi->fp[37]; + File_ReadInt = (File_ReadInt_fp)mi->fp[38]; + File_ReadShort = (File_ReadShort_fp)mi->fp[39]; + File_ReadByte = (File_ReadByte_fp)mi->fp[40]; + File_ReadFloat = (File_ReadFloat_fp)mi->fp[41]; + File_ReadDouble = (File_ReadDouble_fp)mi->fp[42]; + File_ReadString = (File_ReadString_fp)mi->fp[43]; + File_WriteBytes = (File_WriteBytes_fp)mi->fp[44]; + File_WriteString = (File_WriteString_fp)mi->fp[45]; + File_WriteInt = (File_WriteInt_fp)mi->fp[46]; + File_WriteShort = (File_WriteShort_fp)mi->fp[47]; + File_WriteByte = (File_WriteByte_fp)mi->fp[48]; + File_WriteFloat = (File_WriteFloat_fp)mi->fp[49]; + File_WriteDouble = (File_WriteDouble_fp)mi->fp[50]; + Scrpt_MemAlloc = (Scrpt_MemAlloc_fp)mi->fp[51]; + Scrpt_MemFree = (Scrpt_MemFree_fp)mi->fp[52]; + Scrpt_CancelTimer = (Scrpt_CancelTimer_fp)mi->fp[53]; + Scrpt_CreateTimer = (Scrpt_CreateTimer_fp)mi->fp[54]; + MSafe_DoPowerup = (MSafe_DoPowerup_fp)mi->fp[55]; + Obj_CreateFP = (Obj_Create_fp)mi->fp[56]; + Game_GetTime = (Game_GetTime_fp)mi->fp[57]; + Game_GetFrameTime = (Game_GetFrameTime_fp)mi->fp[58]; + Obj_WBValueFP = (Obj_WBValue_fp)mi->fp[59]; + Scrpt_TimerExists = (Scrpt_TimerExists_fp)mi->fp[60]; + Obj_ValueFP = (Obj_Value_fp)mi->fp[61]; + Matcen_ValueFP = (Matcen_Value_fp)mi->fp[62]; + Matcen_Reset = (Matcen_Reset_fp)mi->fp[63]; + Matcen_Copy = (Matcen_Copy_fp)mi->fp[64]; + Matcen_Create = (Matcen_Create_fp)mi->fp[65]; + Matcen_FindID = (Matcen_FindID_fp)mi->fp[66]; + Msn_FlagSet = (Msn_FlagSet_fp)mi->fp[67]; + Msn_FlagGet = (Msn_FlagGet_fp)mi->fp[68]; + Player_ValueFP = (Player_Value_fp)mi->fp[69]; + Obj_SetCustomAnimFP = (Obj_SetCustomAnim_fp)mi->fp[70]; + Player_AddHudMessage = (Player_AddHudMessage_fp)mi->fp[71]; + Obj_Ghost = (Obj_Ghost_fp)mi->fp[72]; + Obj_BurningFP = (Obj_Burning_fp)mi->fp[73]; + Obj_IsEffect = (Obj_IsEffect_fp)mi->fp[74]; + File_Open = (File_Open_fp)mi->fp[75]; + File_Close = (File_Close_fp)mi->fp[76]; + File_Tell = (File_Tell_fp)mi->fp[77]; + File_eof = (File_eof_fp)mi->fp[78]; + Sound_StopFP = (Sound_Stop_fp)mi->fp[79]; + Sound_Play2dFP = (Sound_Play2d_fp)mi->fp[80]; + Sound_Play3dFP = (Sound_Play3d_fp)mi->fp[81]; + Sound_FindId = (Sound_FindId_fp)mi->fp[82]; + AI_IsObjFriend = (AI_IsObjFriend_fp)mi->fp[83]; + AI_IsObjEnemy = (AI_IsObjEnemy_fp)mi->fp[84]; + AI_GoalValueFP = (AI_GoalValue_fp)mi->fp[85]; + AI_GetNearbyObjsFP = (AI_GetNearbyObjs_fp)mi->fp[86]; + AI_GetCurGoalIndex = (AI_GetCurGoalIndex_fp)mi->fp[87]; + OMMS_Malloc = (OMMS_Malloc_fp)mi->fp[88]; + OMMS_Attach = (OMMS_Attach_fp)mi->fp[89]; + OMMS_Detach = (OMMS_Detach_fp)mi->fp[90]; + OMMS_Free = (OMMS_Free_fp)mi->fp[91]; + OMMS_Find = (OMMS_Find_fp)mi->fp[92]; + OMMS_GetInfo = (OMMS_GetInfo_fp)mi->fp[93]; + Cine_Start = (Cine_Start_fp)mi->fp[94]; + Cine_Stop = (Cine_Stop_fp)mi->fp[95]; + Scrpt_FindSoundName = (Scrpt_FindSoundName_fp)mi->fp[96]; + Scrpt_FindRoomName = (Scrpt_FindRoomName_fp)mi->fp[97]; + Scrpt_FindTriggerName = (Scrpt_FindTriggerName_fp)mi->fp[98]; + Scrpt_FindObjectName = (Scrpt_FindObjectName_fp)mi->fp[99]; + Scrpt_GetTriggerRoom = (Scrpt_GetTriggerRoom_fp)mi->fp[100]; + Scrpt_GetTriggerFace = (Scrpt_GetTriggerFace_fp)mi->fp[101]; + Scrpt_FindDoorName = (Scrpt_FindDoorName_fp)mi->fp[102]; + Scrpt_FindTextureName = (Scrpt_FindTextureName_fp)mi->fp[103]; + Game_CreateRandomSparksFP = (Game_CreateRandomSparks_fp)mi->fp[104]; + Scrpt_CancelTimerID = (Scrpt_CancelTimerID_fp)mi->fp[105]; + Obj_GetGroundPosFP = (Obj_GetGroundPos_fp)mi->fp[106]; + Game_EnableShip = (Game_EnableShip_fp)mi->fp[107]; + Game_IsShipEnabled = (Game_IsShipEnabled_fp)mi->fp[108]; + Path_GetInformationFP = (Path_GetInformation_fp)mi->fp[109]; + Cine_StartCanned = (Cine_StartCanned_fp)mi->fp[110]; + Scrpt_FindMatcenName = (Scrpt_FindMatcenName_fp)mi->fp[111]; + Scrpt_FindPathName = (Scrpt_FindPathName_fp)mi->fp[112]; + Scrpt_FindLevelGoalName = (Scrpt_FindLevelGoalName_fp)mi->fp[113]; + Obj_FindType = (Obj_FindType_fp)mi->fp[114]; + LGoal_ValueFP = (LGoal_Value_fp)mi->fp[115]; + Obj_MakeListOfType = (Obj_MakeListOfType_fp)mi->fp[116]; + Obj_Kill = (Obj_Kill_fp)mi->fp[117]; + AI_IsDestReachable = (AI_IsDestReachable_fp)mi->fp[118]; + AI_IsObjReachable = (AI_IsObjReachable_fp)mi->fp[119]; + Game_GetDiffLevel = (Game_GetDiffLevel_fp)mi->fp[120]; + Game_GetLanguage = (Game_GetLanguage_fp)mi->fp[121]; + Path_Value = (Path_Value_fp)mi->fp[122]; + CreateMessageMap = (CreateMessageMap_fp)mi->fp[123]; + DestroyMessageMap = (DestroyMessageMap_fp)mi->fp[124]; + GetMessageNew = (GetMessage_fp)mi->fp[125]; } diff --git a/scripts/osiris_import.h b/scripts/osiris_import.h index e7b135934..91e7c43a0 100644 --- a/scripts/osiris_import.h +++ b/scripts/osiris_import.h @@ -19,6 +19,10 @@ #define OSIRISEXTERN extern +#include +#include +#include + #include "osiris_common.h" #if defined(POSIX) @@ -82,7 +86,7 @@ OSIRISEXTERN Obj_GetTimeLived_fp Obj_GetTimeLived; typedef void (*Obj_GetGunPos_fp)(int objhandle, int gun_number, vector *gun_pnt, vector *gun_normal); OSIRISEXTERN Obj_GetGunPos_fp Obj_GetGunPosFP; -static inline void Obj_GetGunPos(int objhandle, int gun_number, vector *gun_pnt, vector *gun_normal = NULL) { +static inline void Obj_GetGunPos(int objhandle, int gun_number, vector *gun_pnt, vector *gun_normal = nullptr) { Obj_GetGunPosFP(objhandle, gun_number, gun_pnt, gun_normal); } @@ -91,7 +95,7 @@ static inline void Obj_GetGunPos(int objhandle, int gun_number, vector *gun_pnt, typedef void (*Obj_GetGroundPos_fp)(int objhandle, int ground_number, vector *ground_pnt, vector *ground_normal); OSIRISEXTERN Obj_GetGroundPos_fp Obj_GetGroundPosFP; static inline void Obj_GetGroundPos(int objhandle, int ground_number, vector *ground_pnt, - vector *ground_normal = NULL) { + vector *ground_normal = nullptr) { Obj_GetGroundPosFP(objhandle, ground_number, ground_pnt, ground_normal); } @@ -385,16 +389,16 @@ OSIRISEXTERN MSafe_DoPowerup_fp MSafe_DoPowerup; typedef int (*Obj_Create_fp)(uint8_t type, uint16_t id, int roomnum, vector *pos, const matrix *orient, int parent_handle, vector *initial_velocity); OSIRISEXTERN Obj_Create_fp Obj_CreateFP; -static inline int Obj_Create(uint8_t type, uint16_t id, int roomnum, vector *pos, const matrix *orient = NULL, - int parent_handle = 0, vector *initial_velocity = NULL) { +static inline int Obj_Create(uint8_t type, uint16_t id, int roomnum, vector *pos, const matrix *orient = nullptr, + int parent_handle = 0, vector *initial_velocity = nullptr) { return Obj_CreateFP(type, id, roomnum, pos, orient, parent_handle, initial_velocity); } // float Game_GetTime() (void) -typedef float (*Game_GetTime_fp)(void); +typedef float (*Game_GetTime_fp)(); OSIRISEXTERN Game_GetTime_fp Game_GetTime; // float Game_GetFrameTime() (void) -typedef float (*Game_GetFrameTime_fp)(void); +typedef float (*Game_GetFrameTime_fp)(); OSIRISEXTERN Game_GetFrameTime_fp Game_GetFrameTime; // void Obj_WBValue() (int obj_handle, char wb_index, char op, char vtype, void *ptr, char g_index) @@ -573,7 +577,7 @@ typedef bool (*Cine_Start_fp)(tGameCinematic *info, const char *text_string); OSIRISEXTERN Cine_Start_fp Cine_Start; // Stops and clears up a in-game cinematic. -typedef void (*Cine_Stop_fp)(void); +typedef void (*Cine_Stop_fp)(); OSIRISEXTERN Cine_Stop_fp Cine_Stop; // Looks up the id's of the sound, room, trigger, object, ect. based on the name @@ -628,8 +632,8 @@ OSIRISEXTERN Game_IsShipEnabled_fp Game_IsShipEnabled; // returns true if operation was successful typedef bool (*Path_GetInformation_fp)(int pathid, int point, vector *pos, int *room, matrix *orient); OSIRISEXTERN Path_GetInformation_fp Path_GetInformationFP; -static inline bool Path_GetInformation(int pathid, int point, vector *pos = NULL, int *room = NULL, - matrix *orient = NULL) { +static inline bool Path_GetInformation(int pathid, int point, vector *pos = nullptr, int *room = nullptr, + matrix *orient = nullptr) { return Path_GetInformationFP(pathid, point, pos, room, orient); } // starts a canned cinematic sequence @@ -667,17 +671,10 @@ OSIRISEXTERN AI_IsDestReachable_fp AI_IsDestReachable; typedef bool (*AI_IsObjReachable_fp)(int handle, int target); OSIRISEXTERN AI_IsObjReachable_fp AI_IsObjReachable; -typedef char (*Game_GetDiffLevel_fp)(void); +typedef char (*Game_GetDiffLevel_fp)(); OSIRISEXTERN Game_GetDiffLevel_fp Game_GetDiffLevel; -/* -0:LANGUAGE_ENGLISH -1:LANGUAGE_GERMAN -2:LANGUAGE_SPANISH -3:LANGUAGE_ITALIAN -4:LANGUAGE_FRENCH -*/ -typedef int (*Game_GetLanguage_fp)(void); +typedef int (*Game_GetLanguage_fp)(); OSIRISEXTERN Game_GetLanguage_fp Game_GetLanguage; // Sets/Gets information about a path. @@ -691,6 +688,15 @@ OSIRISEXTERN Game_GetLanguage_fp Game_GetLanguage; typedef void (*Path_Value_fp)(int path_id, int node_id, char op, int changes, void *ptr); OSIRISEXTERN Path_Value_fp Path_Value; +typedef bool (*CreateMessageMap_fp)(const std::filesystem::path &filename, std::map &map); +OSIRISEXTERN CreateMessageMap_fp CreateMessageMap; + +typedef void (*DestroyMessageMap_fp)(std::map &map); +OSIRISEXTERN DestroyMessageMap_fp DestroyMessageMap; + +typedef const char *(*GetMessage_fp)(const std::string &name, std::map &map); +OSIRISEXTERN GetMessage_fp GetMessageNew; + // =========================================================== // osicommon_Initialize