summaryrefslogtreecommitdiffstats
path: root/src/re3.cpp
diff options
context:
space:
mode:
authorFire-Head <Fire-Head@users.noreply.github.com>2019-06-02 23:42:51 +0200
committerFire-Head <Fire-Head@users.noreply.github.com>2019-06-02 23:42:51 +0200
commit31f349d9c2fd755679e8be2e6e346bd1bb6a1a0e (patch)
treec42ccd0296cf84ea356c94fa7295c34812a5b043 /src/re3.cpp
parentmouse fixed (diff)
downloadre3-31f349d9c2fd755679e8be2e6e346bd1bb6a1a0e.tar
re3-31f349d9c2fd755679e8be2e6e346bd1bb6a1a0e.tar.gz
re3-31f349d9c2fd755679e8be2e6e346bd1bb6a1a0e.tar.bz2
re3-31f349d9c2fd755679e8be2e6e346bd1bb6a1a0e.tar.lz
re3-31f349d9c2fd755679e8be2e6e346bd1bb6a1a0e.tar.xz
re3-31f349d9c2fd755679e8be2e6e346bd1bb6a1a0e.tar.zst
re3-31f349d9c2fd755679e8be2e6e346bd1bb6a1a0e.zip
Diffstat (limited to 'src/re3.cpp')
-rw-r--r--src/re3.cpp74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/re3.cpp b/src/re3.cpp
index b7404ba2..f81c52a6 100644
--- a/src/re3.cpp
+++ b/src/re3.cpp
@@ -1,4 +1,5 @@
#include <direct.h>
+#include <csignal>
#include <Windows.h>
#include "common.h"
#include "patcher.h"
@@ -136,6 +137,79 @@ HeadlightsFix_DontLimit:
}
}
+const int re3_buffsize = 1024;
+static char re3_buff[re3_buffsize];
+
+void re3_assert(const char *expr, const char *filename, unsigned int lineno, const char *func)
+{
+ int nCode;
+
+ strcpy_s(re3_buff, re3_buffsize, "Assertion failed!" );
+ strcat_s(re3_buff, re3_buffsize, "\n" );
+
+ strcat_s(re3_buff, re3_buffsize, "File: ");
+ strcat_s(re3_buff, re3_buffsize, filename );
+ strcat_s(re3_buff, re3_buffsize, "\n" );
+
+ strcat_s(re3_buff, re3_buffsize, "Line: " );
+ _itoa_s( lineno, re3_buff + strlen(re3_buff), re3_buffsize - strlen(re3_buff), 10 );
+ strcat_s(re3_buff, re3_buffsize, "\n");
+
+ strcat_s(re3_buff, re3_buffsize, "Function: ");
+ strcat_s(re3_buff, re3_buffsize, func );
+ strcat_s(re3_buff, re3_buffsize, "\n" );
+
+ strcat_s(re3_buff, re3_buffsize, "Expression: ");
+ strcat_s(re3_buff, re3_buffsize, expr);
+ strcat_s(re3_buff, re3_buffsize, "\n");
+
+ strcat_s(re3_buff, re3_buffsize, "\n" );
+ strcat_s(re3_buff, re3_buffsize, "(Press Retry to debug the application)");
+
+
+ nCode = ::MessageBoxA(NULL, re3_buff, "RE3 Assertion Failed!",
+ MB_ABORTRETRYIGNORE|MB_ICONHAND|MB_SETFOREGROUND|MB_TASKMODAL);
+
+ if (nCode == IDABORT)
+ {
+ raise(SIGABRT);
+ _exit(3);
+ }
+
+ if (nCode == IDRETRY)
+ {
+ __debugbreak();
+ return;
+ }
+
+ if (nCode == IDIGNORE)
+ return;
+
+ abort();
+}
+
+void re3_debug(char *format, ...)
+{
+ va_list va;
+ va_start(va, format);
+ vsprintf_s(re3_buff, re3_buffsize, format, va);
+ va_end(va);
+
+ printf("%s\n", re3_buff);
+}
+
+void re3_trace(const char *filename, unsigned int lineno, const char *func, char *format, ...)
+{
+ char buff[re3_buffsize *2];
+ va_list va;
+ va_start(va, format);
+ vsprintf_s(re3_buff, re3_buffsize, format, va);
+ va_end(va);
+
+ sprintf_s(buff, re3_buffsize * 2, "[%s.%s:%d]: %s", filename, func, lineno, re3_buff);
+
+ OutputDebugStringA(buff);
+}
void
patch()