Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
gamestates fixed, mpeg now working
  • Loading branch information
Fire-Head committed Jun 2, 2019
1 parent caa61ad commit 31f349d9c2fd755679e8be2e6e346bd1bb6a1a0e
Showing with 231 additions and 46 deletions.
  1. +10 −3 src/common.h
  2. +74 −0 src/re3.cpp
  3. +147 −43 src/skel/win/win.cpp
@@ -10,7 +10,7 @@

#include <stdint.h>
#include <math.h>
#include <assert.h>
//#include <assert.h>
#include <new>

#ifdef WITHD3D
@@ -134,8 +134,15 @@ inline float sq(float x) { return x*x; }
int myrand(void);
void mysrand(unsigned int seed);

#define debug(f, ...) printf("[DBG]: " f "\n", __VA_ARGS__)
#define DEV(f, ...) printf("[DEV]: " f "", __VA_ARGS__)
void re3_debug(char *format, ...);
void re3_trace(const char *filename, unsigned int lineno, const char *func, char *format, ...);
void re3_assert(const char *expr, const char *filename, unsigned int lineno, const char *func);

#define debug(f, ...) re3_debug("[DBG]: " f, __VA_ARGS__)
#define DEV(f, ...) re3_debug("[DEV]: " f, __VA_ARGS__)
#define TRACE(f, ...) re3_trace(__FILE__, __LINE__, __FUNCTION__, f, __VA_ARGS__)

#define assert(_Expression) (void)( (!!(_Expression)) || (re3_assert(#_Expression, __FILE__, __LINE__, __FUNCTION__), 0) )
#define ASSERT assert

#define _TODO(x)
@@ -1,4 +1,5 @@
#include <direct.h>
#include <csignal>
#include <Windows.h>
#include "common.h"
#include "patcher.h"
@@ -136,6 +137,79 @@ void __declspec(naked) HeadlightsFix()
}
}

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()

0 comments on commit 31f349d

Please sign in to comment.