diff --git a/artifacts/scripting/headers/lib.math.h b/artifacts/scripting/headers/lib.math.h index 0d5588c1..9f3191d4 100644 --- a/artifacts/scripting/headers/lib.math.h +++ b/artifacts/scripting/headers/lib.math.h @@ -5,6 +5,17 @@ Numbers... */ +#define above(a, b) (unsigned_comp(a, b) > 0) +#define above_equal(a, b) (unsigned_comp(a, b) >= 0) +#define below(a, b) (unsigned_comp(a, b) < 0) +#define below_equal(a, b) (unsigned_comp(a, b) <= 0) + +procedure unsigned_comp(variable a, variable b) begin + if (a bwxor b) then return 0; + if (b == 0) then return 1; + return 1 if (a / b) else -1; +end + #define MAX(x, y) ((x > y) * x + (x <= y) * y) #define MIN(x, y) ((x < y) * x + (x >= y) * y) #define in_range(x, from, to) (x >= from and x <= to) diff --git a/sfall/Console.cpp b/sfall/Console.cpp index 459f7609..eefa5df8 100644 --- a/sfall/Console.cpp +++ b/sfall/Console.cpp @@ -22,12 +22,10 @@ #include "Console.h" -using namespace std; +static std::ofstream consoleFile; -static ofstream consolefile; - -static void _stdcall ConsoleFilePrint(const char* msg) { - consolefile << msg << endl; +static void __stdcall ConsoleFilePrint(const char* msg) { + consoleFile << msg << std::endl; } static const DWORD ConsoleHookRet = 0x431871; @@ -49,15 +47,15 @@ static void __declspec(naked) ConsoleHook() { void ConsoleInit() { std::string path = GetConfigString("Misc", "ConsoleOutputPath", "", MAX_PATH); if (!path.empty()) { - consolefile.open(path); - if (consolefile.is_open()) { + consoleFile.open(path); + if (consoleFile.is_open()) { MakeJump(0x43186C, ConsoleHook); } } } void ConsoleExit() { - if (consolefile.is_open()) { - consolefile.close(); + if (consoleFile.is_open()) { + consoleFile.close(); } } diff --git a/sfall/Logging.cpp b/sfall/Logging.cpp index 4246412a..3bc2c48f 100644 --- a/sfall/Logging.cpp +++ b/sfall/Logging.cpp @@ -23,10 +23,8 @@ #include -using namespace std; - -static int DebugTypes=0; -static ofstream Log; +static int DebugTypes = 0; +static std::ofstream Log; void dlog(const char* a, int type) { if (isDebug && (type == DL_MAIN || (type & DebugTypes))) { @@ -55,7 +53,7 @@ void dlog_f(const char *fmt, int type, ...) { } void LoggingInit() { - Log.open("sfall-log.txt", ios_base::out | ios_base::trunc); + Log.open("sfall-log.txt", std::ios_base::out | std::ios_base::trunc); if (iniGetInt("Debugging", "Init", 0, ddrawIniDef)) { DebugTypes |= DL_INIT; } diff --git a/sfall/Movies.cpp b/sfall/Movies.cpp index 074d0e3a..c5b8b445 100644 --- a/sfall/Movies.cpp +++ b/sfall/Movies.cpp @@ -90,8 +90,8 @@ private: HRESULT hr = pAllocNotify->AllocateSurfaceHelper(lpAllocInfo, lpNumBuffers, &surfaces[0]); if (FAILED(hr)) return hr; - dlog_f(" Height: %d,", DL_INIT, lpAllocInfo->dwHeight); dlog_f(" Width: %d,", DL_INIT, lpAllocInfo->dwWidth); + dlog_f(" Height: %d,", DL_INIT, lpAllocInfo->dwHeight); dlog_f(" Format: %d", DL_INIT, lpAllocInfo->Format); hr = surfaces[0]->GetContainer(IID_IDirect3DTexture9, (void**)&pTex);