diff --git a/RSDKv4/Script.cpp b/RSDKv4/Script.cpp index 851286e6..e309cef6 100644 --- a/RSDKv4/Script.cpp +++ b/RSDKv4/Script.cpp @@ -2878,6 +2878,27 @@ void ParseScriptFile(char *scriptName, int scriptID) } if (scriptFunctionCount < FUNCTION_COUNT && funcID == -1) { +#if !RETRO_USE_ORIGINAL_CODE + if (StrLength(funcName) >= FUNCTION_NAME_LIMIT) { + SetupTextMenu(&gameMenu[0], 0); + AddTextMenuEntry(&gameMenu[0], "SCRIPT PARSING FAILED"); + AddTextMenuEntry(&gameMenu[0], " "); + AddTextMenuEntry(&gameMenu[0], "FUNCTION NAME TOO LONG"); + AddTextMenuEntry(&gameMenu[0], funcName); + AddTextMenuEntry(&gameMenu[0], " "); + AddTextMenuEntry(&gameMenu[0], "LINE NUMBER"); + char buffer[0x10]; + buffer[0] = 0; + AppendIntegerToString(buffer, lineID); + AddTextMenuEntry(&gameMenu[0], buffer); + AddTextMenuEntry(&gameMenu[0], " "); + AddTextMenuEntry(&gameMenu[0], "ERROR IN"); + AddTextMenuEntry(&gameMenu[0], scriptName); + Engine.gameMode = ENGINE_SCRIPTERROR; + return; + } +#endif + StrCopy(scriptFunctionList[scriptFunctionCount++].name, funcName); } else { @@ -2902,6 +2923,27 @@ void ParseScriptFile(char *scriptName, int scriptID) parseMode = PARSEMODE_SCOPELESS; } else { +#if !RETRO_USE_ORIGINAL_CODE + if (StrLength(funcName) >= FUNCTION_NAME_LIMIT) { + SetupTextMenu(&gameMenu[0], 0); + AddTextMenuEntry(&gameMenu[0], "SCRIPT PARSING FAILED"); + AddTextMenuEntry(&gameMenu[0], " "); + AddTextMenuEntry(&gameMenu[0], "FUNCTION NAME TOO LONG"); + AddTextMenuEntry(&gameMenu[0], funcName); + AddTextMenuEntry(&gameMenu[0], " "); + AddTextMenuEntry(&gameMenu[0], "LINE NUMBER"); + char buffer[0x10]; + buffer[0] = 0; + AppendIntegerToString(buffer, lineID); + AddTextMenuEntry(&gameMenu[0], buffer); + AddTextMenuEntry(&gameMenu[0], " "); + AddTextMenuEntry(&gameMenu[0], "ERROR IN"); + AddTextMenuEntry(&gameMenu[0], scriptName); + Engine.gameMode = ENGINE_SCRIPTERROR; + return; + } +#endif + StrCopy(scriptFunctionList[scriptFunctionCount].name, funcName); scriptFunctionList[scriptFunctionCount].access = ACCESS_PUBLIC; scriptFunctionList[scriptFunctionCount].ptr.scriptCodePtr = scriptCodePos; @@ -2940,6 +2982,27 @@ void ParseScriptFile(char *scriptName, int scriptID) parseMode = PARSEMODE_SCOPELESS; } else { +#if !RETRO_USE_ORIGINAL_CODE + if (StrLength(funcName) >= FUNCTION_NAME_LIMIT) { + SetupTextMenu(&gameMenu[0], 0); + AddTextMenuEntry(&gameMenu[0], "SCRIPT PARSING FAILED"); + AddTextMenuEntry(&gameMenu[0], " "); + AddTextMenuEntry(&gameMenu[0], "FUNCTION NAME TOO LONG"); + AddTextMenuEntry(&gameMenu[0], funcName); + AddTextMenuEntry(&gameMenu[0], " "); + AddTextMenuEntry(&gameMenu[0], "LINE NUMBER"); + char buffer[0x10]; + buffer[0] = 0; + AppendIntegerToString(buffer, lineID); + AddTextMenuEntry(&gameMenu[0], buffer); + AddTextMenuEntry(&gameMenu[0], " "); + AddTextMenuEntry(&gameMenu[0], "ERROR IN"); + AddTextMenuEntry(&gameMenu[0], scriptName); + Engine.gameMode = ENGINE_SCRIPTERROR; + return; + } +#endif + StrCopy(scriptFunctionList[scriptFunctionCount].name, funcName); scriptFunctionList[scriptFunctionCount].access = ACCESS_PRIVATE; scriptFunctionList[scriptFunctionCount].ptr.scriptCodePtr = scriptCodePos; diff --git a/RSDKv4/Script.hpp b/RSDKv4/Script.hpp index b845880e..41bac5a8 100644 --- a/RSDKv4/Script.hpp +++ b/RSDKv4/Script.hpp @@ -9,6 +9,8 @@ #define FUNCSTACK_COUNT (0x400) #define FORSTACK_COUNT (0x400) +#define FUNCTION_NAME_LIMIT (0x20) + #define RETRO_USE_COMPILER (1) struct ScriptPtr { @@ -20,7 +22,7 @@ struct ScriptFunction { byte access; #if RETRO_USE_COMPILER - char name[0x20]; + char name[FUNCTION_NAME_LIMIT]; #endif ScriptPtr ptr; };