Skip to content

Commit

Permalink
Fix cops yanked by spidey crashing the game
Browse files Browse the repository at this point in the history
  • Loading branch information
krystalgamer committed Nov 9, 2023
1 parent 1d6bb0e commit a6ad4aa
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 2 deletions.
2 changes: 2 additions & 0 deletions texture_loader/loader.c
Expand Up @@ -11,7 +11,9 @@ BOOL WINAPI DllMain(HINSTANCE hInstDll, DWORD fdwReason, LPVOID reserverd){

if(fdwReason == DLL_PROCESS_ATTACH){

#if DEBUG
AllocateConsole();
#endif

if (FALSE == CheckBinkwVersion()) {
return FALSE;
Expand Down
10 changes: 9 additions & 1 deletion texture_loader/new_ep.c
Expand Up @@ -5,7 +5,7 @@
#include "patches.h"
#include "console.h"

#define CTL_VERSION "0.8"
#define CTL_VERSION "0.9"

typedef int (*OriginalEntryPoint_t)(void);
OriginalEntryPoint_t OriginalEntryPoint = (OriginalEntryPoint_t)0x0052B46F;
Expand All @@ -19,6 +19,7 @@ typedef struct{
bool psx_graphics;
bool frame_counter;
bool frame_limiter;
bool fix_bugs;
} Settings;

void EnsureBinkw32IsLoaded(void) {
Expand Down Expand Up @@ -127,6 +128,10 @@ static BOOL ApplyMyPatches(const Settings *settings){
DO_OR_QUIT(FrameLimiter());
}

if (settings->fix_bugs) {
DO_OR_QUIT(FixBugs());
}

return TRUE;
}

Expand Down Expand Up @@ -210,6 +215,7 @@ static void WriteSettingsToDisk(const Settings *settings) {
AddSettingToJsonObject(json, "file_loader", settings->file_loader);
AddSettingToJsonObject(json, "frame_counter", settings->frame_counter);
AddSettingToJsonObject(json, "frame_limiter", settings->frame_limiter);
AddSettingToJsonObject(json, "fix_bugs", settings->fix_bugs);

char *content = cJSON_Print(json);
fputs(content, fp);
Expand Down Expand Up @@ -262,6 +268,7 @@ static void ReadSettings(Settings* settings) {
GetJsonBool(json, "file_loader", &settings->file_loader);
GetJsonBool(json, "frame_counter", &settings->frame_counter);
GetJsonBool(json, "frame_limiter", &settings->frame_limiter);
GetJsonBool(json, "fix_bugs", &settings->fix_bugs);
cJSON_Delete(json);
}

Expand All @@ -280,6 +287,7 @@ static int NewEntryPoint() {
.psx_graphics = false,
.frame_counter = false,
.frame_limiter = false,
.fix_bugs = true,
};

ReadSettings(&settings);
Expand Down
11 changes: 11 additions & 0 deletions texture_loader/patches.c
Expand Up @@ -394,3 +394,14 @@ BOOL FrameLimiter() {

return TRUE;
}

/************************************************
FIX BUGS
************************************************/

BOOL FixBugs() {
Nop(0x0042D49B, 8, "Fix CCop::GetYankedBySpidey null dereference that assumes CBaddy::StruckGameObject was called");
return TRUE;
}
1 change: 1 addition & 0 deletions texture_loader/patches.h
Expand Up @@ -10,5 +10,6 @@ BOOL DisableFmvs();
BOOL FileLoader();
BOOL TextureLoader();
BOOL ModOptions();
BOOL FixBugs();

#endif
3 changes: 2 additions & 1 deletion texture_loader/sm2000.json
Expand Up @@ -6,5 +6,6 @@
"texture_loader": true,
"file_loader": true,
"frame_counter": false,
"frame_limiter": false
"frame_limiter": false,
"fix_bugs": true
}

0 comments on commit a6ad4aa

Please sign in to comment.