Reenable c++ exceptions

This commit is contained in:
ineed bots 2023-09-10 18:33:43 -06:00
parent 623d0001a9
commit 93a9fd55d5
2 changed files with 9 additions and 8 deletions

View File

@ -103,8 +103,6 @@ workspace "t4sp-server-plugin"
dependencies.imports() dependencies.imports()
exceptionhandling ("Off")
if _OPTIONS["copy-to"] then if _OPTIONS["copy-to"] then
postbuildcommands {"copy /y \"$(TargetPath)\" \"" .. _OPTIONS["copy-to"] .. "\""} postbuildcommands {"copy /y \"$(TargetPath)\" \"" .. _OPTIONS["copy-to"] .. "\""}
else else

View File

@ -109,11 +109,12 @@ namespace codsrc
} }
} }
jmp_buf g_script_error[2][33];
// Completed // Completed
void Scr_ErrorInternal(game::scriptInstance_t inst) void Scr_ErrorInternal(game::scriptInstance_t inst)
{ {
std::string a = "OH NO";
printf("%s\n", a.c_str());
assert(game::gScrVarPub[inst].error_message); assert(game::gScrVarPub[inst].error_message);
if ( !game::gScrVarPub[inst].evaluate && !game::gScrCompilePub[inst].script_loading ) if ( !game::gScrVarPub[inst].evaluate && !game::gScrCompilePub[inst].script_loading )
@ -126,8 +127,9 @@ namespace codsrc
assert(game::g_script_error_level[inst] < 33); assert(game::g_script_error_level[inst] < 33);
//game::longjmp((int*)game::g_script_error.get() + 0x10 * (0x21 * inst + game::g_script_error_level[inst]), -1); // use game's longjmp so we can enable c++ exceptions in our project without crashing due to stack unwinding a c++ object
longjmp(g_script_error[inst][game::g_script_error_level[inst]], -1); auto jmp_bufs = reinterpret_cast<jmp_buf(*)[2][33]>(game::g_script_error.get());
game::longjmp((*jmp_bufs)[inst][game::g_script_error_level[inst]], -1);
} }
game::Sys_Error("%s", game::gScrVarPub[inst].error_message); game::Sys_Error("%s", game::gScrVarPub[inst].error_message);
@ -2387,8 +2389,9 @@ namespace codsrc
assert(game::g_script_error_level[inst] >= 0); assert(game::g_script_error_level[inst] >= 0);
assert(game::g_script_error_level[inst] < 33); assert(game::g_script_error_level[inst] < 33);
assert(inst == 0 || inst == 1); assert(inst == 0 || inst == 1);
//if (game::_setjmp3((int *)game::g_script_error.get() + 0x10 * (0x21 * inst + game::g_script_error_level[inst]), 0))
if (!setjmp(g_script_error[inst][game::g_script_error_level[inst]])) auto jmp_bufs = reinterpret_cast<jmp_buf(*)[2][33]>(game::g_script_error.get());
if (!game::_setjmp3((*jmp_bufs)[inst][game::g_script_error_level[inst]], 0))
{ {
break; break;
} }