[CODE] GSC 'unknown function' reporting
Featured Replies
Сейчас на странице 0
- Нет пользователей, просматривающих эту страницу
A better way to browse. Learn more.
A full-screen app on your home screen with push notifications, badges and more.
Используя этот сайт, вы соглашаетесь Условия использования.
thought I might as well contribute
currently if you make a function type in gsc, you get an error 'unknown function'
it doesn't tell you the name or what file the error is from, though
heres a patch to do just that (displays function name and file name):
Index: PatchMW2ScriptCompileDebug.cpp =================================================================== --- PatchMW2ScriptCompileDebug.cpp (revision 122) +++ PatchMW2ScriptCompileDebug.cpp (working copy) @@ -10,6 +10,7 @@ // ========================================================== #include "StdInc.h" +#include "Script.h" const char* currentScriptFilename; @@ -152,6 +153,68 @@ Com_Error(5, "script compile error\n%s\n%s\n(see console for actual details)\n", msgbuf, scriptFilename); } +DWORD FunctionLookupStartRetn = (DWORD)0x612DB6; +DWORD FunctionLookupUnkStubRetn = (DWORD)0x612E92; +DWORD FunctionLookupUnkStub2Retn = (DWORD)0x612EA7; + +int functionRef; +char* functionStr; + +void FunctionLookupUnkFunc() +{ + functionStr = SL_ConvertToString((unsigned short)functionRef); + + char scriptFilename[512]; + + if (strstr(currentScriptFilename, ".gsc") == 0) + { + _snprintf(scriptFilename, sizeof(scriptFilename), "%s.gsc", currentScriptFilename); + } + else + { + strcpy(scriptFilename, currentScriptFilename); + } + + Com_Printf(23, "\n"); + Com_Printf(23, "******* script compile error *******\n"); + Com_Printf(23, "Howdy there, fella' - it seems you made a mistake!\n"); + Com_Printf(23, "Error: unknown function %s in %s\n", functionStr, scriptFilename); + Com_Printf(23, "************************************\n"); + + Com_Error(5, "script compile error\nunknown function %s\n%s\n", functionStr, scriptFilename); +} + +void __declspec(naked) FunctionLookupUnkStub() +{ + __asm + { + call FunctionLookupUnkFunc + mov edx, [ebx] + jmp FunctionLookupUnkStubRetn + } +} + +void __declspec(naked) FunctionLookupUnkStub2() +{ + __asm + { + call FunctionLookupUnkFunc + jmp FunctionLookupUnkStub2Retn + } +} + +void __declspec(naked) FunctionLookupStart() +{ + __asm + { + mov eax, [esp-8] + mov functionRef, eax + sub esp, 0Ch + push 0 + push edi + jmp FunctionLookupStartRetn + } +} void PatchMW2_ScriptCompileDebug() { scriptSetFileNameHook.initialize(scriptSetFileNameHookLoc, ScriptSetFileNameHookStub, 7); @@ -163,6 +226,11 @@ compileErrorHook.initialize(compileErrorHookLoc, CompileError); compileErrorHook.installHook(); + // unknown function reporting + call(0x612DB0, FunctionLookupStart, PATCH_JUMP); // to get the function name + call(0x612E85, FunctionLookupUnkStub, PATCH_JUMP); // first occurence + call(0x612E9C, FunctionLookupUnkStub2, PATCH_JUMP); // second occurence + // increase various stack bits as we push/pop ebx as well now #define ADD_STACK_BYTE(address) *(BYTE*)address += 4; #define ADD_STACK_DWORD(address) *(DWORD*)address += 4;hopefully nta will add it officially