Merge pull request #236 from mjkzy/script-error

don't make script errors fatal error
This commit is contained in:
Maurice Heumann 2023-02-26 11:18:53 +01:00 committed by GitHub
commit 614200d429
2 changed files with 37 additions and 1 deletions

View File

@ -0,0 +1,36 @@
#include <std_include.hpp>
#include "loader/component_loader.hpp"
#include <game/game.hpp>
#include <utils/hook.hpp>
namespace patches
{
namespace
{
void script_errors_stub(const char* file, int line, unsigned int code, const char* fmt, ...)
{
char buffer[0x1000];
{
va_list ap;
va_start(ap, fmt);
vsnprintf_s(buffer, sizeof(buffer), _TRUNCATE, fmt, ap);
va_end(ap);
}
game::Com_Error(game::ERROR_SCRIPT_DROP, "%s", buffer);
}
}
struct component final : generic_component
{
void post_unpack() override
{
// don't make script errors fatal error
utils::hook::call(game::select(0x1412CAC4D, 0x140158EB2), script_errors_stub);
}
};
}
REGISTER_COMPONENT(patches::component)

View File

@ -19,7 +19,7 @@ namespace game
// Com
WEAK symbol<void(int channel, unsigned int label, const char* fmt, ...)> Com_Printf{0x1421499C0, 0x140505630};
WEAK symbol<void(const char* file, int line, int code, const char* fmt, ...)> Com_Error_{0x1420F8BD0};
WEAK symbol<void(const char* file, int line, int code, const char* fmt, ...)> Com_Error_{0x1420F8BD0, 0x140501470};
WEAK symbol<bool(eModes mode)> Com_SessionMode_IsMode{0x1420F7DD0};
WEAK symbol<void(eNetworkModes networkMode)> Com_SessionMode_SetNetworkMode{0x1420F8010, 0x140500B80};
WEAK symbol<eGameModes(eGameModes gameMode)> Com_SessionMode_SetGameMode{0x1420F7FD0, 0x140500B40};