From 0a5ce33c08402cb6d41bbce9712729aeffce882e Mon Sep 17 00:00:00 2001 From: "Marco Antonio J. Costa" Date: Fri, 21 Aug 2026 23:50:11 -0300 Subject: [PATCH] Move the remaining header build switches into the build system Same reasoning as builddefines.h: BMP_RANDOM, CALLBACKTIMER, WINDOWED_MODE and the three multiplayer switches are build configuration, and a header is the wrong place to keep them. None of the six was ever toggled from source -- they were unconditional #defines, or in WINDOWED_MODE's case keyed off _DEBUG. WINDOWED_MODE now keys off the Debug configuration rather than _DEBUG. That is the same thing in an ordinary Debug build, and fixes the asan Debug build, which links the release CRT and so never saw _DEBUG at all. All twelve executables stay bit-identical, this time with no differing bytes to explain away at all. Co-Authored-By: Claude Opus 5 --- CMakeLists.txt | 19 ++++++++++++++++++- Ja2/local.h | 8 -------- Multiplayer/connect.h | 11 ----------- Utils/Timer Control.h | 4 ---- sgp/random.h | 2 -- 5 files changed, 18 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 325bf6d39..6021e272f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,6 +106,21 @@ add_compile_definitions( ROBOT_ALWAYS_READY # keep Assert() live in configurations that would otherwise compile it out FORCE_ASSERTS_ON + # sgp/random.h: the 32-bit PRNG. Turning this off returns the old generator, + # which only ever yields 2^15 distinct values -- it breaks big maps and + # invalidates saves. + BMP_RANDOM + # Utils/Timer Control.h + CALLBACKTIMER + + # Multiplayer (WANNE), formerly Multiplayer/connect.h. + # Interrupts stay off in COOP: AI interrupts computed on a pure client are + # still wrong. This also drops the server-side ALT+E "override turn" dialog, + # which should no longer be needed. + DISABLE_MP_INTERRUPTS_IN_COOP + # r5623 workaround for the enemy AI deadlocking on a pure-client interrupt + INTERRUPT_MP_DEADLOCK_FIX + ENABLE_MP_FRIENDLY_PLAYERS_SHARE_SAME_FOV ) # ja2export utility @@ -199,7 +214,9 @@ ValidateOptions("${ValidApplications}" "Applications" "${Applications}" "Applica # preprocessor definitions for Debug build, per the legacy MSBuild -set(debugFlags $,JA2BETAVERSION;JA2TESTVERSION;DEBUG_ATTACKBUSY,>) +# WINDOWED_MODE was keyed off _DEBUG in Ja2/local.h, which an asan Debug build +# does not get: it links the release CRT (see CMAKE_MSVC_RUNTIME_LIBRARY above). +set(debugFlags $,JA2BETAVERSION;JA2TESTVERSION;DEBUG_ATTACKBUSY;WINDOWED_MODE,>) foreach(app IN LISTS ApplicationTargets) set(isEditor $) diff --git a/Ja2/local.h b/Ja2/local.h index c52e262f4..7995874c6 100644 --- a/Ja2/local.h +++ b/Ja2/local.h @@ -18,14 +18,6 @@ // Basic defines for the video manager. These represent the starting values // -#ifdef BOUNDS_CHECKER - #define WINDOWED_MODE -#endif - -#ifdef _DEBUG - #define WINDOWED_MODE -#endif - extern UINT16 SCREEN_WIDTH; extern UINT16 SCREEN_HEIGHT; diff --git a/Multiplayer/connect.h b/Multiplayer/connect.h index dd85e9d83..816e12d3f 100644 --- a/Multiplayer/connect.h +++ b/Multiplayer/connect.h @@ -149,17 +149,6 @@ extern char cServerName[30]; //OJW - 20081224 #define MAX_CONNECT_RETRIES 5 -// WANNE: Completly disable interrupts in a multiplayer COOP game (see TeamTurns.cpp::StandardInterruptConditionsMet), because we still have problems in the code with AI interrupts calculated on the pure client -// This also disabled the "override turn" dialog, which would be displayed on the server by pressing ALT + E, because it should not be needed anymore -#define DISABLE_MP_INTERRUPTS_IN_COOP - -// WANNE: After some MP-Tests: It seems there are still problems with enemy interupt and if this define is enabled the ALT + E (give turn to client) does not work either. So I disabled this define for now ... -// WANNE: If this define is enabled, it hopefully fixes the "enemy AI got stuck on pure client interrupt". (this "fix" was added in revision 5623) -#define INTERRUPT_MP_DEADLOCK_FIX - -// WANNE: This features seems to work without any errors, so it is enabled :) -#define ENABLE_MP_FRIENDLY_PLAYERS_SHARE_SAME_FOV - #define ENABLE_COLLISION (is_server && pBullet->ubFirerID<120) || (!is_server && is_client && pBullet->ubFirerID<20) || (!is_server && !is_client) extern bool auto_retry; extern int giNumTries; diff --git a/Utils/Timer Control.h b/Utils/Timer Control.h index 16b25c3bd..b3a9c7ee7 100644 --- a/Utils/Timer Control.h +++ b/Utils/Timer Control.h @@ -1,10 +1,6 @@ #ifndef __TIMER_CONTROL_H #define __TIMER_CONTROL_H -#ifndef CALLBACKTIMER -#define CALLBACKTIMER -#endif - typedef INT32 TIMECOUNTER; //typedef void (__stdcall *JA2_TIMERPROC)( UINT32 uiID, UINT32 uiMsg, UINT32 uiUser, UINT32 uiDw1, UINT32 uiDw2 ); diff --git a/sgp/random.h b/sgp/random.h index 446fc8d38..3e81f36d4 100644 --- a/sgp/random.h +++ b/sgp/random.h @@ -1,8 +1,6 @@ #ifndef __RANDOM_ #define __RANDOM_ -#define BMP_RANDOM - #include "types.h" #include "DEBUG.H" #include "GameSettings.h"