From 2330dd97bb8c5561dc547fce3f8cc55a162e552f Mon Sep 17 00:00:00 2001 From: Vennor Date: Mon, 9 May 2016 19:10:25 +0200 Subject: [PATCH] Refactored op_message_str_game2 function to always return a valid string value. Now an "Error" string will be returned on error instead of an uninitialized char pointer or an integer value. --- sfall/ScriptOps/ScriptUtils.hpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/sfall/ScriptOps/ScriptUtils.hpp b/sfall/ScriptOps/ScriptUtils.hpp index a230a2cb..023a4b45 100644 --- a/sfall/ScriptOps/ScriptUtils.hpp +++ b/sfall/ScriptOps/ScriptUtils.hpp @@ -862,9 +862,10 @@ static const DWORD* proto_msg_files = (DWORD*)0x006647AC; static void _stdcall op_message_str_game2() { DWORD fileId = opArgs[0]; + const char* msg = 0; + if (IsOpArgInt(0) && IsOpArgInt(1)) { int msgId = GetOpArgInt(1); - const char* msg; if (fileId < 20) { // main msg files msg = GetMessageStr(game_msg_files[fileId], msgId); } @@ -876,16 +877,13 @@ static void _stdcall op_message_str_game2() { if (it != gExtraGameMsgLists.end()) msg = GetMsg(it->second, msgId, 2); - else - msg = 0; } - if (msg != 0) - SetOpReturn(msg); - else - SetOpReturn(0, DATATYPE_INT); - } else { - SetOpReturn(0, DATATYPE_INT); } + + if (msg == 0) + msg = "Error"; + + SetOpReturn(msg); } static void __declspec(naked) op_message_str_game() {