From d18f5eecb4221151fdbff0c76c40202b88559870 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 3 Jun 2018 19:28:16 +0200 Subject: [PATCH] - Fixed: Dehacked must not validate parameters for MBF special functions. These won't match the conditions. Additionally this adds disassembly output for the synthesized replacement functions for diagnostics purposes. --- src/d_dehacked.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index 25b42632e..9688d3cab 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -64,6 +64,7 @@ #include "v_text.h" #include "backend/vmbuilder.h" #include "types.h" +#include "m_argv.h" // [SO] Just the way Randy said to do it :) // [RH] Made this CVAR_SERVERINFO @@ -813,6 +814,16 @@ void SetDehParams(FState *state, int codepointer) sfunc->ImplicitArgs = numargs; state->SetAction(sfunc); sfunc->PrintableName.Format("Dehacked.%s.%d.%d", MBFCodePointers[codepointer].name.GetChars(), value1, value2); + + if (Args->CheckParm("-dumpdisasm")) + { + FILE *dump = fopen("disasm.txt", "a"); + if (dump != nullptr) + { + DumpFunction(dump, sfunc, sfunc->PrintableName.GetChars(), (int)sfunc->PrintableName.Len()); + } + fclose(dump); + } } } @@ -2103,12 +2114,15 @@ static int PatchCodePtrs (int dummy) symname.Format("A_%s", Line2); // Let's consider as aliases some redundant MBF pointer + bool ismbfcp = false; for (unsigned int i = 0; i < MBFCodePointers.Size(); i++) { if (!symname.CompareNoCase(MBFCodePointers[i].alias)) { symname = MBFCodePointers[i].name; DPrintf(DMSG_SPAMMY, "%s --> %s\n", MBFCodePointers[i].alias, MBFCodePointers[i].name.GetChars()); + ismbfcp = true; + break; } } @@ -2119,7 +2133,7 @@ static int PatchCodePtrs (int dummy) { Printf(TEXTCOLOR_RED "Frame %d: Unknown code pointer '%s'\n", frame, Line2); } - else + else if (!ismbfcp) // MBF special code pointers will produce errors here because they will receive some args and won't match the conditions here. { TArray &args = sym->Variants[0].ArgFlags; unsigned numargs = sym->GetImplicitArgs();