diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index 6b0059981..7cd599b11 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -2014,13 +2014,13 @@ void FParser::SF_CeilingTexture(void) void FParser::SF_ChangeHubLevel(void) { - I_Error("FS hub system permanently disabled\n"); + script_error("FS hub system permanently disabled\n"); } // for start map: start new game on a particular skill void FParser::SF_StartSkill(void) { - I_Error("startskill is not supported by this implementation!\n"); + script_error("startskill is not supported by this implementation!\n"); } //========================================================================== diff --git a/src/fragglescript/t_parse.cpp b/src/fragglescript/t_parse.cpp index 0b2f27680..28330e9e9 100644 --- a/src/fragglescript/t_parse.cpp +++ b/src/fragglescript/t_parse.cpp @@ -113,7 +113,7 @@ void FParser::NextToken() } if(!Section) { - I_Error("section not found!\n"); + script_error("section not found!\n"); return; } } @@ -708,6 +708,18 @@ void FParser::EvaluateExpression(svalue_t &result, int start, int stop) // //========================================================================== +void FS_Error(const char *error, ...) +{ + va_list argptr; + char errortext[MAX_ERRORTEXT]; + + va_start(argptr, error); + myvsnprintf(errortext, MAX_ERRORTEXT, error, argptr); + va_end(argptr); + throw CFraggleScriptError(errortext); +} + + void FParser::ErrorMessage(FString msg) { int linenum = 0; @@ -721,7 +733,7 @@ void FParser::ErrorMessage(FString msg) } //lineinfo.Format("Script %d, line %d: ", Script->scriptnum, linenum); - I_Error("Script %d, line %d: %s", Script->scriptnum, linenum, msg.GetChars()); + FS_Error("Script %d, line %d: %s", Script->scriptnum, linenum, msg.GetChars()); } //========================================================================== diff --git a/src/fragglescript/t_script.cpp b/src/fragglescript/t_script.cpp index b852607b3..81b2ce21e 100644 --- a/src/fragglescript/t_script.cpp +++ b/src/fragglescript/t_script.cpp @@ -251,7 +251,7 @@ void DFsScript::ParseScript(char *position) FParser parse(this); parse.Run(position, data, data + len); } - catch (CRecoverableError &err) + catch (CFraggleScriptError &err) { Printf ("%s\n", err.GetMessage()); } diff --git a/src/fragglescript/t_script.h b/src/fragglescript/t_script.h index 50829e000..f0409a3f0 100644 --- a/src/fragglescript/t_script.h +++ b/src/fragglescript/t_script.h @@ -41,12 +41,22 @@ #include "p_lnspec.h" #include "m_fixed.h" #include "actor.h" +#include "doomerrors.h" #ifdef _MSC_VER // This pragma saves 8kb of wasted code. #pragma pointers_to_members( full_generality, single_inheritance ) #endif + +class CFraggleScriptError : public CDoomError +{ +public: + CFraggleScriptError() : CDoomError() {} + CFraggleScriptError(const char *message) : CDoomError(message) {} +}; + + class DRunningScript;