diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index b2c8d5b9..a61cc0dd 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -724,8 +724,8 @@ CreditsAtBottom=0 ;Paths outside of scripts folder are supported GlobalScriptPaths=scripts\gl*.int,scripts\sfall\gl*.int -;Uncomment the option to specify a common folder path for all scripted ini configuration files -;You will need to place all the available ini files of the mods to this directory +;Uncomment the option to specify a common folder path for all ini files used by scripts +;You will have to put all the available ini files of the mods in this directory ;The maximum length of the specified path is 61 characters ;IniConfigFolder=IniConfig diff --git a/sfall/Modules/Criticals.cpp b/sfall/Modules/Criticals.cpp index 3df9c377..29a3ec6a 100644 --- a/sfall/Modules/Criticals.cpp +++ b/sfall/Modules/Criticals.cpp @@ -261,7 +261,7 @@ void Criticals::init() { mode = GetConfigInt("Misc", "OverrideCriticalTable", 2); if (mode < 0 || mode > 3) mode = 0; if (mode) { - critTableFile += GetConfigString("Misc", "OverrideCriticalFile", "CriticalOverrides.ini", MAX_PATH - 3); + critTableFile += GetConfigString("Misc", "OverrideCriticalFile", "CriticalOverrides.ini", MAX_PATH); CriticalTableOverride(); } diff --git a/sfall/Modules/ScriptExtender.cpp b/sfall/Modules/ScriptExtender.cpp index eff5a4a7..3c17303e 100644 --- a/sfall/Modules/ScriptExtender.cpp +++ b/sfall/Modules/ScriptExtender.cpp @@ -602,12 +602,11 @@ static DWORD _stdcall HandleMapUpdateForScripts(const DWORD procId) { for (SfallProgsMap::iterator it = sfallProgsMap.begin(); it != sfallProgsMap.end(); it++) { fo::func::runProgram(it->second.ptr); } - } + } else if (procId == fo::ScriptProc::map_exit_p_proc) onMapExit.invoke(); + RunGlobalScriptsAtProc(procId); // gl* scripts of types 0 and 3 RunHookScriptsAtProc(procId); // all hs_ scripts - if (procId == fo::ScriptProc::map_exit_p_proc) onMapExit.invoke(); - return procId; // restore eax (don't delete) } @@ -726,7 +725,7 @@ void ScriptExtender::init() { dlogr("Arrays in backward-compatiblity mode.", DL_SCRIPT); } - iniConfigFolder = GetConfigString("Scripts", "IniConfigFolder", ""); + iniConfigFolder = GetConfigString("Scripts", "IniConfigFolder", "", 64); size_t len = iniConfigFolder.length(); if (len) { char c = iniConfigFolder[len - 1]; diff --git a/sfall/Modules/Scripting/Handlers/Utils.cpp b/sfall/Modules/Scripting/Handlers/Utils.cpp index d5f85ee6..55e04f66 100644 --- a/sfall/Modules/Scripting/Handlers/Utils.cpp +++ b/sfall/Modules/Scripting/Handlers/Utils.cpp @@ -276,24 +276,22 @@ void sf_round(OpcodeContext& ctx) { void sf_message_str_game(OpcodeContext& ctx) { const char* msg = nullptr; - const ScriptValue &fileIdArg = ctx.arg(0), - &msgIdArg = ctx.arg(1); - int fileId = fileIdArg.asInt(); - int msgId = msgIdArg.asInt(); - if (fileId >= 0 && fileId <= 19) { // main msg files - msg = fo::GetMessageStr(gameMsgFiles[fileId], msgId); - } else if (fileId >= 0x1000 && fileId <= 0x1005) { // proto msg files - msg = fo::GetMessageStr(&fo::var::proto_msg_files[fileId - 0x1000], msgId); - } else if (fileId >= 0x2000) { // Extra game message files. - ExtraGameMessageListsMap::iterator it = gExtraGameMsgLists.find(fileId); - if (it != gExtraGameMsgLists.end()) { - msg = GetMsg(it->second.get(), msgId, 2); + int fileId = ctx.arg(0).rawValue(); + if (fileId >= 0) { + int msgId = ctx.arg(1).rawValue(); + if (fileId < 20) { // main msg files + msg = fo::GetMessageStr(gameMsgFiles[fileId], msgId); + } else if (fileId >= 0x1000 && fileId <= 0x1005) { // proto msg files + msg = fo::GetMessageStr(&fo::var::proto_msg_files[fileId - 0x1000], msgId); + } else if (fileId >= 0x2000) { // Extra game message files. + ExtraGameMessageListsMap::iterator it = gExtraGameMsgLists.find(fileId); + if (it != gExtraGameMsgLists.end()) { + msg = GetMsg(it->second.get(), msgId, 2); + } } } - if (msg == nullptr) { - msg = "Error"; - } + if (msg == nullptr) msg = "Error"; ctx.setReturn(msg); } diff --git a/sfall/Modules/Scripting/ScriptValue.cpp b/sfall/Modules/Scripting/ScriptValue.cpp index 187b5763..e5911f6f 100644 --- a/sfall/Modules/Scripting/ScriptValue.cpp +++ b/sfall/Modules/Scripting/ScriptValue.cpp @@ -70,8 +70,7 @@ ScriptValue::ScriptValue(fo::GameObject* obj) { _type = DataType::INT; } -bool ScriptValue::isInt() const -{ +bool ScriptValue::isInt() const { return _type == DataType::INT; } diff --git a/sfall/Modules/Skills.cpp b/sfall/Modules/Skills.cpp index 36dabfa5..45bbb4da 100644 --- a/sfall/Modules/Skills.cpp +++ b/sfall/Modules/Skills.cpp @@ -332,7 +332,7 @@ void Skills::init() { HookCall(0x47831E, item_w_skill_hook); char buf[512], key[16]; - auto skillsFile = GetConfigString("Misc", "SkillsFile", ""); + auto skillsFile = GetConfigString("Misc", "SkillsFile", "", MAX_PATH); if (!skillsFile.empty()) { fo::SkillInfo *skills = fo::var::skill_data; diff --git a/sfall/main.cpp b/sfall/main.cpp index 2fa8dc68..e4cf2cdb 100644 --- a/sfall/main.cpp +++ b/sfall/main.cpp @@ -285,7 +285,7 @@ inline void SfallInit() { strcpy_s(ini, ::sfall::ddrawIni); } - GetConfigString("Main", "TranslationsINI", "./Translations.ini", translationIni, 65); + GetConfigString("Main", "TranslationsINI", ".\\Translations.ini", translationIni, 65); modifiedIni = GetConfigInt("Main", "ModifiedIni", 0); InitModules();