From 8a4a83c8f86196c87d4140d4d2527b63f9a49f51 Mon Sep 17 00:00:00 2001 From: NovaRain Date: Sun, 27 Jan 2019 10:43:54 +0800 Subject: [PATCH] Added HideObjIsNullMsg option to [Debugging]. Moved DebugEditor option from MiscPatches.cpp to DebugEditor.cpp. --- artifacts/ddraw.ini | 3 + sfall/DebugEditor.cpp | 243 +++++++++++++++++++++++++++--------------- sfall/DebugEditor.h | 3 +- sfall/main.cpp | 40 +------ 4 files changed, 162 insertions(+), 127 deletions(-) diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index cd5df246..194fce69 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -703,6 +703,9 @@ DontDeleteProtos=0 ;Set to 1 to give scripts direct access to Fallout's address space, and to make arbitrary calls into Fallout's code AllowUnsafeScripting=0 +;Set to 1 to hide error messages in the debug.log file when a null value is passed to the function as an object +HideObjIsNullMsg=0 + ;These options control what output is saved in the debug log (sfall-log.txt) ;Prints messages duing sfall initialization diff --git a/sfall/DebugEditor.cpp b/sfall/DebugEditor.cpp index a2ea017a..748abf81 100644 --- a/sfall/DebugEditor.cpp +++ b/sfall/DebugEditor.cpp @@ -38,44 +38,50 @@ #define CODE_GET_ARRAY (9) #define CODE_SET_ARRAY (10) +static const char* debugLog = "LOG"; +static const char* debugGnw = "GNW"; + static bool SetBlocking(SOCKET s, bool block) { - DWORD d=!block; + DWORD d = !block; ioctlsocket(s, FIONBIO, &d); } + static bool InternalSend(SOCKET s, const void* _data, int size) { - const char* data=(const char*) _data; - int upto=0; + const char* data = (const char*)_data; + int upto = 0; int tmp; DWORD d; - while(upto0) upto+=tmp; + while (upto < size) { + tmp = send(s, &data[upto], size - upto, 0); + if (tmp > 0) upto += tmp; else { - d=WSAGetLastError(); - if(d!=WSAEWOULDBLOCK && d!=WSAENOBUFS) return true; + d = WSAGetLastError(); + if (d != WSAEWOULDBLOCK && d != WSAENOBUFS) return true; } } return false; } + static bool InternalRecv(SOCKET s, void* _data, int size) { - char* data=(char*)_data; - int upto=0; + char* data = (char*)_data; + int upto = 0; int tmp; DWORD d; - while(upto0) upto+=tmp; + while (upto < size) { + tmp = recv(s, &data[upto], size - upto, 0); + if (tmp > 0) upto += tmp; else { - d=WSAGetLastError(); - if(d!=WSAEWOULDBLOCK && d!=WSAENOBUFS) return true; + d = WSAGetLastError(); + if (d != WSAEWOULDBLOCK && d != WSAENOBUFS) return true; } } return false; } + static void RunEditorInternal(SOCKET &s) { std::vector vec = std::vector(); - for(int elv=0;elv<3;elv++) { - for(int tile=0;tile<40000;tile++) { + for (int elv = 0; elv < 3; elv++) { + for (int tile = 0; tile < 40000; tile++) { DWORD* obj; __asm { mov edx, tile; @@ -83,10 +89,10 @@ static void RunEditorInternal(SOCKET &s) { call obj_find_first_at_tile_; mov obj, eax; } - while(obj) { + while (obj) { DWORD otype = obj[25]; - otype = (otype&0xff000000) >> 24; - if(otype==1) vec.push_back(obj); + otype = (otype & 0xFF000000) >> 24; + if (otype == 1) vec.push_back(obj); __asm { call obj_find_next_at_tile_; mov obj, eax; @@ -95,12 +101,12 @@ static void RunEditorInternal(SOCKET &s) { } } - int numCritters=vec.size(); + int numCritters = vec.size(); - int numGlobals=*(int*)_num_game_global_vars; - int numMapVars=*(int*)_num_map_global_vars; - int numSGlobals=GetNumGlobals(); - int numArrays=GetNumArrays(); + int numGlobals = *(int*)_num_game_global_vars; + int numMapVars = *(int*)_num_map_global_vars; + int numSGlobals = GetNumGlobals(); + int numArrays = GetNumArrays(); InternalSend(s, &numGlobals, 4); InternalSend(s, &numMapVars, 4); InternalSend(s, &numSGlobals, 4); @@ -109,65 +115,67 @@ static void RunEditorInternal(SOCKET &s) { sGlobalVar* sglobals=new sGlobalVar[numSGlobals]; GetGlobals(sglobals); - int* arrays=new int[numArrays*3]; + int* arrays = new int[numArrays * 3]; GetArrays(arrays); - InternalSend(s, *(void**)_game_global_vars, 4*numGlobals); - InternalSend(s, *(void**)_map_global_vars, 4*numMapVars); - InternalSend(s, sglobals, sizeof(sGlobalVar)*numSGlobals); - InternalSend(s, arrays, numArrays*3*4); - for(int i=0;i