From acf29bf263c1349d0c2c4e165986bf9e823669bf Mon Sep 17 00:00:00 2001 From: xezon <4720891+xezon@users.noreply.github.com> Date: Sun, 25 Jan 2026 11:23:59 +0100 Subject: [PATCH 1/2] unify(lib): Move BaseType.h, trig.h to Core (#2185) --- Core/CMakeLists.txt | 2 + .../Libraries/Include/Lib/BaseType.h | 0 .../Libraries/Include/Lib/trig.h | 0 Generals/Code/CMakeLists.txt | 8 - .../Code/Libraries/Include/Lib/BaseType.h | 453 ------------------ Generals/Code/Libraries/Include/Lib/trig.h | 30 -- GeneralsMD/Code/CMakeLists.txt | 8 - scripts/cpp/unify_move_files.py | 3 + 8 files changed, 5 insertions(+), 499 deletions(-) rename {GeneralsMD/Code => Core}/Libraries/Include/Lib/BaseType.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Include/Lib/trig.h (100%) delete mode 100644 Generals/Code/Libraries/Include/Lib/BaseType.h delete mode 100644 Generals/Code/Libraries/Include/Lib/trig.h diff --git a/Core/CMakeLists.txt b/Core/CMakeLists.txt index ccf2513e5e6..7c1269d1db9 100644 --- a/Core/CMakeLists.txt +++ b/Core/CMakeLists.txt @@ -14,7 +14,9 @@ target_include_directories(corei_libraries_source_wwvegas_wwlib INTERFACE "Libra target_include_directories(corei_main INTERFACE "Main") target_sources(corei_libraries_include PRIVATE + Libraries/Include/Lib/BaseType.h Libraries/Include/Lib/BaseTypeCore.h + Libraries/Include/Lib/trig.h Libraries/Include/rts/debug.h Libraries/Include/rts/profile.h ) diff --git a/GeneralsMD/Code/Libraries/Include/Lib/BaseType.h b/Core/Libraries/Include/Lib/BaseType.h similarity index 100% rename from GeneralsMD/Code/Libraries/Include/Lib/BaseType.h rename to Core/Libraries/Include/Lib/BaseType.h diff --git a/GeneralsMD/Code/Libraries/Include/Lib/trig.h b/Core/Libraries/Include/Lib/trig.h similarity index 100% rename from GeneralsMD/Code/Libraries/Include/Lib/trig.h rename to Core/Libraries/Include/Lib/trig.h diff --git a/Generals/Code/CMakeLists.txt b/Generals/Code/CMakeLists.txt index e52d043e441..85838bb94d6 100644 --- a/Generals/Code/CMakeLists.txt +++ b/Generals/Code/CMakeLists.txt @@ -1,20 +1,14 @@ # g stands for Generals, i stands for Interface add_library(gi_gameengine_include INTERFACE) -add_library(gi_libraries_include INTERFACE) add_library(gi_libraries_source_wwvegas INTERFACE) add_library(gi_main INTERFACE) add_library(gi_always INTERFACE) add_library(gi_always_no_pch INTERFACE) # Use this for Shared Libs with MFC AFX target_include_directories(gi_gameengine_include INTERFACE "GameEngine/Include") -target_include_directories(gi_libraries_include INTERFACE "Libraries/Include") target_include_directories(gi_libraries_source_wwvegas INTERFACE "Libraries/Source/WWVegas") target_include_directories(gi_main INTERFACE "Main") -target_sources(gi_libraries_include PRIVATE - Libraries/Include/Lib/BaseType.h - Libraries/Include/Lib/trig.h -) target_compile_definitions(gi_always INTERFACE RTS_GENERALS=1 ) @@ -25,11 +19,9 @@ target_link_libraries(gi_gameengine_include INTERFACE corei_gameengine_include ) target_link_libraries(gi_always INTERFACE - gi_libraries_include corei_always # Must stay below so headers from game are included first ) target_link_libraries(gi_always_no_pch INTERFACE - gi_libraries_include corei_always_no_pch # Must stay below so headers from game are included first ) diff --git a/Generals/Code/Libraries/Include/Lib/BaseType.h b/Generals/Code/Libraries/Include/Lib/BaseType.h deleted file mode 100644 index 274f700f76e..00000000000 --- a/Generals/Code/Libraries/Include/Lib/BaseType.h +++ /dev/null @@ -1,453 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// FILE: BaseType.h /////////////////////////////////////////////////////////// -// -// Project: RTS3 -// -// Basic types and constants -// Author: Michael S. Booth, January 1995, September 2000 -// -/////////////////////////////////////////////////////////////////////////////// - -// tell the compiler to only load this file once - -#pragma once - -#include "Lib/BaseTypeCore.h" -#include "Lib/trig.h" - -//----------------------------------------------------------------------------- -typedef wchar_t WideChar; ///< multi-byte character representations - -//----------------------------------------------------------------------------- -template -inline NUM sqr(NUM x) -{ - return x*x; -} - -template -inline NUM clamp(NUM lo, NUM val, NUM hi) -{ - if (val < lo) return lo; - else if (val > hi) return hi; - else return val; -} - -template -inline int sign(NUM x) -{ - if (x > 0) return 1; - else if (x < 0) return -1; - else return 0; -} - -//----------------------------------------------------------------------------- -inline Real rad2deg(Real rad) { return rad * (180/PI); } -inline Real deg2rad(Real rad) { return rad * (PI/180); } - -//----------------------------------------------------------------------------- -// For twiddling bits -//----------------------------------------------------------------------------- -// TheSuperHackers @build xezon 17/03/2025 Renames BitTest to BitIsSet to prevent conflict with BitTest macro from winnt.h -#define BitIsSet( x, i ) ( ( (x) & (i) ) != 0 ) -#define BitSet( x, i ) ( (x) |= (i) ) -#define BitClear( x, i ) ( (x ) &= ~(i) ) -#define BitToggle( x, i ) ( (x) ^= (i) ) - -//------------------------------------------------------------------------------------------------- - -// note, this function depends on the cpu rounding mode, which we set to CHOP every frame, -// but apparently tends to be left in unpredictable modes by various system bits of -// code, so use this function with caution -- it might not round in the way you want. -__forceinline long fast_float2long_round(float f) -{ - long i; - -#if defined(_MSC_VER) && _MSC_VER < 1300 - __asm { - fld [f] - fistp [i] - } -#else - i = lroundf(f); -#endif - - return i; -} - -// super fast float trunc routine, works always (independent of any FPU modes) -// code courtesy of Martin Hoffesommer (grin) -__forceinline float fast_float_trunc(float f) -{ -#if defined(_MSC_VER) && _MSC_VER < 1300 - _asm - { - mov ecx,[f] - shr ecx,23 - mov eax,0xff800000 - xor ebx,ebx - sub cl,127 - cmovc eax,ebx - sar eax,cl - and [f],eax - } - return f; -#else - unsigned x = *(unsigned *)&f; - unsigned char exp = x >> 23; - int mask = exp < 127 ? 0 : 0xff800000; - exp -= 127; - mask >>= exp & 31; - x &= mask; - return *(float *)&x; -#endif -} - -// same here, fast floor function -__forceinline float fast_float_floor(float f) -{ - static unsigned almost1=(126<<23)|0x7fffff; - if (*(unsigned *)&f &0x80000000) - f-=*(float *)&almost1; - return fast_float_trunc(f); -} - -// same here, fast ceil function -__forceinline float fast_float_ceil(float f) -{ - static unsigned almost1=(126<<23)|0x7fffff; - if ( (*(unsigned *)&f &0x80000000)==0) - f+=*(float *)&almost1; - return fast_float_trunc(f); -} - -//------------------------------------------------------------------------------------------------- -#define REAL_TO_INT(x) ((Int)(x)) -#define REAL_TO_UNSIGNEDINT(x) ((UnsignedInt)(x)) -#define REAL_TO_SHORT(x) ((Short)(x)) -#define REAL_TO_UNSIGNEDSHORT(x) ((UnsignedShort)(x)) -#define REAL_TO_BYTE(x) ((Byte)(x)) -#define REAL_TO_UNSIGNEDBYTE(x) ((UnsignedByte)(x)) -#define REAL_TO_CHAR(x) ((Char)(x)) -#define DOUBLE_TO_REAL(x) ((Real)(x)) -#define DOUBLE_TO_INT(x) ((Int)(x)) -#define INT_TO_REAL(x) ((Real)(x)) - -// once we've ceiled/floored, trunc and round are identical, and currently, round is faster... (srj) -#if RTS_GENERALS /*&& RETAIL_COMPATIBLE_CRC*/ -#define REAL_TO_INT_CEIL(x) (fast_float2long_round(ceilf(x))) -#define REAL_TO_INT_FLOOR(x) (fast_float2long_round(floorf(x))) -#else -#define REAL_TO_INT_CEIL(x) (fast_float2long_round(fast_float_ceil(x))) -#define REAL_TO_INT_FLOOR(x) (fast_float2long_round(fast_float_floor(x))) -#endif - -#define FAST_REAL_TRUNC(x) fast_float_trunc(x) -#define FAST_REAL_CEIL(x) fast_float_ceil(x) -#define FAST_REAL_FLOOR(x) fast_float_floor(x) - -//-------------------------------------------------------------------- -// Derived type definitions -//-------------------------------------------------------------------- - -// NOTE: Keep these derived types simple, and avoid constructors and destructors -// so they can be used within unions. - -// real-valued range defined by low and high values -struct RealRange -{ - Real lo, hi; // low and high values of the range - - // combine the given range with us such that we now encompass - // both ranges - void combine( RealRange &other ) - { - lo = MIN( lo, other.lo ); - hi = MAX( hi, other.hi ); - } -}; - -struct Coord2D -{ - Real x, y; - - Real length( void ) const { return (Real)sqrt( x*x + y*y ); } - - void normalize( void ) - { - Real len = length(); - if( len != 0 ) - { - x /= len; - y /= len; - } - } - - Real toAngle( void ) const; ///< turn 2D vector into angle (where angle 0 is down the +x axis) - -}; - -inline Real Coord2D::toAngle( void ) const -{ -#if RTS_GENERALS /*&& RETAIL_COMPATIBLE_CRC*/ - Coord2D vector; - - vector.x = x; - vector.y = y; - - Real dist = (Real)sqrt(vector.x * vector.x + vector.y * vector.y); - - // normalize - if (dist == 0.0f) - return 0.0f; - - Coord2D dir; - dir.x = 1.0f; - dir.y = 0.0f; - - Real distInv = 1.0f / dist; - vector.x *= distInv; - vector.y *= distInv; - - // dot of two unit vectors is cos of angle - Real c = dir.x*vector.x + dir.y*vector.y; - - // bound it in case of numerical error - if (c < -1.0) - c = -1.0; - else if (c > 1.0) - c = 1.0; - - Real value = (Real)ACos( (Real)c ); - - // Determine sign by checking Z component of dir cross vector - // Note this is assumes 2D, and is identical to dotting the perpendicular of v with dir - Real perpZ = dir.x * vector.y - dir.y * vector.x; - if (perpZ < 0.0f) - value = -value; - - // note: to make this 3D, 'dir' and 'vector' can be normalized and dotted just as they are - // to test sign, compute N = dir X vector, then P = N x dir, then S = P . vector, where sign of - // S is sign of angle - MSB - - return value; -#else - const Real len = length(); - if (len == 0.0f) - return 0.0f; - - Real c = x/len; - // bound it in case of numerical error - if (c < -1.0f) - c = -1.0f; - else if (c > 1.0f) - c = 1.0f; - - return y < 0.0f ? -ACos(c) : ACos(c); -#endif -} - -struct ICoord2D -{ - Int x, y; - - Int length( void ) const { return (Int)sqrt( (double)(x*x + y*y) ); } -}; - -struct Region2D -{ - Coord2D lo, hi; // bounds of 2D rectangular region - - Real width( void ) const { return hi.x - lo.x; } - Real height( void ) const { return hi.y - lo.y; } -}; - -struct IRegion2D -{ - ICoord2D lo, hi; // bounds of 2D rectangular region - - Int width( void ) const { return hi.x - lo.x; } - Int height( void ) const { return hi.y - lo.y; } -}; - - -struct Coord3D -{ - Real x, y, z; - - Real length( void ) const { return (Real)sqrt( x*x + y*y + z*z ); } - Real lengthSqr( void ) const { return ( x*x + y*y + z*z ); } - - void normalize( void ) - { - Real len = length(); - - if( len != 0 ) - { - x /= len; - y /= len; - z /= len; - } - } - - static void crossProduct( const Coord3D *a, const Coord3D *b, Coord3D *r ) - { - r->x = (a->y * b->z - a->z * b->y); - r->y = (a->z * b->x - a->x * b->z); - r->z = (a->x * b->y - a->y * b->x); - } - - void zero( void ) - { - x = 0.0f; - y = 0.0f; - z = 0.0f; - } - - void add( const Coord3D *a ) - { - x += a->x; - y += a->y; - z += a->z; - } - - void sub( const Coord3D *a ) - { - x -= a->x; - y -= a->y; - z -= a->z; - } - - void set( const Coord3D *a ) - { - x = a->x; - y = a->y; - z = a->z; - } - - void set( Real ax, Real ay, Real az ) - { - x = ax; - y = ay; - z = az; - } - - void scale( Real scale ) - { - x *= scale; - y *= scale; - z *= scale; - } - - Bool equals( const Coord3D &r ) - { - return (x == r.x && - y == r.y && - z == r.z); - } - - Bool operator==( const Coord3D &r ) const - { - return (x == r.x && - y == r.y && - z == r.z); - } -}; - -struct ICoord3D -{ - Int x, y, z; - - Int length( void ) const { return (Int)sqrt( (double)(x*x + y*y + z*z) ); } - void zero( void ) - { - - x = 0; - y = 0; - z = 0; - } -}; - -struct Region3D -{ - Coord3D lo, hi; // axis-aligned bounding box - - Real width( void ) const { return hi.x - lo.x; } - Real height( void ) const { return hi.y - lo.y; } - Real depth( void ) const { return hi.z - lo.z; } - - void zero() { lo.zero(); hi.zero(); } - Bool isInRegionNoZ( const Coord3D *query ) const - { - return (lo.x < query->x) && (query->x < hi.x) - && (lo.y < query->y) && (query->y < hi.y); - } - Bool isInRegionWithZ( const Coord3D *query ) const - { - return (lo.x < query->x) && (query->x < hi.x) - && (lo.y < query->y) && (query->y < hi.y) - && (lo.z < query->z) && (query->z < hi.z); - } -}; - -struct IRegion3D -{ - ICoord3D lo, hi; // axis-aligned bounding box - - Int width( void ) const { return hi.x - lo.x; } - Int height( void ) const { return hi.y - lo.y; } - Int depth( void ) const { return hi.z - lo.z; } -}; - - -struct RGBColor -{ - Real red, green, blue; // range between 0 and 1 - - Int getAsInt() const - { - return - ((Int)(red * 255.0) << 16) | - ((Int)(green * 255.0) << 8) | - ((Int)(blue * 255.0) << 0); - } - - void setFromInt(Int c) - { - red = ((c >> 16) & 0xff) / 255.0f; - green = ((c >> 8) & 0xff) / 255.0f; - blue = ((c >> 0) & 0xff) / 255.0f; - } - -}; - -struct RGBAColorReal -{ - - Real red, green, blue, alpha; // range between 0.0 and 1.0 - -}; - -struct RGBAColorInt -{ - - UnsignedInt red, green, blue, alpha; // range between 0 and 255 - -}; diff --git a/Generals/Code/Libraries/Include/Lib/trig.h b/Generals/Code/Libraries/Include/Lib/trig.h deleted file mode 100644 index 569f1ff3496..00000000000 --- a/Generals/Code/Libraries/Include/Lib/trig.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// Trig.h -// fast trig functions -// Author: Sondra Iverson, March 1998 -// Converted to Generals by Matthew D. Campbell, February 2002 - -#pragma once - -Real Sin(Real); -Real Cos(Real); -Real Tan(Real); -Real ACos(Real); -Real ASin(Real x); diff --git a/GeneralsMD/Code/CMakeLists.txt b/GeneralsMD/Code/CMakeLists.txt index d173801dc98..a713dcc7c2b 100644 --- a/GeneralsMD/Code/CMakeLists.txt +++ b/GeneralsMD/Code/CMakeLists.txt @@ -1,20 +1,14 @@ # z stands for Zero Hour, i stands for Interface add_library(zi_gameengine_include INTERFACE) -add_library(zi_libraries_include INTERFACE) add_library(zi_libraries_source_wwvegas INTERFACE) add_library(zi_main INTERFACE) add_library(zi_always INTERFACE) add_library(zi_always_no_pch INTERFACE) # Use this for Shared Libs with MFC AFX target_include_directories(zi_gameengine_include INTERFACE "GameEngine/Include") -target_include_directories(zi_libraries_include INTERFACE "Libraries/Include") target_include_directories(zi_libraries_source_wwvegas INTERFACE "Libraries/Source/WWVegas") target_include_directories(zi_main INTERFACE "Main") -target_sources(zi_libraries_include PRIVATE - Libraries/Include/Lib/BaseType.h - Libraries/Include/Lib/trig.h -) target_compile_definitions(zi_always INTERFACE RTS_ZEROHOUR=1 ) @@ -25,11 +19,9 @@ target_link_libraries(zi_gameengine_include INTERFACE corei_gameengine_include ) target_link_libraries(zi_always INTERFACE - zi_libraries_include corei_always # Must stay below so headers from game are included first ) target_link_libraries(zi_always_no_pch INTERFACE - zi_libraries_include corei_always_no_pch # Must stay below so headers from game are included first ) diff --git a/scripts/cpp/unify_move_files.py b/scripts/cpp/unify_move_files.py index 3430d4b450f..f0845dd95f3 100644 --- a/scripts/cpp/unify_move_files.py +++ b/scripts/cpp/unify_move_files.py @@ -260,6 +260,9 @@ def main(): #unify_file(Game.ZEROHOUR, "GameEngine/Include/Common/UserPreferences.h", Game.CORE, "GameEngine/Include/Common/UserPreferences.h") #unify_file(Game.ZEROHOUR, "GameEngine/Source/Common/UserPreferences.cpp", Game.CORE, "GameEngine/Source/Common/UserPreferences.cpp") + #unify_file(Game.ZEROHOUR, "Libraries/Include/Lib/BaseType.h", Game.CORE, "Libraries/Include/Lib/BaseType.h") + #unify_file(Game.ZEROHOUR, "Libraries/Include/Lib/trig.h", Game.CORE, "Libraries/Include/Lib/trig.h") + return From 8fd7226419e37b6a7efeac05510430d4da2ccd39 Mon Sep 17 00:00:00 2001 From: xezon <4720891+xezon@users.noreply.github.com> Date: Sun, 25 Jan 2026 11:27:47 +0100 Subject: [PATCH 2/2] unify(common): Move common system files to Core needed for ParticleEditor (#2185) --- Core/GameEngine/CMakeLists.txt | 28 +- .../GameEngine/Include/Common/Errors.h | 0 .../GameEngine/Include/Common/GameCommon.h | 0 .../GameEngine/Include/Common/GameType.h | 0 .../GameEngine/Include/Common/INI.h | 0 .../GameEngine/Include/Common/STLTypedefs.h | 0 .../GameEngine/Include/Common/Snapshot.h | 0 .../Include/Common/SubsystemInterface.h | 0 .../Include/GameClient/ChallengeGenerals.h | 0 .../GameEngine/Source/Common/INI/INI.cpp | 0 .../Source/Common/System/GameCommon.cpp | 0 .../Source/Common/System/GameType.cpp | 0 .../Source/Common/System/Snapshot.cpp | 0 .../Common/System/SubsystemInterface.cpp | 0 .../GameClient/GUI/ChallengeGenerals.cpp | 0 Generals/Code/GameEngine/CMakeLists.txt | 28 +- .../Code/GameEngine/Include/Common/Errors.h | 67 - .../GameEngine/Include/Common/GameCommon.h | 505 ----- .../Code/GameEngine/Include/Common/GameType.h | 191 -- Generals/Code/GameEngine/Include/Common/INI.h | 415 ---- .../GameEngine/Include/Common/STLTypedefs.h | 297 --- .../Code/GameEngine/Include/Common/Snapshot.h | 67 - .../Include/Common/SubsystemInterface.h | 168 -- .../GameEngine/Include/Common/ThingSort.h | 2 +- .../Include/GameClient/ChallengeGenerals.h | 155 -- .../Code/GameEngine/Source/Common/INI/INI.cpp | 2000 ----------------- .../Source/Common/System/GameCommon.cpp | 69 - .../Source/Common/System/GameType.cpp | 48 - .../Source/Common/System/Snapshot.cpp | 56 - .../Common/System/SubsystemInterface.cpp | 236 -- GeneralsMD/Code/GameEngine/CMakeLists.txt | 28 +- .../GameEngine/Include/Common/ThingSort.h | 2 +- .../GameClient/GUI/ChallengeGenerals.cpp | 160 -- scripts/cpp/unify_move_files.py | 14 + 34 files changed, 58 insertions(+), 4478 deletions(-) rename {GeneralsMD/Code => Core}/GameEngine/Include/Common/Errors.h (100%) rename {GeneralsMD/Code => Core}/GameEngine/Include/Common/GameCommon.h (100%) rename {GeneralsMD/Code => Core}/GameEngine/Include/Common/GameType.h (100%) rename {GeneralsMD/Code => Core}/GameEngine/Include/Common/INI.h (100%) rename {GeneralsMD/Code => Core}/GameEngine/Include/Common/STLTypedefs.h (100%) rename {GeneralsMD/Code => Core}/GameEngine/Include/Common/Snapshot.h (100%) rename {GeneralsMD/Code => Core}/GameEngine/Include/Common/SubsystemInterface.h (100%) rename {GeneralsMD/Code => Core}/GameEngine/Include/GameClient/ChallengeGenerals.h (100%) rename {GeneralsMD/Code => Core}/GameEngine/Source/Common/INI/INI.cpp (100%) rename {GeneralsMD/Code => Core}/GameEngine/Source/Common/System/GameCommon.cpp (100%) rename {GeneralsMD/Code => Core}/GameEngine/Source/Common/System/GameType.cpp (100%) rename {GeneralsMD/Code => Core}/GameEngine/Source/Common/System/Snapshot.cpp (100%) rename {GeneralsMD/Code => Core}/GameEngine/Source/Common/System/SubsystemInterface.cpp (100%) rename {Generals/Code => Core}/GameEngine/Source/GameClient/GUI/ChallengeGenerals.cpp (100%) delete mode 100644 Generals/Code/GameEngine/Include/Common/Errors.h delete mode 100644 Generals/Code/GameEngine/Include/Common/GameCommon.h delete mode 100644 Generals/Code/GameEngine/Include/Common/GameType.h delete mode 100644 Generals/Code/GameEngine/Include/Common/INI.h delete mode 100644 Generals/Code/GameEngine/Include/Common/STLTypedefs.h delete mode 100644 Generals/Code/GameEngine/Include/Common/Snapshot.h delete mode 100644 Generals/Code/GameEngine/Include/Common/SubsystemInterface.h delete mode 100644 Generals/Code/GameEngine/Include/GameClient/ChallengeGenerals.h delete mode 100644 Generals/Code/GameEngine/Source/Common/INI/INI.cpp delete mode 100644 Generals/Code/GameEngine/Source/Common/System/GameCommon.cpp delete mode 100644 Generals/Code/GameEngine/Source/Common/System/GameType.cpp delete mode 100644 Generals/Code/GameEngine/Source/Common/System/Snapshot.cpp delete mode 100644 Generals/Code/GameEngine/Source/Common/System/SubsystemInterface.cpp delete mode 100644 GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ChallengeGenerals.cpp diff --git a/Core/GameEngine/CMakeLists.txt b/Core/GameEngine/CMakeLists.txt index 13fa1158a01..50636fc397f 100644 --- a/Core/GameEngine/CMakeLists.txt +++ b/Core/GameEngine/CMakeLists.txt @@ -37,14 +37,14 @@ set(GAMEENGINE_SRC Include/Common/DynamicAudioEventInfo.h # Include/Common/encrypt.h # Include/Common/Energy.h -# Include/Common/Errors.h + Include/Common/Errors.h Include/Common/file.h Include/Common/FileSystem.h Include/Common/FramePacer.h Include/Common/FrameRateLimit.h # Include/Common/FunctionLexicon.h Include/Common/GameAudio.h -# Include/Common/GameCommon.h + Include/Common/GameCommon.h Include/Common/GameDefines.h # Include/Common/GameEngine.h # Include/Common/GameLOD.h @@ -54,13 +54,13 @@ set(GAMEENGINE_SRC # Include/Common/GameSpyMiscPreferences.h # Include/Common/GameState.h # Include/Common/GameStateMap.h -# Include/Common/GameType.h + Include/Common/GameType.h Include/Common/GameUtility.h # Include/Common/Geometry.h # Include/Common/GlobalData.h # Include/Common/Handicap.h # Include/Common/IgnorePreferences.h -# Include/Common/INI.h + Include/Common/INI.h # Include/Common/INIException.h # Include/Common/KindOf.h # Include/Common/LadderPreferences.h @@ -108,7 +108,7 @@ set(GAMEENGINE_SRC #Include/Common/simpleplayer.h # unused # Include/Common/SkirmishBattleHonors.h # Include/Common/SkirmishPreferences.h -# Include/Common/Snapshot.h + Include/Common/Snapshot.h # Include/Common/SparseMatchFinder.h # Include/Common/SpecialPower.h # Include/Common/SpecialPowerMaskType.h @@ -116,9 +116,9 @@ set(GAMEENGINE_SRC # Include/Common/StackDump.h # Include/Common/StateMachine.h # Include/Common/StatsCollector.h -# Include/Common/STLTypedefs.h + Include/Common/STLTypedefs.h Include/Common/StreamingArchiveFile.h -# Include/Common/SubsystemInterface.h + Include/Common/SubsystemInterface.h # Include/Common/SystemInfo.h # Include/Common/Team.h # Include/Common/Terrain.h @@ -145,7 +145,7 @@ set(GAMEENGINE_SRC # Include/GameClient/AnimateWindowManager.h # Include/GameClient/CampaignManager.h # Include/GameClient/CDCheck.h -# Include/GameClient/ChallengeGenerals.h + Include/GameClient/ChallengeGenerals.h # Include/GameClient/ClientInstance.h Include/GameClient/ClientRandomValue.h # Include/GameClient/Color.h @@ -582,7 +582,7 @@ set(GAMEENGINE_SRC # Source/Common/GameMain.cpp Source/Common/GameUtility.cpp # Source/Common/GlobalData.cpp -# Source/Common/INI/INI.cpp + Source/Common/INI/INI.cpp # Source/Common/INI/INIAiData.cpp # Source/Common/INI/INIAnimation.cpp Source/Common/INI/INIAudioEventInfo.cpp @@ -653,10 +653,10 @@ set(GAMEENGINE_SRC Source/Common/System/File.cpp Source/Common/System/FileSystem.cpp # Source/Common/System/FunctionLexicon.cpp -# Source/Common/System/GameCommon.cpp + Source/Common/System/GameCommon.cpp #Source/Common/System/GameMemory.cpp # is conditionally appended #Source/Common/System/GameMemoryInit.cpp # is conditionally appended -# Source/Common/System/GameType.cpp + Source/Common/System/GameType.cpp # Source/Common/System/Geometry.cpp # Source/Common/System/KindOf.cpp # Source/Common/System/List.cpp @@ -670,10 +670,10 @@ set(GAMEENGINE_SRC # Source/Common/System/registry.cpp # Source/Common/System/SaveGame/GameState.cpp # Source/Common/System/SaveGame/GameStateMap.cpp -# Source/Common/System/Snapshot.cpp + Source/Common/System/Snapshot.cpp # Source/Common/System/StackDump.cpp Source/Common/System/StreamingArchiveFile.cpp -# Source/Common/System/SubsystemInterface.cpp + Source/Common/System/SubsystemInterface.cpp # Source/Common/System/Trig.cpp Source/Common/System/UnicodeString.cpp # Source/Common/System/Upgrade.cpp @@ -710,7 +710,7 @@ set(GAMEENGINE_SRC # Source/GameClient/GlobalLanguage.cpp # Source/GameClient/GraphDraw.cpp # Source/GameClient/GUI/AnimateWindowManager.cpp -# Source/GameClient/GUI/ChallengeGenerals.cpp + Source/GameClient/GUI/ChallengeGenerals.cpp # Source/GameClient/GUI/ControlBar/ControlBar.cpp # Source/GameClient/GUI/ControlBar/ControlBarBeacon.cpp # Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp diff --git a/GeneralsMD/Code/GameEngine/Include/Common/Errors.h b/Core/GameEngine/Include/Common/Errors.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/Common/Errors.h rename to Core/GameEngine/Include/Common/Errors.h diff --git a/GeneralsMD/Code/GameEngine/Include/Common/GameCommon.h b/Core/GameEngine/Include/Common/GameCommon.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/Common/GameCommon.h rename to Core/GameEngine/Include/Common/GameCommon.h diff --git a/GeneralsMD/Code/GameEngine/Include/Common/GameType.h b/Core/GameEngine/Include/Common/GameType.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/Common/GameType.h rename to Core/GameEngine/Include/Common/GameType.h diff --git a/GeneralsMD/Code/GameEngine/Include/Common/INI.h b/Core/GameEngine/Include/Common/INI.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/Common/INI.h rename to Core/GameEngine/Include/Common/INI.h diff --git a/GeneralsMD/Code/GameEngine/Include/Common/STLTypedefs.h b/Core/GameEngine/Include/Common/STLTypedefs.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/Common/STLTypedefs.h rename to Core/GameEngine/Include/Common/STLTypedefs.h diff --git a/GeneralsMD/Code/GameEngine/Include/Common/Snapshot.h b/Core/GameEngine/Include/Common/Snapshot.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/Common/Snapshot.h rename to Core/GameEngine/Include/Common/Snapshot.h diff --git a/GeneralsMD/Code/GameEngine/Include/Common/SubsystemInterface.h b/Core/GameEngine/Include/Common/SubsystemInterface.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/Common/SubsystemInterface.h rename to Core/GameEngine/Include/Common/SubsystemInterface.h diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ChallengeGenerals.h b/Core/GameEngine/Include/GameClient/ChallengeGenerals.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/GameClient/ChallengeGenerals.h rename to Core/GameEngine/Include/GameClient/ChallengeGenerals.h diff --git a/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp b/Core/GameEngine/Source/Common/INI/INI.cpp similarity index 100% rename from GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp rename to Core/GameEngine/Source/Common/INI/INI.cpp diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/GameCommon.cpp b/Core/GameEngine/Source/Common/System/GameCommon.cpp similarity index 100% rename from GeneralsMD/Code/GameEngine/Source/Common/System/GameCommon.cpp rename to Core/GameEngine/Source/Common/System/GameCommon.cpp diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/GameType.cpp b/Core/GameEngine/Source/Common/System/GameType.cpp similarity index 100% rename from GeneralsMD/Code/GameEngine/Source/Common/System/GameType.cpp rename to Core/GameEngine/Source/Common/System/GameType.cpp diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/Snapshot.cpp b/Core/GameEngine/Source/Common/System/Snapshot.cpp similarity index 100% rename from GeneralsMD/Code/GameEngine/Source/Common/System/Snapshot.cpp rename to Core/GameEngine/Source/Common/System/Snapshot.cpp diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/SubsystemInterface.cpp b/Core/GameEngine/Source/Common/System/SubsystemInterface.cpp similarity index 100% rename from GeneralsMD/Code/GameEngine/Source/Common/System/SubsystemInterface.cpp rename to Core/GameEngine/Source/Common/System/SubsystemInterface.cpp diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/ChallengeGenerals.cpp b/Core/GameEngine/Source/GameClient/GUI/ChallengeGenerals.cpp similarity index 100% rename from Generals/Code/GameEngine/Source/GameClient/GUI/ChallengeGenerals.cpp rename to Core/GameEngine/Source/GameClient/GUI/ChallengeGenerals.cpp diff --git a/Generals/Code/GameEngine/CMakeLists.txt b/Generals/Code/GameEngine/CMakeLists.txt index f4ef0c45917..217d7dcecba 100644 --- a/Generals/Code/GameEngine/CMakeLists.txt +++ b/Generals/Code/GameEngine/CMakeLists.txt @@ -33,12 +33,12 @@ set(GAMEENGINE_SRC Include/Common/DrawModule.h Include/Common/encrypt.h Include/Common/Energy.h - Include/Common/Errors.h +# Include/Common/Errors.h # Include/Common/file.h # Include/Common/FileSystem.h Include/Common/FunctionLexicon.h # Include/Common/GameAudio.h - Include/Common/GameCommon.h +# Include/Common/GameCommon.h # Include/Common/GameDefines.h Include/Common/GameEngine.h Include/Common/GameLOD.h @@ -48,12 +48,12 @@ set(GAMEENGINE_SRC Include/Common/GameSpyMiscPreferences.h Include/Common/GameState.h Include/Common/GameStateMap.h - Include/Common/GameType.h +# Include/Common/GameType.h Include/Common/Geometry.h Include/Common/GlobalData.h Include/Common/Handicap.h Include/Common/IgnorePreferences.h - Include/Common/INI.h +# Include/Common/INI.h Include/Common/INIException.h Include/Common/KindOf.h Include/Common/LadderPreferences.h @@ -98,7 +98,7 @@ set(GAMEENGINE_SRC Include/Common/ScoreKeeper.h Include/Common/SkirmishBattleHonors.h Include/Common/SkirmishPreferences.h - Include/Common/Snapshot.h +# Include/Common/Snapshot.h Include/Common/SparseMatchFinder.h Include/Common/SpecialPower.h Include/Common/SpecialPowerMaskType.h @@ -106,9 +106,9 @@ set(GAMEENGINE_SRC Include/Common/StackDump.h Include/Common/StateMachine.h Include/Common/StatsCollector.h - Include/Common/STLTypedefs.h +# Include/Common/STLTypedefs.h # Include/Common/StreamingArchiveFile.h - Include/Common/SubsystemInterface.h +# Include/Common/SubsystemInterface.h Include/Common/SystemInfo.h Include/Common/Team.h Include/Common/Terrain.h @@ -132,7 +132,7 @@ set(GAMEENGINE_SRC # Include/Common/XferSave.h Include/GameClient/Anim2D.h Include/GameClient/AnimateWindowManager.h - Include/GameClient/ChallengeGenerals.h +# Include/GameClient/ChallengeGenerals.h Include/GameClient/CampaignManager.h Include/GameClient/CDCheck.h Include/GameClient/ClientInstance.h @@ -533,7 +533,7 @@ set(GAMEENGINE_SRC Source/Common/GameLOD.cpp Source/Common/GameMain.cpp Source/Common/GlobalData.cpp - Source/Common/INI/INI.cpp +# Source/Common/INI/INI.cpp Source/Common/INI/INIAiData.cpp Source/Common/INI/INIAnimation.cpp # Source/Common/INI/INIAudioEventInfo.cpp @@ -602,9 +602,9 @@ set(GAMEENGINE_SRC # Source/Common/System/File.cpp # Source/Common/System/FileSystem.cpp Source/Common/System/FunctionLexicon.cpp - Source/Common/System/GameCommon.cpp +# Source/Common/System/GameCommon.cpp #Source/Common/System/GameMemory.cpp - Source/Common/System/GameType.cpp +# Source/Common/System/GameType.cpp Source/Common/System/Geometry.cpp Source/Common/System/KindOf.cpp Source/Common/System/List.cpp @@ -618,10 +618,10 @@ set(GAMEENGINE_SRC Source/Common/System/registry.cpp Source/Common/System/SaveGame/GameState.cpp Source/Common/System/SaveGame/GameStateMap.cpp - Source/Common/System/Snapshot.cpp +# Source/Common/System/Snapshot.cpp Source/Common/System/StackDump.cpp # Source/Common/System/StreamingArchiveFile.cpp - Source/Common/System/SubsystemInterface.cpp +# Source/Common/System/SubsystemInterface.cpp Source/Common/System/Trig.cpp # Source/Common/System/UnicodeString.cpp Source/Common/System/Upgrade.cpp @@ -658,7 +658,7 @@ set(GAMEENGINE_SRC Source/GameClient/GlobalLanguage.cpp Source/GameClient/GraphDraw.cpp Source/GameClient/GUI/AnimateWindowManager.cpp - Source/GameClient/GUI/ChallengeGenerals.cpp +# Source/GameClient/GUI/ChallengeGenerals.cpp Source/GameClient/GUI/ControlBar/ControlBar.cpp Source/GameClient/GUI/ControlBar/ControlBarBeacon.cpp Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp diff --git a/Generals/Code/GameEngine/Include/Common/Errors.h b/Generals/Code/GameEngine/Include/Common/Errors.h deleted file mode 100644 index 2c2cec27c6c..00000000000 --- a/Generals/Code/GameEngine/Include/Common/Errors.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: Errors.h -//----------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright (C) 2001 - All Rights Reserved -// -//----------------------------------------------------------------------------- -// -// Project: RTS3 -// -// File name: Errors.h -// -// Created: Steven Johnson, August 2001 -// -// Desc: Error codes -// -//----------------------------------------------------------------------------- -/////////////////////////////////////////////////////////////////////////////// - -#pragma once - -/** - An ErrorCode is the repository for failure modes. In almost all situations, - these values will be THROWN, not returned as error codes. Feel free - to add to this list as necessary; however, there should generally be very - few codes needed. -*/ -enum ErrorCode CPP_11(: UnsignedInt) -{ - ERROR_BASE = 0xdead0001, // a nice, distinctive value - - ERROR_BUG = (ERROR_BASE + 0x0000), ///< should not be possible under normal operation - ERROR_OUT_OF_MEMORY = (ERROR_BASE + 0x0001), ///< unable to allocate memory. - ERROR_BAD_ARG = (ERROR_BASE + 0x0002), ///< generic "bad argument". - ERROR_INVALID_FILE_VERSION = (ERROR_BASE + 0x0003), ///< Unrecognized file version. - ERROR_CORRUPT_FILE_FORMAT = (ERROR_BASE + 0x0004), ///< Invalid file format. - ERROR_BAD_INI = (ERROR_BASE + 0x0005), ///< Bad INI data. - ERROR_INVALID_D3D = (ERROR_BASE + 0x0006), ///< Error initing D3D - - ERROR_LAST -}; diff --git a/Generals/Code/GameEngine/Include/Common/GameCommon.h b/Generals/Code/GameEngine/Include/Common/GameCommon.h deleted file mode 100644 index 34e26d9b065..00000000000 --- a/Generals/Code/GameEngine/Include/Common/GameCommon.h +++ /dev/null @@ -1,505 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: GameCommon.h //////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright (C) 2001 - All Rights Reserved -// -//----------------------------------------------------------------------------- -// -// Project: RTS3 -// -// File name: GameCommon.h -// -// Created: Steven Johnson, October 2001 -// -// Desc: This is a catchall header for some basic types and definitions -// needed by various bits of the GameLogic/GameClient, but that -// we haven't found a good place for yet. Hopefully this file -// should go away someday, but for now is a convenient spot. -// -//----------------------------------------------------------------------------- - -#pragma once - -#define DONT_ALLOW_DEBUG_CHEATS_IN_RELEASE ///< Take of the DONT to get cheats back in to release - -//#define _CAMPEA_DEMO - -// ---------------------------------------------------------------------------------------------- -#include "Lib/BaseType.h" -#include "WWCommon.h" -#include "Common/GameDefines.h" - -// ---------------------------------------------------------------------------------------------- -#if defined(RTS_DEBUG) - #define DUMP_PERF_STATS -#else - #define NO_DUMP_PERF_STATS -#endif - -// ---------------------------------------------------------------------------------------------- -enum -{ - BaseFps = 30, // The historic base frame rate for this game. This value must never change. - LOGICFRAMES_PER_SECOND = WWSyncPerSecond, - MSEC_PER_SECOND = 1000 -}; -const Real LOGICFRAMES_PER_MSEC_REAL = (((Real)LOGICFRAMES_PER_SECOND) / ((Real)MSEC_PER_SECOND)); -const Real MSEC_PER_LOGICFRAME_REAL = (((Real)MSEC_PER_SECOND) / ((Real)LOGICFRAMES_PER_SECOND)); -const Real LOGICFRAMES_PER_SECONDS_REAL = (Real)LOGICFRAMES_PER_SECOND; -const Real SECONDS_PER_LOGICFRAME_REAL = 1.0f / LOGICFRAMES_PER_SECONDS_REAL; - -// ---------------------------------------------------------------------------------------------- -// note that this returns a REAL value, not an int... most callers will want to -// call ceil() on the result, so that partial frames get converted to full frames! -inline Real ConvertDurationFromMsecsToFrames(Real msec) -{ - return (msec * LOGICFRAMES_PER_MSEC_REAL); -} - -// ---------------------------------------------------------------------------------------------- -inline Real ConvertVelocityInSecsToFrames(Real distPerMsec) -{ - // this looks wrong, but is the correct conversion factor. - return (distPerMsec * SECONDS_PER_LOGICFRAME_REAL); -} - -// ---------------------------------------------------------------------------------------------- -inline Real ConvertAccelerationInSecsToFrames(Real distPerSec2) -{ - // this looks wrong, but is the correct conversion factor. - const Real SEC_PER_LOGICFRAME_SQR = (SECONDS_PER_LOGICFRAME_REAL * SECONDS_PER_LOGICFRAME_REAL); - return (distPerSec2 * SEC_PER_LOGICFRAME_SQR); -} - -// ---------------------------------------------------------------------------------------------- -inline Real ConvertAngularVelocityInDegreesPerSecToRadsPerFrame(Real degPerSec) -{ - const Real RADS_PER_DEGREE = PI / 180.0f; - return (degPerSec * (SECONDS_PER_LOGICFRAME_REAL * RADS_PER_DEGREE)); -} - -// ---------------------------------------------------------------------------------------------- -enum -{ - MAX_PLAYER_COUNT = 16 ///< max number of Players. -}; - -// ---------------------------------------------------------------------------------------------- -/** - a bitmask that can uniquely represent each player. -*/ -#if MAX_PLAYER_COUNT <= 16 - typedef UnsignedShort PlayerMaskType; - const PlayerMaskType PLAYERMASK_ALL = 0xffff; - const PlayerMaskType PLAYERMASK_NONE = 0x0; -#else - #error "this is the wrong size" -#endif - -// ---------------------------------------------------------------------------------------------- -enum -{ - MAX_GLOBAL_GENERAL_TYPES = 9, ///< number of playable General Types, not including the boss) - - /// The start of the playable global generals playertemplates - GLOBAL_GENERAL_BEGIN = 5, - - /// The end of the playable global generals - GLOBAL_GENERAL_END = (GLOBAL_GENERAL_BEGIN + MAX_GLOBAL_GENERAL_TYPES - 1) -}; - -//------------------------------------------------------------------------------------------------- -enum GameDifficulty CPP_11(: Int) -{ - DIFFICULTY_EASY, - DIFFICULTY_NORMAL, - DIFFICULTY_HARD, - - DIFFICULTY_COUNT -}; - -//------------------------------------------------------------------------------------------------- -enum PlayerType CPP_11(: Int) -{ - PLAYER_HUMAN, ///< player is human-controlled - PLAYER_COMPUTER, ///< player is computer-controlled - - PLAYERTYPE_COUNT -}; - -//------------------------------------------------------------------------------------------------- -/// A PartitionCell can be one of three states for Shroud -enum CellShroudStatus CPP_11(: Int) -{ - CELLSHROUD_CLEAR, - CELLSHROUD_FOGGED, - CELLSHROUD_SHROUDED, -}; - -//------------------------------------------------------------------------------------------------- -/// Since an object can take up more than a single PartitionCell, this is a status that applies to the whole Object -enum ObjectShroudStatus CPP_11(: Int) -{ - OBJECTSHROUD_INVALID, ///< indeterminate state, will recompute - OBJECTSHROUD_CLEAR, ///< object is not shrouded at all (ie, completely visible) - OBJECTSHROUD_PARTIAL_CLEAR, ///< object is partly clear (rest is shroud or fog) - OBJECTSHROUD_FOGGED, ///< object is completely fogged - OBJECTSHROUD_SHROUDED, ///< object is completely shrouded - OBJECTSHROUD_INVALID_BUT_PREVIOUS_VALID, ///< indeterminate state, will recompute, BUT previous status is valid, don't reset (used for save/load) -}; - -//------------------------------------------------------------------------------------------------- -enum GuardMode CPP_11(: Int) -{ - GUARDMODE_NORMAL, - GUARDMODE_GUARD_WITHOUT_PURSUIT, // no pursuit out of guard area - GUARDMODE_GUARD_FLYING_UNITS_ONLY // ignore nonflyers -}; - -// --------------------------------------------------- -enum -{ - NEVER = 0, - FOREVER = 0x3fffffff // (we use 0x3fffffff so that we can add offsets and not overflow... - // at 30fps we're still pretty safe!) -}; - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- - -/// Veterancy level define needed by several files that don't need the full Experience code. -// NOTE NOTE NOTE: Keep TheVeterencyNames in sync with these. -enum VeterancyLevel CPP_11(: Int) -{ - LEVEL_REGULAR, - LEVEL_VETERAN, - LEVEL_ELITE, - LEVEL_HEROIC, - - LEVEL_COUNT, - LEVEL_INVALID, - - LEVEL_FIRST = 0, - LEVEL_LAST = LEVEL_HEROIC -}; - -// TheVeterancyNames is defined in GameCommon.cpp -extern const char *const TheVeterancyNames[]; - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -enum CommandSourceType CPP_11(: Int) -{ - - CMD_FROM_PLAYER = 0, - CMD_FROM_SCRIPT, - CMD_FROM_AI, - CMD_FROM_DOZER, // Special rare command when the dozer originates a command to attack a mine. Mines are not ai-attackable, and it seems deceitful for the dozer to generate a player or script command. jba. - CMD_DEFAULT_SWITCH_WEAPON, // Special case: A weapon that can be chosen -- this is the default case (machine gun vs flashbang). - - COMMAND_SOURCE_TYPE_COUNT -}; - -//------------------------------------------------------------------------------------------------- -enum AbleToAttackType CPP_11(: Int) -{ - _ATTACK_FORCED = 0x01, - _ATTACK_CONTINUED = 0x02, - _ATTACK_TUNNELNETWORK_GUARD = 0x04, - - /** - can we attack if this is a new target? - */ - ATTACK_NEW_TARGET = (0), - - /** - can we attack if this is a new target, via force-fire? - (The only current difference between this and ATTACK_NEW_TARGET is that disguised units - are force-attackable even when stealthed.) - */ - ATTACK_NEW_TARGET_FORCED= (_ATTACK_FORCED), - - /** - can we attack if this is continuation of an existing attack? - (The only current difference between this and ATTACK_NEW_TARGET is you are allowed to follow - immobile shrouded units into the fog) - */ - ATTACK_CONTINUED_TARGET = (_ATTACK_CONTINUED), - - /** - can we attack if this is continuation of an existing attack? - (The only current difference between this and ATTACK_NEW_TARGET is you are allowed to follow - immobile shrouded units into the fog) - */ - ATTACK_CONTINUED_TARGET_FORCED = (_ATTACK_FORCED | _ATTACK_CONTINUED), - - /** - Special case that bypasses some of the checks for units guarding from within tunnel networks! - For example, a unit inside couldn't normally see outside and would fail. - */ - ATTACK_TUNNEL_NETWORK_GUARD = (_ATTACK_TUNNELNETWORK_GUARD) - -}; - -//------------------------------------------------------------------------------------------------- -inline Bool isForcedAttack(AbleToAttackType t) -{ - return (((Int)t) & _ATTACK_FORCED) != 0; -} - -//------------------------------------------------------------------------------------------------- -inline Bool isContinuedAttack(AbleToAttackType t) -{ - return (((Int)t) & _ATTACK_CONTINUED) != 0; -} - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- - -typedef UnsignedInt VeterancyLevelFlags; - -const VeterancyLevelFlags VETERANCY_LEVEL_FLAGS_ALL = 0xffffffff; -const VeterancyLevelFlags VETERANCY_LEVEL_FLAGS_NONE = 0x00000000; - -inline Bool getVeterancyLevelFlag(VeterancyLevelFlags flags, VeterancyLevel dt) -{ - return (flags & (1UL << (dt - 1))) != 0; -} - -inline VeterancyLevelFlags setVeterancyLevelFlag(VeterancyLevelFlags flags, VeterancyLevel dt) -{ - return (flags | (1UL << (dt - 1))); -} - -inline VeterancyLevelFlags clearVeterancyLevelFlag(VeterancyLevelFlags flags, VeterancyLevel dt) -{ - return (flags & ~(1UL << (dt - 1))); -} - -// ---------------------------------------------------------------------------------------------- -#define BOGUSPTR(p) ((((unsigned int)(p)) & 1) != 0) - -// ---------------------------------------------------------------------------------------------- -#define MAKE_DLINK_HEAD(OBJCLASS, LISTNAME) \ -public: \ - inline DLINK_ITERATOR iterate_##LISTNAME() const \ - { \ - DEBUG_ASSERTCRASH(!BOGUSPTR(m_dlinkhead_##LISTNAME.m_head), ("bogus head ptr")); \ - return DLINK_ITERATOR(m_dlinkhead_##LISTNAME.m_head, &OBJCLASS::dlink_next_##LISTNAME); \ - } \ - inline OBJCLASS *getFirstItemIn_##LISTNAME() const \ - { \ - DEBUG_ASSERTCRASH(!BOGUSPTR(m_dlinkhead_##LISTNAME.m_head), ("bogus head ptr")); \ - return m_dlinkhead_##LISTNAME.m_head; \ - } \ - inline Bool isInList_##LISTNAME(OBJCLASS* o) const \ - { \ - DEBUG_ASSERTCRASH(!BOGUSPTR(m_dlinkhead_##LISTNAME.m_head), ("bogus head ptr")); \ - return o->dlink_isInList_##LISTNAME(&m_dlinkhead_##LISTNAME.m_head); \ - } \ - inline void prependTo_##LISTNAME(OBJCLASS* o) \ - { \ - DEBUG_ASSERTCRASH(!BOGUSPTR(m_dlinkhead_##LISTNAME.m_head), ("bogus head ptr")); \ - if (!isInList_##LISTNAME(o)) \ - o->dlink_prependTo_##LISTNAME(&m_dlinkhead_##LISTNAME.m_head); \ - } \ - inline void removeFrom_##LISTNAME(OBJCLASS* o) \ - { \ - DEBUG_ASSERTCRASH(!BOGUSPTR(m_dlinkhead_##LISTNAME.m_head), ("bogus head ptr")); \ - if (isInList_##LISTNAME(o)) \ - o->dlink_removeFrom_##LISTNAME(&m_dlinkhead_##LISTNAME.m_head); \ - } \ - typedef void (*RemoveAllProc_##LISTNAME)(OBJCLASS* o); \ - inline void removeAll_##LISTNAME(RemoveAllProc_##LISTNAME p = nullptr) \ - { \ - while (m_dlinkhead_##LISTNAME.m_head) \ - { \ - DEBUG_ASSERTCRASH(!BOGUSPTR(m_dlinkhead_##LISTNAME.m_head), ("bogus head ptr"));\ - OBJCLASS *tmp = m_dlinkhead_##LISTNAME.m_head; \ - removeFrom_##LISTNAME(tmp); \ - if (p) (*p)(tmp); \ - } \ - } \ - inline void reverse_##LISTNAME() \ - { \ - OBJCLASS* cur = m_dlinkhead_##LISTNAME.m_head; \ - OBJCLASS* prev = nullptr; \ - while (cur) \ - { \ - OBJCLASS* originalNext = cur->dlink_next_##LISTNAME(); \ - cur->dlink_swapLinks_##LISTNAME(); \ - prev = cur; \ - cur = originalNext; \ - } \ - m_dlinkhead_##LISTNAME.m_head = prev; \ - } \ -private: \ - /* a trick: init head to zero */ \ - struct DLINKHEAD_##LISTNAME \ - { \ - public: \ - OBJCLASS* m_head; \ - inline DLINKHEAD_##LISTNAME() : \ - m_head(0) { } \ - inline ~DLINKHEAD_##LISTNAME() \ - { DEBUG_ASSERTCRASH(!m_head,("destroying dlinkhead still in a list " #LISTNAME)); } \ - }; \ - DLINKHEAD_##LISTNAME m_dlinkhead_##LISTNAME; - -// ---------------------------------------------------------------------------------------------- -#define MAKE_DLINK(OBJCLASS, LISTNAME) \ -public: \ - OBJCLASS* dlink_prev_##LISTNAME() const { return m_dlink_##LISTNAME.m_prev; } \ - OBJCLASS* dlink_next_##LISTNAME() const { return m_dlink_##LISTNAME.m_next; } \ - void dlink_swapLinks_##LISTNAME() \ - { \ - OBJCLASS* originalNext = m_dlink_##LISTNAME.m_next; \ - m_dlink_##LISTNAME.m_next = m_dlink_##LISTNAME.m_prev; \ - m_dlink_##LISTNAME.m_prev = originalNext; \ - } \ - Bool dlink_isInList_##LISTNAME(OBJCLASS* const* pListHead) const \ - { \ - DEBUG_ASSERTCRASH(!BOGUSPTR(*pListHead) && !BOGUSPTR(m_dlink_##LISTNAME.m_next) && !BOGUSPTR(m_dlink_##LISTNAME.m_prev), ("bogus ptrs")); \ - return *pListHead == this || m_dlink_##LISTNAME.m_prev || m_dlink_##LISTNAME.m_next; \ - } \ - void dlink_prependTo_##LISTNAME(OBJCLASS** pListHead) \ - { \ - DEBUG_ASSERTCRASH(!dlink_isInList_##LISTNAME(pListHead), ("already in list " #LISTNAME)); \ - DEBUG_ASSERTCRASH(!BOGUSPTR(*pListHead) && !BOGUSPTR(m_dlink_##LISTNAME.m_next) && !BOGUSPTR(m_dlink_##LISTNAME.m_prev), ("bogus ptrs")); \ - m_dlink_##LISTNAME.m_next = *pListHead; \ - if (*pListHead) \ - (*pListHead)->m_dlink_##LISTNAME.m_prev = this; \ - *pListHead = this; \ - DEBUG_ASSERTCRASH(!BOGUSPTR(*pListHead) && !BOGUSPTR(m_dlink_##LISTNAME.m_next) && !BOGUSPTR(m_dlink_##LISTNAME.m_prev), ("bogus ptrs")); \ - } \ - void dlink_removeFrom_##LISTNAME(OBJCLASS** pListHead) \ - { \ - DEBUG_ASSERTCRASH(dlink_isInList_##LISTNAME(pListHead), ("not in list" #LISTNAME)); \ - DEBUG_ASSERTCRASH(!BOGUSPTR(*pListHead) && !BOGUSPTR(m_dlink_##LISTNAME.m_next) && !BOGUSPTR(m_dlink_##LISTNAME.m_prev), ("bogus ptrs")); \ - if (m_dlink_##LISTNAME.m_next) \ - m_dlink_##LISTNAME.m_next->m_dlink_##LISTNAME.m_prev = m_dlink_##LISTNAME.m_prev; \ - if (m_dlink_##LISTNAME.m_prev) \ - m_dlink_##LISTNAME.m_prev->m_dlink_##LISTNAME.m_next = m_dlink_##LISTNAME.m_next; \ - else \ - *pListHead = m_dlink_##LISTNAME.m_next; \ - m_dlink_##LISTNAME.m_prev = 0; \ - m_dlink_##LISTNAME.m_next = 0; \ - DEBUG_ASSERTCRASH(!BOGUSPTR(*pListHead) && !BOGUSPTR(m_dlink_##LISTNAME.m_next) && !BOGUSPTR(m_dlink_##LISTNAME.m_prev), ("bogus ptrs")); \ - } \ -private: \ - /* a trick: init links to zero */ \ - struct DLINK_##LISTNAME \ - { \ - public: \ - OBJCLASS* m_prev; \ - OBJCLASS* m_next; \ - inline DLINK_##LISTNAME() : \ - m_prev(0), m_next(0) { } \ - inline ~DLINK_##LISTNAME() \ - { DEBUG_ASSERTCRASH(!m_prev && !m_next,("destroying dlink still in a list " #LISTNAME)); } \ - }; \ - DLINK_##LISTNAME m_dlink_##LISTNAME; - -// ------------------------------------------------------------------------ -// this is the weird C++ syntax for "call pointer-to-member-function"... see C++ FAQ LITE for details. -#define callMemberFunction(object,ptrToMember) ((object).*(ptrToMember)) - -// ------------------------------------------------------------------------ -template -class DLINK_ITERATOR -{ -public: - // this is the weird C++ syntax for "pointer-to-member-function" - typedef OBJCLASS* (OBJCLASS::*GetNextFunc)() const; -private: - OBJCLASS* m_cur; - GetNextFunc m_getNextFunc; // this is the weird C++ syntax for "pointer-to-member-function" -public: - DLINK_ITERATOR(OBJCLASS* cur, GetNextFunc getNextFunc) : m_cur(cur), m_getNextFunc(getNextFunc) - { - } - - void advance() - { - if (m_cur) - m_cur = callMemberFunction(*m_cur, m_getNextFunc)(); - } - - Bool done() const - { - return m_cur == nullptr; - } - - OBJCLASS* cur() const - { - return m_cur; - } - -}; - -// ------------------------------------------------------------------------ - -enum WhichTurretType CPP_11(: Int) -{ - TURRET_INVALID = -1, - - TURRET_MAIN = 0, - TURRET_ALT, - - MAX_TURRETS -}; - -// ------------------------------------------------------------------------ -// this normalizes an angle to the range -PI...PI. -// TheSuperHackers @todo DO NOT USE THIS FUNCTION! Use WWMath::Normalize_Angle instead. Delete this. -extern Real normalizeAngle(Real angle); - -// ------------------------------------------------------------------------ -// this returns the difference between a1 and a2, normalized. -inline Real stdAngleDiff(Real a1, Real a2) -{ - return normalizeAngle(a1 - a2); -} - -// ------------------------------------------------------------------------ -// NOTE NOTE NOTE: Keep TheRelationShipNames in sync with this enum -enum Relationship CPP_11(: Int) -{ - ENEMIES, - NEUTRAL, - ALLIES, - - RELATIONSHIP_COUNT -}; - - -// TheRelationShipNames is defined in Common/GameCommon.cpp -extern const char *const TheRelationshipNames[]; diff --git a/Generals/Code/GameEngine/Include/Common/GameType.h b/Generals/Code/GameEngine/Include/Common/GameType.h deleted file mode 100644 index c28b9e04fbd..00000000000 --- a/Generals/Code/GameEngine/Include/Common/GameType.h +++ /dev/null @@ -1,191 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// GameType.h -// Basic data types needed for the game engine. This is an extension of BaseType.h. -// Author: Michael S. Booth, April 2001 - -#pragma once - -#include "Lib/BaseType.h" - -// the default size of the world map -#define DEFAULT_WORLD_WIDTH 64 -#define DEFAULT_WORLD_HEIGHT 64 - -/// A unique, generic "identifier" used to access Objects. -enum ObjectID CPP_11(: Int) -{ - INVALID_ID = 0, - FORCE_OBJECTID_TO_LONG_SIZE = 0x7ffffff -}; - -/// A unique, generic "identifier" used to access Drawables. -enum DrawableID CPP_11(: Int) -{ - INVALID_DRAWABLE_ID = 0, - FORCE_DRAWABLEID_TO_LONG_SIZE = 0x7ffffff -}; - -/// A unique, generic "identifier" used to identify player specified formations. -enum FormationID CPP_11(: Int) -{ - NO_FORMATION_ID = 0, // Unit is not a member of any formation - FORCE_FORMATIONID_TO_LONG_SIZE = 0x7ffffff -}; - -#define INVALID_ANGLE -100.0f - -class INI; - -//------------------------------------------------------------------------------------------------- -/** The time of day enumeration, keep in sync with TimeOfDayNames[] */ -//------------------------------------------------------------------------------------------------- -enum TimeOfDay CPP_11(: Int) -{ - TIME_OF_DAY_INVALID, - - TIME_OF_DAY_MORNING, - TIME_OF_DAY_AFTERNOON, - TIME_OF_DAY_EVENING, - TIME_OF_DAY_NIGHT, - - TIME_OF_DAY_COUNT, - TIME_OF_DAY_FIRST = TIME_OF_DAY_MORNING, -}; - -extern const char *const TimeOfDayNames[]; -// defined in Common/GameType.cpp - -//------------------------------------------------------------------------------------------------- -enum Weather CPP_11(: Int) -{ - WEATHER_NORMAL = 0, - WEATHER_SNOWY = 1, - - WEATHER_COUNT -}; - -extern const char *const WeatherNames[]; - -enum Scorches CPP_11(: Int) -{ - SCORCH_1 = 0, - SCORCH_2 = 1, - SCORCH_3 = 2, - SCORCH_4 = 3, - SHADOW_SCORCH = 4, -/* SCORCH_6 = 5, - SCORCH_7 = 6, - SCORCH_8 = 7, - - CRATER_1 = 8, - CRATER_2 = 9, - CRATER_3 = 10, - CRATER_4 = 11, - CRATER_5 = 12, - CRATER_6 = 13, - CRATER_7 = 14, - CRATER_8 = 15, - - - MISC_DECAL_1 = 16, - MISC_DECAL_2 = 17, - MISC_DECAL_3 = 18, - MISC_DECAL_4 = 19, - MISC_DECAL_5 = 20, - MISC_DECAL_6 = 21, - MISC_DECAL_7 = 22, - MISC_DECAL_8 = 23, - - MISC_DECAL_9 = 24, - MISC_DECAL_10 = 25, - MISC_DECAL_11 = 26, - MISC_DECAL_12 = 27, - MISC_DECAL_13 = 28, - MISC_DECAL_14 = 29, - MISC_DECAL_15 = 30, - MISC_DECAL_16 = 31, - - MISC_DECAL_17 = 32, - MISC_DECAL_18 = 33, - MISC_DECAL_19 = 34, - MISC_DECAL_20 = 35, - MISC_DECAL_21 = 36, - MISC_DECAL_22 = 37, - MISC_DECAL_23 = 38, - MISC_DECAL_24 = 39, - - MISC_DECAL_25 = 40, - MISC_DECAL_26 = 41, - MISC_DECAL_27 = 42, - MISC_DECAL_28 = 43, - MISC_DECAL_29 = 44, - MISC_DECAL_30 = 45, - MISC_DECAL_31 = 46, - MISC_DECAL_32 = 47, - - MISC_DECAL_33 = 48, - MISC_DECAL_34 = 49, - MISC_DECAL_35 = 50, - MISC_DECAL_36 = 51, - MISC_DECAL_37 = 52, - MISC_DECAL_38 = 53, - MISC_DECAL_39 = 54, - MISC_DECAL_40 = 55, - - MISC_DECAL_41 = 56, - MISC_DECAL_42 = 57, - MISC_DECAL_43 = 58, - MISC_DECAL_44 = 59, - MISC_DECAL_45 = 60, - MISC_DECAL_46 = 61, - MISC_DECAL_47 = 62, - MISC_DECAL_48 = 63, -*/ - SCORCH_COUNT -}; - -//------------------------------------------------------------------------------------------------- -enum WeaponSlotType CPP_11(: Int) -{ - PRIMARY_WEAPON = 0, - SECONDARY_WEAPON, - TERTIARY_WEAPON, - - WEAPONSLOT_COUNT -}; - -//------------------------------------------------------------------------------------------------- -// Pathfind layers - ground is the first layer, each bridge is another. jba. -// Layer 1 is the ground. -// Layer 2 is the top layer - bridge if one is present, ground otherwise. -// Layer 2 - LAYER_LAST -1 are bridges. -// Layer_WALL is a special "wall" layer for letting units run around on top of a wall -// made of structures. -// Note that the bridges just index in the pathfinder, so you don't actually -// have a LAYER_BRIDGE_1 enum value. -enum PathfindLayerEnum CPP_11(: Int) {LAYER_INVALID = 0, LAYER_GROUND = 1, LAYER_WALL = 15, LAYER_LAST=15}; - -//------------------------------------------------------------------------------------------------- diff --git a/Generals/Code/GameEngine/Include/Common/INI.h b/Generals/Code/GameEngine/Include/Common/INI.h deleted file mode 100644 index f08d157f7dc..00000000000 --- a/Generals/Code/GameEngine/Include/Common/INI.h +++ /dev/null @@ -1,415 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: INI.h //////////////////////////////////////////////////////////////////////////////////// -// Author: Colin Day, November 2001 -// Desc: INI Reader -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#pragma once - -// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include // for offsetof, which we don't use but everyone who includes us does -#include "Common/STLTypedefs.h" -#include "Common/AsciiString.h" -#include "Common/GameCommon.h" - -//------------------------------------------------------------------------------------------------- -class INI; -class Xfer; -class File; -enum ScienceType CPP_11(: Int); - -//------------------------------------------------------------------------------------------------- -/** These control the behavior of loading the INI data into items */ -//------------------------------------------------------------------------------------------------- -enum INILoadType CPP_11(: Int) -{ - INI_LOAD_INVALID, ///< invalid load type - INI_LOAD_OVERWRITE, ///< create new or load *over* existing data instance - INI_LOAD_CREATE_OVERRIDES, ///< create new or load into *new* override data instance - INI_LOAD_MULTIFILE ///< create new or continue loading into existing data instance. -}; - -//------------------------------------------------------------------------------------------------- -/** INI constant defines */ -//------------------------------------------------------------------------------------------------- -enum -{ - INI_MAX_CHARS_PER_LINE = 1028, ///< max characters per line entry in any ini file -}; - -//------------------------------------------------------------------------------------------------- -/** Status return codes for the INI reader */ -//------------------------------------------------------------------------------------------------- -enum -{ - // we map all of these to the same "real" error code, because - // we generally don't care why it failed; but since the code distinguishes, - // I didn't want to wipe out that intelligence. if we ever need to distinguish - // failure modes at runtime, just put in real values for these. - INI_CANT_SEARCH_DIR = ERROR_BAD_INI, - INI_INVALID_DIRECTORY = ERROR_BAD_INI, - INI_INVALID_PARAMS = ERROR_BAD_INI, - INI_INVALID_NAME_LIST = ERROR_BAD_INI, - INI_INVALID_DATA = ERROR_BAD_INI, - INI_MISSING_END_TOKEN = ERROR_BAD_INI, - INI_UNKNOWN_TOKEN = ERROR_BAD_INI, - INI_BUFFER_TOO_SMALL = ERROR_BAD_INI, - INI_FILE_NOT_OPEN = ERROR_BAD_INI, - INI_FILE_ALREADY_OPEN = ERROR_BAD_INI, - INI_CANT_OPEN_FILE = ERROR_BAD_INI, - INI_UNKNOWN_ERROR = ERROR_BAD_INI, - INI_END_OF_FILE = ERROR_BAD_INI -}; - -//------------------------------------------------------------------------------------------------- -/** Function typedef for parsing data block fields. - * - * buffer - the character buffer of the line from INI that we are reading and parsing - * instance - instance of what we're loading (for example a ThingTemplate instance) - * store - where to store the data parsed, this is a field in the *instance* 'instance' - */ -//------------------------------------------------------------------------------------------------- -typedef void (*INIFieldParseProc)( INI *ini, void *instance, void *store, const void* userData ); - -//------------------------------------------------------------------------------------------------- -typedef const char* const ConstCharPtr; -typedef ConstCharPtr* ConstCharPtrArray; - -//------------------------------------------------------------------------------------------------- -struct LookupListRec -{ - const char* name; - Int value; -}; -typedef const LookupListRec *ConstLookupListRecArray; - -//------------------------------------------------------------------------------------------------- -/** Parse tables for all fields of each data block are created using these */ -//------------------------------------------------------------------------------------------------- -struct FieldParse -{ - const char* token; ///< token of the field - INIFieldParseProc parse; ///< the parse function - const void* userData; ///< field-specific data - Int offset; ///< offset to data field - - void set(const char* t, INIFieldParseProc p, const void* u, Int o) - { - token = t; - parse = p; - userData = u; - offset = o; - } -}; - -//------------------------------------------------------------------------------------------------- -class MultiIniFieldParse -{ -private: - enum { MAX_MULTI_FIELDS = 16 }; - - const FieldParse* m_fieldParse[MAX_MULTI_FIELDS]; - UnsignedInt m_extraOffset[MAX_MULTI_FIELDS]; - Int m_count; - -public: - MultiIniFieldParse() : m_count(0) - { - for(Int i = 0; i < MAX_MULTI_FIELDS; i++) - m_extraOffset[i] = 0; - } - - void add(const FieldParse* f, UnsignedInt e = 0); - - Int getCount() const { return m_count; } - const FieldParse* getNthFieldParse(Int i) const { return m_fieldParse[i]; } - UnsignedInt getNthExtraOffset(Int i) const { return m_extraOffset[i]; } -}; - -//------------------------------------------------------------------------------------------------- -/** Function typedef for parsing INI types blocks */ -//------------------------------------------------------------------------------------------------- -typedef void (*INIBlockParse)( INI *ini ); -typedef void (*BuildMultiIniFieldProc)(MultiIniFieldParse& p); - -//------------------------------------------------------------------------------------------------- -/** INI Reader interface */ -//------------------------------------------------------------------------------------------------- -class INI -{ - INI(const INI&); - INI& operator=(const INI&); - -public: - - INI(); - ~INI(); - - // TheSuperHackers @feature xezon 19/08/2025 - // Load a specific INI file by name and/or INI files from a directory (and its subdirectories). - // For example "Data\INI\Armor" loads "Data\INI\Armor.ini" and all *.ini files in "Data\INI\Armor". - // Throws if not a single INI file is found or one is not read correctly. - UnsignedInt loadFileDirectory( AsciiString fileDirName, INILoadType loadType, Xfer *pXfer, Bool subdirs = TRUE ); - - // Load INI files from a directory (and its subdirectories). - // Throws if one INI file is not read correctly. - UnsignedInt loadDirectory( AsciiString dirName, INILoadType loadType, Xfer *pXfer, Bool subdirs = TRUE ); - - // Load one specific INI file by name. - // Throws if the INI file is not found or is not read correctly. - UnsignedInt load( AsciiString filename, INILoadType loadType, Xfer *pXfer ); - - static Bool isDeclarationOfType( AsciiString blockType, AsciiString blockName, char *bufferToCheck ); - static Bool isEndOfBlock( char *bufferToCheck ); - - // data type parsing (the highest level of what type of thing we're parsing) - static void parseObjectDefinition( INI *ini ); - static void parseObjectReskinDefinition( INI *ini ); - static void parseWeaponTemplateDefinition( INI *ini ); - static void parseScienceDefinition( INI *ini ); - static void parseRankDefinition( INI *ini ); - static void parseCrateTemplateDefinition( INI *ini ); - static void parseLocomotorTemplateDefinition( INI *ini ); - static void parseLanguageDefinition( INI *ini ); - static void parsePlayerTemplateDefinition( INI *ini ); - static void parseGameDataDefinition( INI *ini ); - static void parseMapDataDefinition( INI *ini ); - static void parseAnim2DDefinition( INI *ini ); - static void parseAudioEventDefinition( INI *ini ); - static void parseDialogDefinition( INI *ini ); - static void parseMusicTrackDefinition( INI *ini ); - static void parseWebpageURLDefinition( INI *ini ); - static void parseHeaderTemplateDefinition( INI *ini ); - static void parseParticleSystemDefinition( INI *ini ); - static void parseWaterSettingDefinition( INI *ini ); - static void parseWaterTransparencyDefinition( INI *ini ); - static void parseWeatherDefinition( INI *ini ); - static void parseMappedImageDefinition( INI *ini ); - static void parseArmorDefinition( INI *ini ); - static void parseDamageFXDefinition( INI *ini ); - static void parseDrawGroupNumberDefinition( INI *ini ); - static void parseTerrainDefinition( INI *ini ); - static void parseTerrainRoadDefinition( INI *ini ); - static void parseTerrainBridgeDefinition( INI *ini ); - static void parseMetaMapDefinition( INI *ini ); - static void parseFXListDefinition( INI *ini ); - static void parseObjectCreationListDefinition( INI* ini ); - static void parseMultiplayerSettingsDefinition( INI* ini ); - static void parseMultiplayerColorDefinition( INI* ini ); - static void parseMultiplayerStartingMoneyChoiceDefinition( INI* ini ); - static void parseOnlineChatColorDefinition( INI* ini ); - static void parseMapCacheDefinition( INI* ini ); - static void parseVideoDefinition( INI* ini ); - static void parseCommandButtonDefinition( INI *ini ); - static void parseCommandSetDefinition( INI *ini ); - static void parseUpgradeDefinition( INI *ini ); - static void parseMouseDefinition( INI* ini ); - static void parseMouseCursorDefinition( INI* ini ); - static void parseAIDataDefinition( INI *ini ); - static void parseSpecialPowerDefinition( INI *ini ); - static void parseInGameUIDefinition( INI *ini ); - static void parseControlBarSchemeDefinition( INI *ini ); - static void parseControlBarResizerDefinition( INI *ini ); - static void parseShellMenuSchemeDefinition( INI *ini ); - static void parseCampaignDefinition( INI *ini ); - static void parseAudioSettingsDefinition( INI *ini ); - static void parseMiscAudio( INI *ini ); - static void parseStaticGameLODDefinition( INI *ini); - static void parseDynamicGameLODDefinition( INI *ini); - static void parseStaticGameLODLevel( INI* ini, void * , void *store, const void*); - static void parseDynamicGameLODLevel( INI* ini, void * , void *store, const void*); - static void parseLODPreset( INI* ini); - static void parseBenchProfile( INI* ini); - static void parseEvaEvent( INI* ini ); - static void parseCredits( INI* ini ); - static void parseWindowTransitions( INI* ini ); - static void parseChallengeModeDefinition( INI* ini ); - - AsciiString getFilename( void ) const { return m_filename; } - INILoadType getLoadType( void ) const { return m_loadType; } - UnsignedInt getLineNum( void ) const { return m_lineNum; } - const char *getSeps( void ) const { return m_seps; } - const char *getSepsPercent( void ) const { return m_sepsPercent; } - const char *getSepsColon( void ) const { return m_sepsColon; } - const char *getSepsQuote( void ) { return m_sepsQuote; } - Bool isEOF( void ) const { return m_endOfFile; } - - void initFromINI( void *what, const FieldParse* parseTable ); - void initFromINIMulti( void *what, const MultiIniFieldParse& parseTableList ); - void initFromINIMultiProc( void *what, BuildMultiIniFieldProc proc ); - - static void parseUnsignedByte( INI *ini, void *instance, void *store, const void* userData ); - static void parseShort( INI *ini, void *instance, void *store, const void* userData ); - static void parseUnsignedShort( INI *ini, void *instance, void *store, const void* userData ); - static void parseInt( INI *ini, void *instance, void *store, const void* userData ); - static void parseUnsignedInt( INI *ini, void *instance, void *store, const void* userData ); - static void parseReal( INI *ini, void *instance, void *store, const void* userData ); - static void parsePositiveNonZeroReal( INI *ini, void *instance, void *store, const void* userData ); - static void parseBool( INI *ini, void *instance, void *store, const void* userData ); - static void parseBitInInt32( INI *ini, void *instance, void *store, const void* userData ); - static void parseAsciiString( INI *ini, void *instance, void *store, const void* userData ); - static void parseQuotedAsciiString( INI *ini, void *instance, void *store, const void* userData ); - static void parseAsciiStringVector( INI *ini, void *instance, void *store, const void* userData ); - static void parseAsciiStringVectorAppend( INI *ini, void *instance, void *store, const void* userData ); - static void parseAndTranslateLabel( INI *ini, void *instance, void *store, const void* userData ); - static void parseMappedImage( INI *ini, void *instance, void *store, const void *userData ); - static void parseAnim2DTemplate( INI *ini, void *instance, void *store, const void *userData ); - static void parsePercentToReal( INI *ini, void *instance, void *store, const void* userData ); - static void parseRGBColor( INI *ini, void *instance, void *store, const void* userData ); - static void parseRGBAColorInt( INI *ini, void *instance, void *store, const void* userData ); - static void parseColorInt( INI *ini, void *instance, void *store, const void* userData ); - static void parseCoord3D( INI *ini, void *instance, void *store, const void* userData ); - static void parseCoord2D( INI *ini, void *instance, void *store, const void *userData ); - static void parseICoord2D( INI *ini, void *instance, void *store, const void *userData ); - static void parseDynamicAudioEventRTS( INI *ini, void *instance, void *store, const void* userData ); - static void parseAudioEventRTS( INI *ini, void *instance, void *store, const void* userData ); - static void parseFXList( INI *ini, void *instance, void *store, const void* userData ); - static void parseParticleSystemTemplate( INI *ini, void *instance, void *store, const void *userData ); - static void parseObjectCreationList( INI *ini, void *instance, void *store, const void* userData ); - static void parseSpecialPowerTemplate( INI *ini, void *instance, void *store, const void *userData ); - static void parseUpgradeTemplate( INI *ini, void *instance, void *store, const void *userData ); - static void parseScience( INI *ini, void *instance, void *store, const void *userData ); - static void parseScienceVector( INI *ini, void *instance, void *store, const void *userData ); - static void parseGameClientRandomVariable( INI* ini, void *instance, void *store, const void* userData ); - static void parseBitString8( INI *ini, void *instance, void *store, const void* userData ); - static void parseBitString32( INI *ini, void *instance, void *store, const void* userData ); - static void parseByteSizedIndexList( INI *ini, void *instance, void *store, const void* userData ); - static void parseIndexList( INI *ini, void *instance, void *store, const void* userData ); - static void parseLookupList( INI *ini, void *instance, void *store, const void* userData ); - static void parseThingTemplate( INI *ini, void *instance, void *store, const void* userData ); - static void parseArmorTemplate( INI *ini, void *instance, void *store, const void* userData ); - static void parseDamageFX( INI *ini, void *instance, void *store, const void* userData ); - static void parseWeaponTemplate( INI *ini, void *instance, void *store, const void* userData ); - // parse a duration in msec and convert to duration in frames - static void parseDurationReal( INI *ini, void *instance, void *store, const void* userData ); - // parse a duration in msec and convert to duration in integral number of frames, (unsignedint) rounding UP - static void parseDurationUnsignedInt( INI *ini, void *instance, void *store, const void* userData ); - static void parseDurationUnsignedShort( INI *ini, void *instance, void *store, const void *userData ); - // parse acceleration in (dist/sec) and convert to (dist/frame) - static void parseVelocityReal( INI *ini, void *instance, void *store, const void* userData ); - // parse acceleration in (dist/sec^2) and convert to (dist/frame^2) - static void parseAccelerationReal( INI *ini, void *instance, void *store, const void* userData ); - // parse angle in degrees and convert to radians - static void parseAngleReal( INI *ini, void *instance, void *store, const void *userData ); - // note that this parses in degrees/sec, and converts to rads/frame! - static void parseAngularVelocityReal( INI *ini, void *instance, void *store, const void *userData ); - static void parseDamageTypeFlags(INI* ini, void* instance, void* store, const void* userData); - static void parseDeathTypeFlags(INI* ini, void* instance, void* store, const void* userData); - static void parseVeterancyLevelFlags(INI* ini, void* instance, void* store, const void* userData); - static void parseSoundsList( INI* ini, void *instance, void *store, const void* /*userData*/ ); - - - /** - return the next token. if seps is null (or omitted), the standard seps are used. - - this will *never* return null; if there are no more tokens, an exception will be thrown. - */ - const char* getNextToken(const char* seps = nullptr); - - /** - just like getNextToken(), except that null is returned if no more tokens are present - (rather than throwing an exception). usually you should call getNextToken(), - but for some cases this is handier (ie, parsing a variable-length number of tokens). - */ - const char* getNextTokenOrNull(const char* seps = nullptr); - - /** - This is called when the next thing you expect is something like: - - Tag:value - - pass "Tag" (without the colon) for 'expected', and you will have the 'value' - token returned. - - If "Tag" is not the next token, an error is thrown. - */ - const char* getNextSubToken(const char* expected); - - /** - return the next ascii string. this is usually the same the result of getNextToken(), - except that it allows for quote-delimited strings (eg, "foo bar"), so you can - get strings with spaces, and/or empty strings. - */ - AsciiString getNextAsciiString(); - AsciiString getNextQuotedAsciiString(); //fixed version of above. We can't fix the regular one for fear of breaking existing code. :-( - - /** - utility routine that does a sscanf() on the string to get the Science, and throws - an exception if not of the right form. - */ - static ScienceType scanScience(const char* token); - - /** - utility routine that does a sscanf() on the string to get the int, and throws - an exception if not of the right form. - */ - static Int scanInt(const char* token); - - /** - utility routine that does a sscanf() on the string to get the unsigned int, and throws - an exception if not of the right form. - */ - static UnsignedInt scanUnsignedInt(const char* token); - - /** - utility routine that does a sscanf() on the string to get the real, and throws - an exception if not of the right form. - */ - static Real scanReal(const char* token); - static Real scanPercentToReal(const char* token); - - static Int scanIndexList(const char* token, ConstCharPtrArray nameList); - static Int scanLookupList(const char* token, ConstLookupListRecArray lookupList); - - static Bool scanBool(const char* token); - -protected: - - static Bool isValidINIFilename( const char *filename ); ///< is this a valid .ini filename - - void prepFile( AsciiString filename, INILoadType loadType ); - void unPrepFile(); - - void readLine( void ); - - char* m_readBuffer; ///< internal read buffer - unsigned m_readBufferNext; ///< next char in read buffer - unsigned m_readBufferUsed; ///< number of bytes in read buffer - - AsciiString m_filename; ///< filename of file currently loading - INILoadType m_loadType; ///< load time for current file - UnsignedInt m_lineNum; ///< current line number that's been read - char m_buffer[ INI_MAX_CHARS_PER_LINE+1 ];///< buffer to read file contents into - const char *m_seps; ///< for strtok parsing - const char *m_sepsPercent; ///< m_seps with percent delimiter as well - const char *m_sepsColon; ///< m_seps with colon delimiter as well - const char *m_sepsQuote; ///< token to represent a quoted ascii string - const char *m_blockEndToken; ///< token to represent end of data block - Bool m_endOfFile; ///< TRUE when we've hit EOF -#ifdef DEBUG_CRASHING - char m_curBlockStart[ INI_MAX_CHARS_PER_LINE+1 ]; ///< first line of cur block -#endif -}; diff --git a/Generals/Code/GameEngine/Include/Common/STLTypedefs.h b/Generals/Code/GameEngine/Include/Common/STLTypedefs.h deleted file mode 100644 index 484b3f33e80..00000000000 --- a/Generals/Code/GameEngine/Include/Common/STLTypedefs.h +++ /dev/null @@ -1,297 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: STLTypedefs.h //////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright (C) 2001 - All Rights Reserved -// -//----------------------------------------------------------------------------- -// -// Project: RTS3 -// -// File name: STLTypedefs.h -// -// Created: John McDonald -// -// Desc: @todo -// -//----------------------------------------------------------------------------- - -#pragma once - -//----------------------------------------------------------------------------- -// srj sez: this must come first, first, first. -#define _STLP_USE_NEWALLOC 1 -//#define _STLP_USE_CUSTOM_NEWALLOC STLSpecialAlloc -class STLSpecialAlloc; - -//----------------------------------------------------------------------------- -#include "Common/AsciiString.h" -#include "Common/UnicodeString.h" -#include "Common/GameCommon.h" -#include "Common/GameMemory.h" - -//----------------------------------------------------------------------------- - - -// FORWARD DECLARATIONS -class Object; -enum NameKeyType CPP_11(: Int); -enum ObjectID CPP_11(: Int); -enum DrawableID CPP_11(: Int); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// List of AsciiStrings to allow list of ThingTemplate names from INI and such -typedef std::list< AsciiString > AsciiStringList; -typedef std::list< AsciiString >::iterator AsciiStringListIterator; -typedef std::list< AsciiString >::const_iterator AsciiStringListConstIterator; - -// One is used in GameLogic to keep track of objects to be destroyed -typedef std::list ObjectPointerList; -typedef std::list::iterator ObjectPointerListIterator; - -typedef std::vector ObjectIDVector; -typedef std::vector::iterator ObjectIDVectorIterator; - -// Terribly useful, especially with Bezier curves -typedef std::vector VecCoord3D; -typedef VecCoord3D::iterator VecCoord3DIt; - -// Used for cursor->3D position request caching in the heightmap -typedef std::pair PosRequest; -typedef std::vector VecPosRequests; -typedef std::vector::iterator VecPosRequestsIt; - -// Used to cache off names of objects for faster lookup -typedef std::pair NamedRequest; -typedef std::vector VecNamedRequests; -typedef std::vector::iterator VecNamedRequestsIt; - -// Rumor has it that a Vector of Bools gets stored as a bitfield internally. -typedef std::vector BoolVector; -typedef std::vector::iterator BoolVectorIterator; - -typedef std::map< NameKeyType, Real, std::less > ProductionChangeMap; -typedef std::map< NameKeyType, VeterancyLevel, std::less > ProductionVeterancyMap; - -// Some useful, common hash and equal_to functors for use with hash_map -namespace rts -{ - - // Generic hash functor. This should almost always be overridden for - // specific types. - template struct hash - { - size_t operator()(const T& __t) const - { - std::hash tmp; - return tmp(__t); - } - }; - - // Generic equal_to functor. This should be overridden if there is no - // operator==, or if that isn't the behavior desired. (For instance, in - // the case of pointers.) - template struct equal_to - { - Bool operator()(const T& __t1, const T& __t2) const - { - return (__t1 == __t2); - } - }; - - // Generic less_than_nocase functor. This should be overridden if there is no - // operator<, or if that isn't the behavior desired. (For instance, in - // the case of pointers, or strings.) - template struct less_than_nocase - { - bool operator()(const T& __t1, const T& __t2) const - { - return (__t1 < __t2); - } - }; - - template<> struct hash - { - size_t operator()(NameKeyType nkt) const - { - std::hash tmp; - return tmp((UnsignedInt)nkt); - } - }; - - template<> struct hash - { - size_t operator()(DrawableID nkt) const - { - std::hash tmp; - return tmp((UnsignedInt)nkt); - } - }; - - template<> struct hash - { - size_t operator()(ObjectID nkt) const - { - std::hash tmp; - return tmp((UnsignedInt)nkt); - } - }; - - template<> struct hash - { - size_t operator()(const Char* s) const - { -#ifdef USING_STLPORT - std::hash hasher; - return hasher(s); -#else - std::hash hasher; - return hasher(s); -#endif - } - }; - - // This is the equal_to overload for char* comparisons. We compare the - // strings to determine whether they are equal or not. - // Other overloads should go into specific header files, not here (unless - // they are to be used in lots of places.) - template<> struct equal_to - { - Bool operator()(const char* s1, const char* s2) const - { - return strcmp(s1, s2) == 0; - } - }; - - template<> struct hash - { - size_t operator()(const AsciiString& ast) const - { -#ifdef USING_STLPORT - std::hash tmp; - return tmp((const char *) ast.str()); -#else - // TheSuperHackers @bugfix xezon 16/03/2024 Re-implements hash function that works with non-STLPort. - std::hash hasher; - return hasher(std::string_view(ast.str(), ast.getLength())); -#endif - } - }; - - template<> struct equal_to - { - Bool operator()(const AsciiString& __t1, const AsciiString& __t2) const - { - return (__t1 == __t2); - } - }; - - template<> struct less_than_nocase - { - bool operator()(const AsciiString& __t1, const AsciiString& __t2) const - { - return (__t1.compareNoCase(__t2) < 0); - } - }; - - template<> struct less_than_nocase - { - bool operator()(const UnicodeString& __t1, const UnicodeString& __t2) const - { - return (__t1.compareNoCase(__t2) < 0); - } - }; - - // TheSuperHackers @info Structs to help create maps that can use C strings for - // lookups without the need to allocate a string. - template - struct string_key - { - typedef typename String::const_pointer const_pointer; - - static string_key temporary(const_pointer s) - { - string_key key; - key.cstr = s; - return key; - } - - string_key(const_pointer s) - : storage(s) - , cstr(storage.str()) - {} - - string_key(const String& s) - : storage(s) - , cstr(storage.str()) - {} - - const_pointer c_str() const - { - return cstr; - } - - private: - string_key() {} - - String storage; - const_pointer cstr; - }; - - template - struct string_key_hash - { - typedef typename String::const_pointer const_pointer; - size_t operator()(const string_key& key) const - { - return hash()(key.c_str()); - } - }; - - template - struct string_key_equal - { - bool operator()(const string_key& a, const string_key& b) const - { - return strcmp(a.c_str(), b.c_str()) == 0; - } - }; - -} // namespace rts diff --git a/Generals/Code/GameEngine/Include/Common/Snapshot.h b/Generals/Code/GameEngine/Include/Common/Snapshot.h deleted file mode 100644 index e8a3ef7434c..00000000000 --- a/Generals/Code/GameEngine/Include/Common/Snapshot.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: Snapshot.h /////////////////////////////////////////////////////////////////////////////// -// Author: Colin Day, February 2002 -// Desc: The Snapshot object is the base class interface for data structures that will -// be considered during game saves, loads, and CRC checks. -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#pragma once - -// USER INCLUDES ////////////////////////////////////////////////////////////////////////////////// -#include "Common/AsciiString.h" - -// FORWARD REFERENCES ///////////////////////////////////////////////////////////////////////////// -class Xfer; - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -class Snapshot -{ - -friend class GameState; -friend class XferLoad; -friend class XferSave; -friend class XferCRC; - -public: - - Snapshot( void ); - ~Snapshot( void ); - -protected: - - /// run the "light" crc check on this data structure - virtual void crc( Xfer *xfer ) = 0; - - /** run save, load, or deep CRC check on this data structure, the type depends on the - setup of the Xfer pointer */ - virtual void xfer( Xfer *xfer ) = 0; - - /** post process phase for loading save games. All save systems have their xfer - run using XferLoad mode, and then all systems each have their post process run */ - virtual void loadPostProcess( void ) = 0; - -}; diff --git a/Generals/Code/GameEngine/Include/Common/SubsystemInterface.h b/Generals/Code/GameEngine/Include/Common/SubsystemInterface.h deleted file mode 100644 index c30e6f663c2..00000000000 --- a/Generals/Code/GameEngine/Include/Common/SubsystemInterface.h +++ /dev/null @@ -1,168 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: SubsystemInterface.h ///////////////////////////////////////////////////////////////////// -// Author: Colin Day, October 2001 -// Description: Framework for subsystems singletons of the game engine -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include "Common/INI.h" -#include "Common/STLTypedefs.h" - -class Xfer; - -//------------------------------------------------------------------------------------------------- -/** This is the abstract base class from which all game engine subsystems should derive from. - * In order to provide consistent behaviors across all these systems, any implementation - * must obey the rules defined in here - * - * Nothing about the subsystems is automatic, this interface does not wrap up automated - * functions, it is only here to provide a basic interface and rules for behavior - * all subsystems - */ -class SubsystemInterface -{ - -public: - - //----------------------------------------------------------------------------------------------- - /** - Constructors should initialize any data to a valid state. That DOES NOT mean - * the data has default values (something done in the init() method), only that - * nothing is left pointing to garbage, un-initialized memory. In most cases - * this probably means just setting members to zero or nullptr. - */ - SubsystemInterface(); - - //----------------------------------------------------------------------------------------------- - /** - Free any resources allocated for this class. - * - * - DO NOT throw exceptions during any destruction ever, and do not call other - * methods that have the possibility of throwing exceptions. Try to keep it - * simple and keep as much work actually inside the destructor as possible. - */ - virtual ~SubsystemInterface(); - - //----------------------------------------------------------------------------------------------- - /** - Assign any default values to data required for the class - * - * - Allocate any memory and resources needed throughout the lifetime of the class - */ - virtual void init() = 0; - - //----------------------------------------------------------------------------------------------- - /** - Called for all subsystems after all other Subsystems are inited. - * (allows for initializing inter-system dependencies) - */ - virtual void postProcessLoad() { } - - //----------------------------------------------------------------------------------------------- - /** - Any system should be able to reset all data and go back to an empty state - * that is ready to accept a completely new set of data. Reset() can expect - * to be used in the context of resetting the engine in order to start or - * load a new game. - * - * - Do NOT free and re-allocate resources needed, where possible reorganize and - * re-initialize the resources already allocated. - * - * - After a reset, the system does not need to be in EXACTLY the same state as a - * fresh instantiation. If there are persistent state information for the - * system make sure you maintain it while restoring or re-initializing other - * transient parts. - */ - virtual void reset() = 0; - - //----------------------------------------------------------------------------------------------- - /** - Update methods are the place to do system per frame processing. You - * should call the system update once each time through the game loop - * to service the system. - * - * - Note that currently the GameClient and GameLogic will be updating - * at different rates where the logic is running real time, and the - * client will adjust how many loops can be done during one server - * time slice in order to improve performance on low end machines. - */ - virtual void update() = 0; - - - virtual void draw( void ){DEBUG_CRASH(("Shouldn't call base class. jba."));} - -#ifdef DUMP_PERF_STATS - void UPDATE(void); - void DRAW(void); - Real getUpdateTime(void) {return m_curUpdateTime;} - Real getDrawTime(void) {return m_curDrawTime;} - Bool doDumpUpdate(void) {return m_dumpUpdate;} - Bool doDumpDraw(void) {return m_dumpDraw;} - static Real getTotalTime(void) {return s_msConsumed;} - static void clearTotalTime(void) {s_msConsumed = 0;} -protected: - static Real s_msConsumed; - Real m_startTimeConsumed; - Real m_curUpdateTime; - - Real m_startDrawTimeConsumed; - Real m_curDrawTime; - Bool m_dumpUpdate; - Bool m_dumpDraw; -#else - void UPDATE(void) {update();} - void DRAW(void) {draw();} -#endif -protected: - AsciiString m_name; -public: - AsciiString getName(void) {return m_name;} - void setName(AsciiString name) {m_name = name;} - -}; - -//------------------------------------------------------------------------------------------------- -class SubsystemInterfaceList -{ -public: - - SubsystemInterfaceList(); - ~SubsystemInterfaceList(); - - void initSubsystem(SubsystemInterface* sys, const char* path1, const char* path2, Xfer *pXfer, AsciiString name=""); - void addSubsystem(SubsystemInterface* sys); - void removeSubsystem(SubsystemInterface* sys); - void postProcessLoadAll(); - void resetAll(); - void shutdownAll(); -#ifdef DUMP_PERF_STATS - AsciiString dumpTimesForAll(); -#endif - -private: - - typedef std::vector SubsystemList; - SubsystemList m_subsystems; - SubsystemList m_allSubsystems; - -}; - -extern SubsystemInterfaceList* TheSubsystemList; diff --git a/Generals/Code/GameEngine/Include/Common/ThingSort.h b/Generals/Code/GameEngine/Include/Common/ThingSort.h index 1accc3dd499..93cdf8cfd4f 100644 --- a/Generals/Code/GameEngine/Include/Common/ThingSort.h +++ b/Generals/Code/GameEngine/Include/Common/ThingSort.h @@ -29,7 +29,7 @@ #pragma once -#include "GameCommon.h" +#include "Common/GameCommon.h" //------------------------------------------------------------------------------------------------- enum EditorSortingType CPP_11(: Int) diff --git a/Generals/Code/GameEngine/Include/GameClient/ChallengeGenerals.h b/Generals/Code/GameEngine/Include/GameClient/ChallengeGenerals.h deleted file mode 100644 index 09d9ba2ebb7..00000000000 --- a/Generals/Code/GameEngine/Include/GameClient/ChallengeGenerals.h +++ /dev/null @@ -1,155 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: ChallengeGenerals.h ////////////////////////////////////////////////////////////////////// -// Author: Steve Copeland, 6/24/2003 -// Desc: This is a manager for data pertaining to the Generals' Challenge personas and related GUI. -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#pragma once - -// INCLUDES ////////////////////////////////////////////////////////////////////////////////// -#include "Common/GameType.h" -#include "Common/INI.h" -#include "Common/Overridable.h" - -// DEFINES //////////////////////////////////////////////////////////////////////////////////////// -//static const Int NUM_GENERALS = 12; // ChallengeMenu.wnd dependent -#define NUM_GENERALS (12) - -// FORWARD REFERENCES ///////////////////////////////////////////////////////////////////////////// -class Image; - -// CLASS DEFINITIONS ////////////////////////////////////////////////////////////////////////////// -class GeneralPersona -{ - friend class ChallengeGenerals; - -private: - Bool m_bStartsEnabled; - AsciiString m_strBioName; - AsciiString m_strBioDOB; - AsciiString m_strBioBirthplace; - AsciiString m_strBioStrategy; - AsciiString m_strBioRank; - AsciiString m_strBioBranch; - AsciiString m_strBioClassNumber; - Image *m_imageBioPortraitSmall; - Image *m_imageBioPortraitLarge; - AsciiString m_strCampaign; - AsciiString m_strPlayerTemplateName; - AsciiString m_strPortraitMovieLeftName; - AsciiString m_strPortraitMovieRightName; - Image *m_imageDefeated; - Image *m_imageVictorious; - AsciiString m_strDefeated; - AsciiString m_strVictorious; - AsciiString m_strSelectionSound; - AsciiString m_strTauntSound1; - AsciiString m_strTauntSound2; - AsciiString m_strTauntSound3; - AsciiString m_strWinSound; - AsciiString m_strLossSound; - AsciiString m_strPreviewSound; - AsciiString m_strNameSound ; - - -public: - GeneralPersona( void ) : - m_imageBioPortraitSmall(nullptr), - m_imageBioPortraitLarge(nullptr) - { - } -// ~GeneralPersona( void ); - - Bool isStartingEnabled() const { return m_bStartsEnabled; } - const AsciiString& getBioName() const { return m_strBioName; } - const AsciiString& getBioDOB() const { return m_strBioDOB; } - const AsciiString& getBioBirthplace() const { return m_strBioBirthplace; } - const AsciiString& getBioStrategy() const { return m_strBioStrategy; } - const AsciiString& getBioRank() const { return m_strBioRank; } - const AsciiString& getBioClassNumber() const { return m_strBioClassNumber; } - const AsciiString& getBioBranch() const { return m_strBioBranch; } - const Image *getBioPortraitSmall() const { return m_imageBioPortraitSmall; } - const Image *getBioPortraitLarge() const { return m_imageBioPortraitLarge; } - const AsciiString& getPortraitMovieLeftName() const { return m_strPortraitMovieLeftName; } - const AsciiString& getPortraitMovieRightName() const { return m_strPortraitMovieRightName; } - const AsciiString& getCampaign() const { return m_strCampaign; } - const AsciiString& getPlayerTemplateName() const { return m_strPlayerTemplateName; } // template name, as parsed in from ini - const Image *getImageDefeated() const { return m_imageDefeated; } - const Image *getImageVictorious() const { return m_imageVictorious; } - const AsciiString& getStringDefeated() const { return m_strDefeated; } - const AsciiString& getStringVictorious() const { return m_strVictorious; } - const AsciiString& getSelectionSound() const { return m_strSelectionSound; } - const AsciiString& getRandomTauntSound() const { - switch (rand()%3) // don't care about distribution or exactly how random this is - { - case 0: return m_strTauntSound1; - case 1: return m_strTauntSound2; - } - return m_strTauntSound3; - } - const AsciiString& getWinSound() const { return m_strWinSound; } - const AsciiString& getLossSound() const { return m_strLossSound; } - const AsciiString& getPreviewSound() const { return m_strPreviewSound; } - const AsciiString& getNameSound() const { return m_strNameSound; } -}; - - -class ChallengeGenerals -{ - -private: - /*const*/ GeneralPersona m_position[ NUM_GENERALS ]; - Int m_PlayerTemplateNum; // the template number as ThePlayerTemplateStore has it - GameDifficulty m_currentDifficulty; // the last selected game difficulty for the challenge generals - - static void parseGeneralPersona( INI* ini, void *instance, void *store, const void *userData ); - -public: - ChallengeGenerals( void ); - ~ChallengeGenerals( void ); - - void init( void ); - const GeneralPersona* getChallengeGenerals() const { return m_position; } - const FieldParse* getFieldParse( void ) const { return s_fieldParseTable; } // for INI file parsing - const GeneralPersona* getPlayerGeneralByCampaignName( AsciiString name ) const; - const GeneralPersona* getGeneralByGeneralName( AsciiString name ) const; - const GeneralPersona* getGeneralByTemplateName( AsciiString name ) const; - - void setCurrentPlayerTemplateNum( Int playerTemplateNum) { m_PlayerTemplateNum = playerTemplateNum; } - Int getCurrentPlayerTemplateNum( void ) { return m_PlayerTemplateNum; } - - void setCurrentDifficulty( GameDifficulty diff ) { m_currentDifficulty = diff; } - GameDifficulty getCurrentDifficulty( void ) { return m_currentDifficulty; } -protected: - static const FieldParse s_fieldParseTable[]; - -}; - - - -// EXTERNALS ////////////////////////////////////////////////////////////////////////////////////// -extern ChallengeGenerals *TheChallengeGenerals; -extern ChallengeGenerals *createChallengeGenerals( void ); diff --git a/Generals/Code/GameEngine/Source/Common/INI/INI.cpp b/Generals/Code/GameEngine/Source/Common/INI/INI.cpp deleted file mode 100644 index 1d941426b5f..00000000000 --- a/Generals/Code/GameEngine/Source/Common/INI/INI.cpp +++ /dev/null @@ -1,2000 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: INI.cpp ////////////////////////////////////////////////////////////////////////////////// -// Author: Colin Day, November 2001 -// Desc: INI Reader -/////////////////////////////////////////////////////////////////////////////////////////////////// - -// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine -#define DEFINE_DEATH_NAMES - -#include "Common/INI.h" -#include "Common/INIException.h" - -#include "Common/DamageFX.h" -#include "Common/file.h" -#include "Common/FileSystem.h" -#include "Common/GameAudio.h" -#include "Common/Science.h" -#include "Common/SpecialPower.h" -#include "Common/ThingFactory.h" -#include "Common/ThingTemplate.h" -#include "Common/Upgrade.h" -#include "Common/Xfer.h" -#include "Common/XferCRC.h" - -#include "GameClient/Anim2D.h" -#include "GameClient/Color.h" -#include "GameClient/FXList.h" -#include "GameClient/GameText.h" -#include "GameClient/Image.h" -#include "GameClient/ParticleSys.h" -#include "GameLogic/Armor.h" -#include "GameLogic/ExperienceTracker.h" -#include "GameLogic/FPUControl.h" -#include "GameLogic/ObjectCreationList.h" -#include "GameLogic/ScriptEngine.h" -#include "GameLogic/Weapon.h" - - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// PRIVATE DATA /////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// - -static Xfer *s_xfer = nullptr; - -//------------------------------------------------------------------------------------------------- -/** This is the table of data types we can have in INI files. To add a new data type - * block make a new entry in this table and add an appropriate parsing function */ -//------------------------------------------------------------------------------------------------- -extern void parseReallyLowMHz( INI* ini); // yeah, so sue me (srj) -struct BlockParse -{ - const char *token; - INIBlockParse parse; -}; -static const BlockParse theTypeTable[] = -{ - { "AIData", INI::parseAIDataDefinition }, - { "Animation", INI::parseAnim2DDefinition }, - { "Armor", INI::parseArmorDefinition }, - { "AudioEvent", INI::parseAudioEventDefinition }, - { "AudioSettings", INI::parseAudioSettingsDefinition }, - { "Bridge", INI::parseTerrainBridgeDefinition }, - { "Campaign", INI::parseCampaignDefinition }, - { "ChallengeGenerals", INI::parseChallengeModeDefinition }, - { "CommandButton", INI::parseCommandButtonDefinition }, - { "CommandMap", INI::parseMetaMapDefinition }, - { "CommandSet", INI::parseCommandSetDefinition }, - { "ControlBarScheme", INI::parseControlBarSchemeDefinition }, - { "ControlBarResizer", INI::parseControlBarResizerDefinition }, - { "CrateData", INI::parseCrateTemplateDefinition }, - { "Credits", INI::parseCredits}, - { "WindowTransition", INI::parseWindowTransitions}, - { "DamageFX", INI::parseDamageFXDefinition }, - { "DialogEvent", INI::parseDialogDefinition }, - { "DrawGroupInfo", INI::parseDrawGroupNumberDefinition }, - { "EvaEvent", INI::parseEvaEvent }, - { "FXList", INI::parseFXListDefinition }, - { "GameData", INI::parseGameDataDefinition }, - { "InGameUI", INI::parseInGameUIDefinition }, - { "Locomotor", INI::parseLocomotorTemplateDefinition }, - { "Language", INI::parseLanguageDefinition }, - { "MapCache", INI::parseMapCacheDefinition }, - { "MapData", INI::parseMapDataDefinition }, - { "MappedImage", INI::parseMappedImageDefinition }, - { "MiscAudio", INI::parseMiscAudio}, - { "Mouse", INI::parseMouseDefinition }, - { "MouseCursor", INI::parseMouseCursorDefinition }, - { "MultiplayerColor", INI::parseMultiplayerColorDefinition }, - { "MultiplayerStartingMoneyChoice", INI::parseMultiplayerStartingMoneyChoiceDefinition }, - { "OnlineChatColors", INI::parseOnlineChatColorDefinition }, - { "MultiplayerSettings",INI::parseMultiplayerSettingsDefinition }, - { "MusicTrack", INI::parseMusicTrackDefinition }, - { "Object", INI::parseObjectDefinition }, - { "ObjectCreationList", INI::parseObjectCreationListDefinition }, - { "ObjectReskin", INI::parseObjectReskinDefinition }, - { "ParticleSystem", INI::parseParticleSystemDefinition }, - { "PlayerTemplate", INI::parsePlayerTemplateDefinition }, - { "Road", INI::parseTerrainRoadDefinition }, - { "Science", INI::parseScienceDefinition }, - { "Rank", INI::parseRankDefinition }, - { "SpecialPower", INI::parseSpecialPowerDefinition }, - { "ShellMenuScheme", INI::parseShellMenuSchemeDefinition }, - { "Terrain", INI::parseTerrainDefinition }, - { "Upgrade", INI::parseUpgradeDefinition }, - { "Video", INI::parseVideoDefinition }, - { "WaterSet", INI::parseWaterSettingDefinition }, - { "WaterTransparency", INI::parseWaterTransparencyDefinition}, - { "Weather", INI::parseWeatherDefinition}, - { "Weapon", INI::parseWeaponTemplateDefinition }, - { "WebpageURL", INI::parseWebpageURLDefinition }, - { "HeaderTemplate", INI::parseHeaderTemplateDefinition }, - { "StaticGameLOD", INI::parseStaticGameLODDefinition }, - { "DynamicGameLOD", INI::parseDynamicGameLODDefinition }, - { "LODPreset", INI::parseLODPreset }, - { "BenchProfile", INI::parseBenchProfile }, - { "ReallyLowMHz", parseReallyLowMHz }, - { "ScriptAction", ScriptEngine::parseScriptAction }, - { "ScriptCondition", ScriptEngine::parseScriptCondition }, - - { nullptr, nullptr }, -}; - - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// PRIVATE FUNCTIONS ////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// -Bool INI::isValidINIFilename( const char *filename ) -{ - if( filename == nullptr ) - return FALSE; - - Int len = strlen( filename ); - if( len < 3 ) - return FALSE; - - if( filename[ len - 1 ] != 'I' && filename[ len - 1 ] != 'i' ) - return FALSE; - - if( filename[ len - 2 ] != 'N' && filename[ len - 2 ] != 'n' ) - return FALSE; - - if( filename[ len - 3 ] != 'I' && filename[ len - 3 ] != 'i' ) - return FALSE; - - return TRUE; - -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// PUBLIC FUNCTIONS /////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -INI::INI( void ) -{ - - m_readBuffer = nullptr; - m_readBufferNext = 0; - m_readBufferUsed = 0; - m_filename = "None"; - m_loadType = INI_LOAD_INVALID; - m_lineNum = 0; - m_seps = " \n\r\t="; ///< make sure you update m_sepsPercent/m_sepsColon as well - m_sepsPercent = " \n\r\t=%%"; - m_sepsColon = " \n\r\t=:"; - m_sepsQuote = "\"\n="; ///< stop at " = EOL - m_blockEndToken = "END"; - m_endOfFile = FALSE; - m_buffer[0] = 0; -#ifdef DEBUG_CRASHING - m_curBlockStart[0] = 0; -#endif - -} - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -INI::~INI( void ) -{ - -} - -//------------------------------------------------------------------------------------------------- -UnsignedInt INI::loadFileDirectory( AsciiString fileDirName, INILoadType loadType, Xfer *pXfer, Bool subdirs ) -{ - UnsignedInt filesRead = 0; - - AsciiString iniDir = fileDirName; - AsciiString iniFile = fileDirName; - - char ext[] = ".ini"; - - if (iniDir.endsWithNoCase(ext)) - { - iniDir.truncateBy(ARRAY_SIZE(ext)-1); - } - - if (!iniFile.endsWithNoCase(ext)) - { - iniFile.concat(ext); - } - - if (TheFileSystem->doesFileExist(iniFile.str())) - { - filesRead += load(iniFile, loadType, pXfer); - } - - // Load any additional ini files from a "filename" directory and its subdirectories. - filesRead += loadDirectory(iniDir, loadType, pXfer, subdirs); - - // Expect to open and load at least one file. - if (filesRead == 0) - { - throw INI_CANT_OPEN_FILE; - } - - return filesRead; -} - -//------------------------------------------------------------------------------------------------- -/** Load all INI files in the specified directory (and subdirectories if indicated). - * If we are to load subdirectories, we will load them *after* we load all the - * files in the current directory */ -//------------------------------------------------------------------------------------------------- -UnsignedInt INI::loadDirectory( AsciiString dirName, INILoadType loadType, Xfer *pXfer, Bool subdirs ) -{ - UnsignedInt filesRead = 0; - - // sanity - if( dirName.isEmpty() ) - throw INI_INVALID_DIRECTORY; - - try - { - FilenameList filenameList; - dirName.concat('\\'); - TheFileSystem->getFileListInDirectory(dirName, "*.ini", filenameList, subdirs); - // Load the INI files in the dir now, in a sorted order. This keeps things the same between machines - // in a network game. - FilenameList::const_iterator it = filenameList.begin(); - while (it != filenameList.end()) - { - AsciiString tempname; - tempname = (*it).str() + dirName.getLength(); - - if ((tempname.find('\\') == nullptr) && (tempname.find('/') == nullptr)) { - // this file doesn't reside in a subdirectory, load it first. - filesRead += load( *it, loadType, pXfer ); - } - ++it; - } - - it = filenameList.begin(); - while (it != filenameList.end()) - { - AsciiString tempname; - tempname = (*it).str() + dirName.getLength(); - - if ((tempname.find('\\') != nullptr) || (tempname.find('/') != nullptr)) { - filesRead += load( *it, loadType, pXfer ); - } - ++it; - } - } - catch (...) - { - // propagate the exception - throw; - } - - return filesRead; -} - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -void INI::prepFile( AsciiString filename, INILoadType loadType ) -{ - // if we have a file open already -- we can't do another one - if( m_readBuffer != nullptr ) - { - - DEBUG_CRASH(( "INI::load, cannot open file '%s', file already open", filename.str() )); - throw INI_FILE_ALREADY_OPEN; - - } - - // open the file - File* file = TheFileSystem->openFile(filename.str(), File::READ); - if( file == nullptr ) - { - - DEBUG_CRASH(( "INI::load, cannot open file '%s'", filename.str() )); - throw INI_CANT_OPEN_FILE; - - } - - m_readBufferNext = 0; - m_readBufferUsed = file->size(); - m_readBuffer = file->readEntireAndClose(); - - // save our filename - m_filename = filename; - - // save our load type - m_loadType = loadType; -} - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -void INI::unPrepFile() -{ - // delete the buffer - delete[] m_readBuffer; - m_readBuffer = nullptr; - m_readBufferNext = 0; - m_readBufferUsed = 0; - - m_filename = "None"; - m_loadType = INI_LOAD_INVALID; - m_lineNum = 0; - m_endOfFile = FALSE; - s_xfer = nullptr; -} - -//------------------------------------------------------------------------------------------------- -static INIBlockParse findBlockParse(const char* token) -{ - for (const BlockParse* parse = theTypeTable; parse->token; ++parse) - { - if (strcmp( parse->token, token ) == 0) - { - return parse->parse; - } - } - return nullptr; -} - -//------------------------------------------------------------------------------------------------- -static INIFieldParseProc findFieldParse(const FieldParse* parseTable, const char* token, int& offset, const void*& userData) -{ - const FieldParse* parse = parseTable; - for (; parse->token; ++parse) - { - if (strcmp( parse->token, token ) == 0) - { - offset = parse->offset; - userData = parse->userData; - return parse->parse; - } - } - - if (!parse->token && parse->parse) - { - offset = parse->offset; - userData = token; - return parse->parse; - } - else - { - return nullptr; - } -} - -//------------------------------------------------------------------------------------------------- -/** Load and parse an INI file */ -//------------------------------------------------------------------------------------------------- -UnsignedInt INI::load( AsciiString filename, INILoadType loadType, Xfer *pXfer ) -{ - setFPMode(); // so we have consistent Real values for GameLogic -MDC - - s_xfer = pXfer; - prepFile(filename, loadType); - - try - { - - // read all lines in the file - DEBUG_ASSERTCRASH( m_endOfFile == FALSE, ("INI::load, EOF at the beginning!") ); - while( m_endOfFile == FALSE ) - { - // read this line - readLine(); - - AsciiString currentLine = m_buffer; - - // the first word is the type of data we're processing - const char *token = strtok( m_buffer, m_seps ); - if( token ) - { - INIBlockParse parse = findBlockParse(token); - if (parse) - { - #ifdef DEBUG_CRASHING - static_assert(ARRAY_SIZE(m_curBlockStart) >= ARRAY_SIZE(m_buffer), "Incorrect array size"); - strcpy(m_curBlockStart, m_buffer); - #endif - try { - (*parse)( this ); - - } catch (...) { - DEBUG_CRASH(("Error parsing block '%s' in INI file '%s'", token, m_filename.str()) ); - char buff[1024]; - sprintf(buff, "Error parsing INI file '%s' (Line: '%s')\n", m_filename.str(), currentLine.str()); - - throw INIException(buff); - } - #ifdef DEBUG_CRASHING - strcpy(m_curBlockStart, "NO_BLOCK"); - #endif - } - else - { - DEBUG_ASSERTCRASH( 0, ("[LINE: %d - FILE: '%s'] Unknown block '%s'", - getLineNum(), getFilename().str(), token ) ); - throw INI_UNKNOWN_TOKEN; - } - - } - - } - } - catch (...) - { - unPrepFile(); - - // propagate the exception. - throw; - } - - unPrepFile(); - - return 1; -} - -//------------------------------------------------------------------------------------------------- -/** Read a line from the already open file. Any comments will be removed and - * therefore ignored from any given line - * - * TheSuperHackers @performance xezon 18/01/2026 The file contents are now read directly from a - * full File Ram buffer into the INI Line Buffer without a third buffer in between. - */ -//------------------------------------------------------------------------------------------------- -void INI::readLine( void ) -{ - // sanity - DEBUG_ASSERTCRASH( m_readBuffer, ("readLine(), read buffer is null") ); - - if (m_endOfFile) - { - *m_buffer = 0; - } - else - { - // read up till the newline or semicolon character, or until out of space - char *p = m_buffer; - while (p != m_buffer+INI_MAX_CHARS_PER_LINE) - { - // test end of read buffer - if (m_readBufferNext==m_readBufferUsed) - { - m_endOfFile = true; - *p = 0; - break; - } - - // get next character - *p = m_readBuffer[m_readBufferNext++]; - - // check for new line - if (*p == '\n') - { - *p = 0; - break; - } - - DEBUG_ASSERTCRASH(*p != '\t', ("tab characters are not allowed in INI files (%s). please check your editor settings. Line Number %d", m_filename.str(), getLineNum())); - - // if this is a semicolon, that represents the start of a comment - if (*p == ';') - { - *p = 0; - } - - // make whitespace characters actual spaces - else if (*p > 0 && *p < 32) - { - *p = ' '; - } - - p++; - } - - *p = 0; - - // increase our line count - m_lineNum++; - - // check for at the max - if ( p == m_buffer+INI_MAX_CHARS_PER_LINE ) - { - DEBUG_ASSERTCRASH( 0, ("Buffer too small (%d) and was truncated, increase INI_MAX_CHARS_PER_LINE", INI_MAX_CHARS_PER_LINE) ); - } - } - - if (s_xfer) - { - s_xfer->xferUser( m_buffer, sizeof( char ) * strlen( m_buffer ) ); - //DEBUG_LOG(("Xfer val is now 0x%8.8X in %s, line %s", ((XferCRC *)s_xfer)->getCRC(), m_filename.str(), m_buffer)); - } -} - -//------------------------------------------------------------------------------------------------- -/** Parse UnsignedByte from buffer and assign at location 'store' */ -//------------------------------------------------------------------------------------------------- -void INI::parseUnsignedByte( INI* ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - const char *token = ini->getNextToken(); - Int value = scanInt(token); - if (value < 0 || value > 255) - { - DEBUG_CRASH(("Bad value INI::parseUnsignedByte")); - throw ERROR_BUG; - } - *(Byte *)store = (Byte)value; -} - -//------------------------------------------------------------------------------------------------- -/** Parse signed short from buffer and assign at location 'store' */ -//------------------------------------------------------------------------------------------------- -void INI::parseShort( INI* ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - const char *token = ini->getNextToken(); - Int value = scanInt(token); - if (value < -32768 || value > 32767) - { - DEBUG_CRASH(("Bad value INI::parseShort")); - throw ERROR_BUG; - } - *(Short *)store = (Short)value; -} - -//------------------------------------------------------------------------------------------------- -/** Parse unsigned short from buffer and assign at location 'store' */ -//------------------------------------------------------------------------------------------------- -void INI::parseUnsignedShort( INI* ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - const char *token = ini->getNextToken(); - Int value = scanInt(token); - if (value < 0 || value > 65535) - { - DEBUG_CRASH(("Bad value INI::parseUnsignedShort")); - throw ERROR_BUG; - } - *(UnsignedShort *)store = (UnsignedShort)value; -} - -//------------------------------------------------------------------------------------------------- -/** Parse integer from buffer and assign at location 'store' */ -//------------------------------------------------------------------------------------------------- -void INI::parseInt( INI* ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - const char *token = ini->getNextToken(); - *(Int *)store = scanInt(token); - -} - -//------------------------------------------------------------------------------------------------- -/** Parse unsigned integer from buffer and assign at location 'store' */ -//------------------------------------------------------------------------------------------------- -void INI::parseUnsignedInt( INI* ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - const char *token = ini->getNextToken(); - *(UnsignedInt *)store = scanUnsignedInt(token); - -} - -//------------------------------------------------------------------------------------------------- -/** Parse real from buffer and assign at location 'store' */ -//------------------------------------------------------------------------------------------------- -void INI::parseReal( INI* ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - const char *token = ini->getNextToken(); - *(Real *)store = scanReal(token); - -} - -//------------------------------------------------------------------------------------------------- -/** Parse real from buffer and assign at location 'store' */ -//------------------------------------------------------------------------------------------------- -void INI::parsePositiveNonZeroReal( INI* ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - const char *token = ini->getNextToken(); - *(Real *)store = scanReal(token); - if (*(Real *)store <= 0.0f) - { - DEBUG_CRASH(("invalid Real value %f -- expected > 0",*(Real*)store)); - throw INI_INVALID_DATA; - } - -} - -//------------------------------------------------------------------------------------------------- -/** Parse a degree value (0 to 360) and store the radian value of that degree - * in a Real */ -//------------------------------------------------------------------------------------------------- -void INI::parseAngleReal( INI *ini, void * /*instance*/, - void *store, const void *userData ) -{ - const char *token = ini->getNextToken(); - - const Real RADS_PER_DEGREE = PI / 180.0f; - *(Real *)store = scanReal( token ) * RADS_PER_DEGREE; - -} - -//------------------------------------------------------------------------------------------------- -/** Parse an angular velocity in degrees-per-sec and store the rads-per-frame value of that degree - * in a Real */ -//------------------------------------------------------------------------------------------------- -void INI::parseAngularVelocityReal( INI *ini, void * /*instance*/, - void *store, const void *userData ) -{ - const char *token = ini->getNextToken(); - - // scan the int and convert to radian and store as a real - *(Real *)store = ConvertAngularVelocityInDegreesPerSecToRadsPerFrame(scanReal( token )); - -} - -//------------------------------------------------------------------------------------------------- -/** Parse Bool from buffer and assign at location 'store'. The buffer token must - * be in the form of a string "Yes" or "No" (case is ignored) */ -//------------------------------------------------------------------------------------------------- -void INI::parseBool( INI* ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - *(Bool*)store = INI::scanBool(ini->getNextToken()); -} - -//------------------------------------------------------------------------------------------------- -/** Parse Bool from buffer; if true, or in MASK, otherwise and out MASK. The buffer token must - * be in the form of a string "Yes" or "No" (case is ignored) */ -//------------------------------------------------------------------------------------------------- -void INI::parseBitInInt32( INI *ini, void *instance, void *store, const void* userData ) -{ - UnsignedInt* s = (UnsignedInt*)store; - UnsignedInt mask = (UnsignedInt)userData; - - if (INI::scanBool(ini->getNextToken())) - *s |= mask; - else - *s &= ~mask; -} - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -/*static*/ Bool INI::scanBool(const char* token) -{ - // translate string yes/no into TRUE/FALSE - if( stricmp( token, "yes" ) == 0 ) - return TRUE; - else if( stricmp( token, "no" ) == 0 ) - return FALSE; - else - { - DEBUG_CRASH(("invalid boolean token %s -- expected Yes or No",token)); - throw INI_INVALID_DATA; - return false; // keep compiler happy - } - -} - -//------------------------------------------------------------------------------------------------- -/** Parse an *ASCII* string from buffer and assign at location 'store' */ -//------------------------------------------------------------------------------------------------- -void INI::parseAsciiString( INI* ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - AsciiString* asciiString = (AsciiString *)store; - *asciiString = ini->getNextAsciiString(); -} - -//------------------------------------------------------------------------------------------------- -/** Parse an *ASCII* string from buffer and assign at location 'store'. Has better support for quoted strings. -We don't really need this function, but parseString() is broken and we want to leave it broken to -maintain existing code. - */ -//------------------------------------------------------------------------------------------------- -void INI::parseQuotedAsciiString( INI* ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - AsciiString* asciiString = (AsciiString *)store; - *asciiString = ini->getNextQuotedAsciiString(); -} - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -void INI::parseAsciiStringVector( INI* ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - std::vector* asv = (std::vector*)store; - asv->clear(); - for (const char *token = ini->getNextTokenOrNull(); token != nullptr; token = ini->getNextTokenOrNull()) - { - asv->push_back(token); - } -} - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -void INI::parseAsciiStringVectorAppend( INI* ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - std::vector* asv = (std::vector*)store; - // nope, don't clear. duh. - // asv->clear(); - for (const char *token = ini->getNextTokenOrNull(); token != nullptr; token = ini->getNextTokenOrNull()) - { - asv->push_back(token); - } -} - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -/* static */void INI::parseScienceVector( INI *ini, void * /*instance*/, void *store, const void *userData ) -{ - ScienceVec* asv = (ScienceVec*)store; - asv->clear(); - for (const char *token = ini->getNextTokenOrNull(); token != nullptr; token = ini->getNextTokenOrNull()) - { - if (stricmp(token, "None") == 0) - { - asv->clear(); - return; - } - asv->push_back(INI::scanScience( token )); - } -} - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -AsciiString INI::getNextQuotedAsciiString() -{ - AsciiString result; - char buff[INI_MAX_CHARS_PER_LINE]; - buff[0] = '\0'; - - const char *token = getNextTokenOrNull(); // if null, just leave an empty string - if (token != nullptr) - { - if (token[0] != '\"') - { - // if token is simply " - result.set( token ); // Start following the " - } - else - { int strLen=0; - Bool done=FALSE; - if ((strLen=strlen(token)) > 1) - { - strlcpy(buff, &token[1], ARRAY_SIZE(buff)); //skip the starting quote - //Check for end of quoted string. Checking here fixes cases where quoted string on same line with other data. - if (buff[strLen-2]=='"') //skip ending quote if present - { buff[strLen-2]='\0'; - done=TRUE; - } - } - - if (!done) - { - token = getNextToken(getSepsQuote()); - - if (strlen(token) > 1 && token[1] != '\t') - { - strlcat(buff, " ", ARRAY_SIZE(buff)); - strlcat(buff, token, ARRAY_SIZE(buff)); - } - else - { Int buflen=strlen(buff); - if (buff[buflen-1]=='\"') - buff[buflen-1]='\0'; - } - } - result.set(buff); - } - } - return result; -} - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -AsciiString INI::getNextAsciiString() -{ - AsciiString result; - - const char *token = getNextTokenOrNull(); // if null, just leave an empty string - if (token != nullptr) - { - if (token[0] != '\"') - { - // if token is simply " - result.set( token ); // Start following the " - } - else - { - static char buff[INI_MAX_CHARS_PER_LINE]; - buff[0] = 0; - if (strlen(token) > 1) - { - strlcpy(buff, &token[1], ARRAY_SIZE(buff)); - } - - token = getNextTokenOrNull(getSepsQuote()); - if (token) { - if (strlen(token) > 1 && token[1] != '\t') - { - strlcat(buff, " ", ARRAY_SIZE(buff)); - } - strlcat(buff, token, ARRAY_SIZE(buff)); - result.set(buff); - } else { - Int len = strlen(buff); - if (len && buff[len-1] == '"') { // strip off trailing quote jba. [2/12/2003] - buff[len-1] = 0; - } - result.set(buff); - } - } - } - return result; -} - -//------------------------------------------------------------------------------------------------- -/** Parse a string label, get the *translated* actual text from the label and store - * into a *UNICODE* string. */ -//------------------------------------------------------------------------------------------------- -void INI::parseAndTranslateLabel( INI* ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - const char *token = ini->getNextToken(); - - // translate - UnicodeString translated = TheGameText->fetch( token ); - if( translated.isEmpty() ) - throw INI_INVALID_DATA; - - // save the translated text - UnicodeString *theString = (UnicodeString *)store; - theString->set( translated.str() ); - -} - -//------------------------------------------------------------------------------------------------- -/** Parse a string label assumed as an image as part of the image collection. Translate - * to an image pointer for storage */ -//------------------------------------------------------------------------------------------------- -void INI::parseMappedImage( INI *ini, void * /*instance*/, void *store, const void *userData ) -{ - const char *token = ini->getNextToken(); - - if( TheMappedImageCollection ) - { - typedef const Image* ConstImagePtr; - *(ConstImagePtr*)store = TheMappedImageCollection->findImageByName( token ); - } - - //KM: If we are in the worldbuilder, we want to parse commandbuttons for informational purposes, - //but we don't care about the images -- because we never access them. In RTS/GUIEdit, they always - //exist -- and in those cases, it will never call this code anyways because it'll throw long before. - //else - // throw INI_UNKNOWN_ERROR; - -} - -// ------------------------------------------------------------------------------------------------ -/** Parse a string label assumed as a Anim2D template name. Translate that name to an - * actual template pointer for storage */ -// ------------------------------------------------------------------------------------------------ -/*static*/ void INI::parseAnim2DTemplate( INI *ini, void *instance, void *store, const void *userData ) -{ - const char *token = ini->getNextToken(); - - if( TheAnim2DCollection ) - { - Anim2DTemplate **anim2DTemplate = (Anim2DTemplate **)store; - *anim2DTemplate = TheAnim2DCollection->findTemplate( AsciiString( token ) ); - } - else - { - - DEBUG_CRASH(( "INI::parseAnim2DTemplate - TheAnim2DCollection is null" )); - throw INI_UNKNOWN_ERROR; - - } - -} - -//------------------------------------------------------------------------------------------------- -/** Parse a percent in int or real form such as "23%" or "95.4%" and assign - * to location 'store' as a number from 0.0 to 1.0 */ -//------------------------------------------------------------------------------------------------- -void INI::parsePercentToReal( INI* ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - const char *token = ini->getNextToken(ini->getSepsPercent()); - Real *theReal = (Real *)store; - *theReal = scanPercentToReal(token); - -} - -//------------------------------------------------------------------------------------------------- -/** 'store' points to an 32 bit unsigned integer. We will zero that integer, parse each token - * in the buffer, if the token is in the userData table of strings, we will set the - * according bit flag for it */ -//------------------------------------------------------------------------------------------------- -void INI::parseBitString8( INI* ini, void * /*instance*/, void *store, const void* userData ) -{ - UnsignedInt tmp; - INI::parseBitString32(ini, nullptr, &tmp, userData); - if (tmp & 0xffffff00) - { - DEBUG_CRASH(("Bad bitstring list INI::parseBitString8")); - throw ERROR_BUG; - } - *(Byte*)store = (Byte)tmp; -} - -//------------------------------------------------------------------------------------------------- -/** 'store' points to an 32 bit unsigned integer. We will zero that integer, parse each token - * in the buffer, if the token is in the userData table of strings, we will set the - * according bit flag for it */ -//------------------------------------------------------------------------------------------------- -void INI::parseBitString32( INI* ini, void * /*instance*/, void *store, const void* userData ) -{ - ConstCharPtrArray flagList = (ConstCharPtrArray)userData; - UnsignedInt *bits = (UnsignedInt *)store; - - if( flagList == nullptr || flagList[ 0 ] == nullptr) - { - DEBUG_ASSERTCRASH( flagList, ("INTERNAL ERROR! parseBitString32: No flag list provided!") ); - throw INI_INVALID_NAME_LIST; - } - - Bool foundNormal = false; - Bool foundAddOrSub = false; - - // loop through all tokens - for (const char *token = ini->getNextTokenOrNull(); token != nullptr; token = ini->getNextTokenOrNull()) - { - if (stricmp(token, "NONE") == 0) - { - if (foundNormal || foundAddOrSub) - { - DEBUG_CRASH(("you may not mix normal and +- ops in bitstring lists")); - throw INI_INVALID_NAME_LIST; - } - *bits = 0; - break; - } - - if (token[0] == '+') - { - if (foundNormal) - { - DEBUG_CRASH(("you may not mix normal and +- ops in bitstring lists")); - throw INI_INVALID_NAME_LIST; - } - Int bitIndex = INI::scanIndexList(token+1, flagList); // this throws if the token is not found - *bits |= (1 << bitIndex); - foundAddOrSub = true; - } - else if (token[0] == '-') - { - if (foundNormal) - { - DEBUG_CRASH(("you may not mix normal and +- ops in bitstring lists")); - throw INI_INVALID_NAME_LIST; - } - Int bitIndex = INI::scanIndexList(token+1, flagList); // this throws if the token is not found - *bits &= ~(1 << bitIndex); - foundAddOrSub = true; - } - else - { - if (foundAddOrSub) - { - DEBUG_CRASH(("you may not mix normal and +- ops in bitstring lists")); - throw INI_INVALID_NAME_LIST; - } - - if (!foundNormal) - *bits = 0; - - Int bitIndex = INI::scanIndexList(token, flagList); // this throws if the token is not found - *bits |= (1 << bitIndex); - foundNormal = true; - } - } -} - -//------------------------------------------------------------------------------------------------- -/** Parse a color in the form of - * - * RGB_COLOR = R:100 G:114 B:245 - * and store in "RGBColor" structure pointed to by 'store' */ -//------------------------------------------------------------------------------------------------- -void INI::parseRGBColor( INI* ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - const char* names[3] = { "R", "G", "B" }; - Int colors[3]; - for( Int i = 0; i < 3; i++ ) - { - colors[i] = scanInt(ini->getNextSubToken(names[i])); - if( colors[ i ] < 0 ) - throw INI_INVALID_DATA; - if( colors[ i ] > 255 ) - throw INI_INVALID_DATA; - } - - // assign the color components to the "RGBColor" pointer at 'store' - RGBColor *theColor = (RGBColor *)store; - theColor->red = (Real)colors[ 0 ] / 255.0f; - theColor->green = (Real)colors[ 1 ] / 255.0f; - theColor->blue = (Real)colors[ 2 ] / 255.0f; - -} - -//------------------------------------------------------------------------------------------------- -/** Parse a color in the form of - * - * RGB_COLOR = R:100 G:114 B:245 [A:233] - * and store in "RGBAColorInt" structure pointed to by 'store' */ -//------------------------------------------------------------------------------------------------- -void INI::parseRGBAColorInt( INI* ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - const char* names[4] = { "R", "G", "B", "A" }; - Int colors[4]; - for( Int i = 0; i < 4; i++ ) - { - const char* token = ini->getNextTokenOrNull(ini->getSepsColon()); - if (token == nullptr) - { - if (i < 3) - { - throw INI_INVALID_DATA; - } - else - { - // it's ok for A to be omitted. - colors[i] = 255; - } - } - else - { - // if present, the token must match. - if (stricmp(token, names[i]) != 0) - { - throw INI_INVALID_DATA; - } - colors[i] = scanInt(ini->getNextToken(ini->getSepsColon())); - } - if( colors[ i ] < 0 ) - throw INI_INVALID_DATA; - if( colors[ i ] > 255 ) - throw INI_INVALID_DATA; - } - - // - // assign the color components to the "RGBColorInt" pointer at 'store', keep - // the numbers as between 0 and 255 - // - RGBAColorInt *theColor = (RGBAColorInt *)store; - theColor->red = colors[ 0 ]; - theColor->green = colors[ 1 ]; - theColor->blue = colors[ 2 ]; - theColor->alpha = colors[ 3 ]; - -} - -//------------------------------------------------------------------------------------------------- -/** Parse a color in the form of - * - * RGB_COLOR = R:100 G:114 B:245 [A:233] - * and store in "Color" structure pointed to by 'store' */ -//------------------------------------------------------------------------------------------------- -void INI::parseColorInt( INI* ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - const char* names[4] = { "R", "G", "B", "A" }; - Int colors[4]; - for( Int i = 0; i < 4; i++ ) - { - const char* token = ini->getNextTokenOrNull(ini->getSepsColon()); - if (token == nullptr) - { - if (i < 3) - { - throw INI_INVALID_DATA; - } - else - { - // it's ok for A to be omitted. - colors[i] = 255; - } - } - else - { - // if present, the token must match. - if (stricmp(token, names[i]) != 0) - { - throw INI_INVALID_DATA; - } - colors[i] = scanInt(ini->getNextToken(ini->getSepsColon())); - } - if( colors[ i ] < 0 ) - throw INI_INVALID_DATA; - if( colors[ i ] > 255 ) - throw INI_INVALID_DATA; - } - - // - // assign the color components to the "Color" pointer at 'store', keep - // the numbers as between 0 and 255 - // - Color *theColor = (Color *)store; - *theColor = GameMakeColor(colors[0], colors[1], colors[2], colors[3]); - -} - -//------------------------------------------------------------------------------------------------- -/** Parse a 3D coordinate of reals in the form of: - * FIELD_NAME = X:400 Y:-214.3 Z:8.6 */ -//------------------------------------------------------------------------------------------------- -void INI::parseCoord3D( INI* ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - Coord3D *theCoord = (Coord3D *)store; - - theCoord->x = scanReal(ini->getNextSubToken("X")); - theCoord->y = scanReal(ini->getNextSubToken("Y")); - theCoord->z = scanReal(ini->getNextSubToken("Z")); - -} - -//------------------------------------------------------------------------------------------------- -/** Parse a 2D coordinate of reals in the form of: - * FIELD_NAME = X:400 Y:-214.3 */ -//------------------------------------------------------------------------------------------------- -void INI::parseCoord2D( INI* ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - Coord2D *theCoord = (Coord2D *)store; - - theCoord->x = scanReal(ini->getNextSubToken("X")); - theCoord->y = scanReal(ini->getNextSubToken("Y")); - -} - -//------------------------------------------------------------------------------------------------- -/** Parse a 2D coordinate of Ints in the form of: - * FIELD_NAME = X:400 Y:-214 */ -//------------------------------------------------------------------------------------------------- -void INI::parseICoord2D( INI* ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - ICoord2D *theCoord = (ICoord2D *)store; - - theCoord->x = scanInt(ini->getNextSubToken("X")); - theCoord->y = scanInt(ini->getNextSubToken("Y")); - -} - -//------------------------------------------------------------------------------------------------- -/** Parse an audio event and assign to the 'AudioEventRTS*' at store */ -//------------------------------------------------------------------------------------------------- -void INI::parseDynamicAudioEventRTS( INI *ini, void * /*instance*/, void *store, const void* userData ) -{ - const char *token = ini->getNextToken(); - DynamicAudioEventRTS** theSound = (DynamicAudioEventRTS**)store; - - // translate the string into a sound - if (stricmp(token, "NoSound") == 0) - { - deleteInstance(*theSound); - *theSound = nullptr; - } - else - { - if (*theSound == nullptr) - *theSound = newInstance(DynamicAudioEventRTS); - (*theSound)->m_event.setEventName(AsciiString(token)); - } - - if (*theSound) - TheAudio->getInfoForAudioEvent(&(*theSound)->m_event); -} - -//------------------------------------------------------------------------------------------------- -/** Parse an audio event and assign to the 'AudioEventRTS*' at store */ -//------------------------------------------------------------------------------------------------- -void INI::parseAudioEventRTS( INI *ini, void * /*instance*/, void *store, const void* userData ) -{ - const char *token = ini->getNextToken(); - - AudioEventRTS *theSound = (AudioEventRTS*)store; - - // translate the string into a sound - if (stricmp(token, "NoSound") != 0) { - theSound->setEventName(AsciiString(token)); - } - - TheAudio->getInfoForAudioEvent(theSound); -} - -//------------------------------------------------------------------------------------------------- -/** Parse an ThingTemplate and assign to the 'ThingTemplate *' at store */ -//------------------------------------------------------------------------------------------------- -void INI::parseThingTemplate( INI* ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - const char *token = ini->getNextToken(); - - if (!TheThingFactory) - { - DEBUG_CRASH(("TheThingFactory not inited yet")); - throw ERROR_BUG; - } - - typedef const ThingTemplate *ConstThingTemplatePtr; - ConstThingTemplatePtr* theThingTemplate = (ConstThingTemplatePtr*)store; - - if (stricmp(token, "None") == 0) - { - *theThingTemplate = nullptr; - } - else - { - const ThingTemplate *tt = TheThingFactory->findTemplate(token); // could be null! - DEBUG_ASSERTCRASH(tt, ("ThingTemplate %s not found!",token)); - // assign it, even if null! - *theThingTemplate = tt; - } - -} - -//------------------------------------------------------------------------------------------------- -/** Parse an ArmorTemplate and assign to the 'ArmorTemplate *' at store */ -//------------------------------------------------------------------------------------------------- -void INI::parseArmorTemplate( INI* ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - const char *token = ini->getNextToken(); - - typedef const ArmorTemplate *ConstArmorTemplatePtr; - ConstArmorTemplatePtr* theArmorTemplate = (ConstArmorTemplatePtr*)store; - - if (stricmp(token, "None") == 0) - { - *theArmorTemplate = nullptr; - } - else - { - const ArmorTemplate *tt = TheArmorStore->findArmorTemplate(token); // could be null! - DEBUG_ASSERTCRASH(tt, ("ArmorTemplate %s not found!",token)); - // assign it, even if null! - *theArmorTemplate = tt; - } - -} - -//------------------------------------------------------------------------------------------------- -/** Parse an WeaponTemplate and assign to the 'WeaponTemplate *' at store */ -//------------------------------------------------------------------------------------------------- -void INI::parseWeaponTemplate( INI* ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - const char *token = ini->getNextToken(); - - typedef const WeaponTemplate *ConstWeaponTemplatePtr; - ConstWeaponTemplatePtr* theWeaponTemplate = (ConstWeaponTemplatePtr*)store; - - const WeaponTemplate *tt = TheWeaponStore->findWeaponTemplate(token); // could be null! - DEBUG_ASSERTCRASH(tt || stricmp(token, "None") == 0, ("WeaponTemplate %s not found!",token)); - // assign it, even if null! - *theWeaponTemplate = tt; - -} - -//------------------------------------------------------------------------------------------------- -/** Parse an FXList and assign to the 'FXList *' at store */ -//------------------------------------------------------------------------------------------------- -void INI::parseFXList( INI* ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - const char *token = ini->getNextToken(); - - typedef const FXList *ConstFXListPtr; - ConstFXListPtr* theFXList = (ConstFXListPtr*)store; - - const FXList *fxl = TheFXListStore->findFXList(token); // could be null! - DEBUG_ASSERTCRASH(fxl != nullptr || stricmp(token, "None") == 0, ("FXList %s not found!",token)); - // assign it, even if null! - *theFXList = fxl; - -} - -//------------------------------------------------------------------------------------------------- -/** Parse a particle system and assign to 'ParticleSystemTemplate *' at store */ -//------------------------------------------------------------------------------------------------- -void INI::parseParticleSystemTemplate( INI *ini, void * /*instance*/, void *store, const void *userData ) -{ - const char *token = ini->getNextToken(); - - const ParticleSystemTemplate *pSystemT = TheParticleSystemManager->findTemplate( AsciiString( token ) ); - DEBUG_ASSERTCRASH( pSystemT || stricmp( token, "None" ) == 0, ("ParticleSystem %s not found!",token) ); - - typedef const ParticleSystemTemplate* ConstParticleSystemTemplatePtr; - ConstParticleSystemTemplatePtr* theParticleSystemTemplate = (ConstParticleSystemTemplatePtr*)store; - - *theParticleSystemTemplate = pSystemT; - -} - -//------------------------------------------------------------------------------------------------- -/** Parse an DamageFX and assign to the 'DamageFX *' at store */ -//------------------------------------------------------------------------------------------------- -void INI::parseDamageFX( INI* ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - const char *token = ini->getNextToken(); - - typedef const DamageFX *ConstDamageFXPtr; - ConstDamageFXPtr* theDamageFX = (ConstDamageFXPtr*)store; - - if (stricmp(token, "None") == 0) - { - *theDamageFX = nullptr; - } - else - { - const DamageFX *fxl = TheDamageFXStore->findDamageFX(token); // could be null! - DEBUG_ASSERTCRASH(fxl, ("DamageFX %s not found!",token)); - // assign it, even if null! - *theDamageFX = fxl; - } - -} - -//------------------------------------------------------------------------------------------------- -/** Parse an ObjectCreationList and assign to the 'ObjectCreationList *' at store */ -//------------------------------------------------------------------------------------------------- -void INI::parseObjectCreationList( INI* ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - const char *token = ini->getNextToken(); - - typedef const ObjectCreationList *ConstObjectCreationListPtr; - ConstObjectCreationListPtr* theObjectCreationList = (ConstObjectCreationListPtr*)store; - - const ObjectCreationList *ocl = TheObjectCreationListStore->findObjectCreationList(token); // could be null! - DEBUG_ASSERTCRASH(ocl || stricmp(token, "None") == 0, ("ObjectCreationList %s not found!",token)); - // assign it, even if null! - *theObjectCreationList = ocl; - -} - -//------------------------------------------------------------------------------------------------- -/** Parse a upgrade template string and store as template pointer */ -//------------------------------------------------------------------------------------------------- -void INI::parseUpgradeTemplate( INI* ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - const char *token = ini->getNextToken(); - - if (!TheUpgradeCenter) - { - DEBUG_CRASH(("TheUpgradeCenter not inited yet")); - throw ERROR_BUG; - } - - const UpgradeTemplate *uu = TheUpgradeCenter->findUpgrade( token ); - DEBUG_ASSERTCRASH( uu || stricmp( token, "None" ) == 0, ("Upgrade %s not found!",token) ); - - typedef const UpgradeTemplate* ConstUpgradeTemplatePtr; - ConstUpgradeTemplatePtr* theUpgradeTemplate = (ConstUpgradeTemplatePtr *)store; - *theUpgradeTemplate = uu; -} - -//------------------------------------------------------------------------------------------------- -/** Parse a special power template string and store as template pointer */ -//------------------------------------------------------------------------------------------------- -void INI::parseSpecialPowerTemplate( INI* ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - const char *token = ini->getNextToken(); - - if (!TheSpecialPowerStore) - { - DEBUG_CRASH(("TheSpecialPowerStore not inited yet")); - throw ERROR_BUG; - } - - const SpecialPowerTemplate *sPowerT = TheSpecialPowerStore->findSpecialPowerTemplate( AsciiString( token ) ); - if( !sPowerT && stricmp( token, "None" ) != 0 ) - { - DEBUG_CRASH( ("[LINE: %d in '%s'] Specialpower %s not found!", ini->getLineNum(), ini->getFilename().str(), token) ); - } - - typedef const SpecialPowerTemplate* ConstSpecialPowerTemplatePtr; - ConstSpecialPowerTemplatePtr* theSpecialPowerTemplate = (ConstSpecialPowerTemplatePtr *)store; - *theSpecialPowerTemplate = sPowerT; -} - -//------------------------------------------------------------------------------------------------- -/** Parse a science string and store as science type */ -//------------------------------------------------------------------------------------------------- -/* static */void INI::parseScience( INI *ini, void * /*instance*/, void *store, const void *userData ) -{ - const char *token = ini->getNextToken(); - - if (!TheScienceStore) - { - DEBUG_CRASH(("TheScienceStore not inited yet")); - throw ERROR_BUG; - } - - *((ScienceType *)store) = INI::scanScience(token); - -} - -//------------------------------------------------------------------------------------------------- -/** Parse a single string token, check for that token in the index list - * of names provided and store the index into that list. - * - * NOTE: Is is assumed that we are going to store the index into - * a 4 byte integer. This works well for INT and ENUM definitions */ -//------------------------------------------------------------------------------------------------- -void INI::parseIndexList( INI* ini, void * /*instance*/, void *store, const void* userData ) -{ - ConstCharPtrArray nameList = (ConstCharPtrArray)userData; - *(Int *)store = scanIndexList(ini->getNextToken(), nameList); -} - -//------------------------------------------------------------------------------------------------- -/** Parse a single string token, check for that token in the index list - * of names provided and store the index into that list. - * - * NOTE: Is is assumed that we are going to store the index into - * a 4 byte integer. This works well for INT and ENUM definitions */ -//------------------------------------------------------------------------------------------------- -void INI::parseByteSizedIndexList( INI* ini, void * /*instance*/, void *store, const void* userData ) -{ - ConstCharPtrArray nameList = (ConstCharPtrArray)userData; - Int value = scanIndexList(ini->getNextToken(), nameList); - if (value < 0 || value > 255) - { - DEBUG_CRASH(("Bad index list INI::parseByteSizedIndexList")); - throw ERROR_BUG; - } - *(Byte *)store = (Byte)value; -} - -//------------------------------------------------------------------------------------------------- -/** Parse a single string token, check for that token in the index list - * of names provided and store the associated value into that list. - * - * NOTE: Is is assumed that we are going to store the index into - * a 4 byte integer. This works well for INT and ENUM definitions */ -//------------------------------------------------------------------------------------------------- -void INI::parseLookupList( INI* ini, void * /*instance*/, void *store, const void* userData ) -{ - ConstLookupListRecArray lookupList = (ConstLookupListRecArray)userData; - *(Int *)store = scanLookupList(ini->getNextToken(), lookupList); -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// PRIVATE FUNCTIONS ////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// - - -//------------------------------------------------------------------------------------------------- -void MultiIniFieldParse::add(const FieldParse* f, UnsignedInt e) -{ - if (m_count < MAX_MULTI_FIELDS) - { - m_fieldParse[m_count] = f; - m_extraOffset[m_count] = e; - ++m_count; - } - else - { - DEBUG_CRASH(("too many multi-fields in INI::initFromINIMultiProc")); - throw ERROR_BUG; - } -} - -//------------------------------------------------------------------------------------------------- -void INI::initFromINI( void *what, const FieldParse* parseTable ) -{ - MultiIniFieldParse p; - p.add(parseTable); - initFromINIMulti(what, p); -} - -//------------------------------------------------------------------------------------------------- -void INI::initFromINIMultiProc( void *what, BuildMultiIniFieldProc proc ) -{ - MultiIniFieldParse p; - (*proc)(p); - initFromINIMulti(what, p); -} - -//------------------------------------------------------------------------------------------------- -void INI::initFromINIMulti( void *what, const MultiIniFieldParse& parseTableList ) -{ - Bool done = FALSE; - - if( what == nullptr ) - { - DEBUG_ASSERTCRASH( 0, ("INI::initFromINI - Invalid parameters supplied!") ); - throw INI_INVALID_PARAMS; - } - - // read each of the data fields - while( !done ) - { - - // read next line - readLine(); - - // check for end token - const char* field = strtok( m_buffer, INI::getSeps() ); - if( field ) - { - - if( stricmp( field, m_blockEndToken ) == 0 ) - { - done = TRUE; - } - else - { - Bool found = false; - for (int ptIdx = 0; ptIdx < parseTableList.getCount(); ++ptIdx) - { - int offset = 0; - const void* userData = nullptr; - INIFieldParseProc parse = findFieldParse(parseTableList.getNthFieldParse(ptIdx), field, offset, userData); - if (parse) - { - // parse this block and check for parse errors - try { - - (*parse)( this, what, (char *)what + offset + parseTableList.getNthExtraOffset(ptIdx), userData ); - - } catch (...) { - DEBUG_CRASH( ("[LINE: %d - FILE: '%s'] Error reading field '%s' of block '%s'", - INI::getLineNum(), INI::getFilename().str(), field, m_curBlockStart) ); - - - char buff[1024]; - sprintf(buff, "[LINE: %d - FILE: '%s'] Error reading field '%s'\n", INI::getLineNum(), INI::getFilename().str(), field); - throw INIException(buff); - } - - found = true; - break; - - } - } - - if (!found) - { - DEBUG_ASSERTCRASH( 0, ("[LINE: %d - FILE: '%s'] Unknown field '%s' in block '%s'", - INI::getLineNum(), INI::getFilename().str(), field, m_curBlockStart) ); - } - - } - - } - - // sanity check for reaching end of file with no closing end token - if( done == FALSE && INI::isEOF() == TRUE ) - { - - done = TRUE; - DEBUG_ASSERTCRASH( 0, ("Error parsing block '%s', in INI file '%s'. Missing '%s' token", - m_curBlockStart, getFilename().str(), m_blockEndToken) ); - throw INI_MISSING_END_TOKEN; - - } - - } - -} - -//------------------------------------------------------------------------------------------------- -/*static*/ const char* INI::getNextToken(const char* seps) -{ - if (!seps) seps = getSeps(); - const char *token = ::strtok(nullptr, seps); - if (!token) - throw INI_INVALID_DATA; - return token; -} - -//------------------------------------------------------------------------------------------------- -/*static*/ const char* INI::getNextTokenOrNull(const char* seps) -{ - if (!seps) seps = getSeps(); - const char *token = ::strtok(nullptr, seps); - return token; -} - -//------------------------------------------------------------------------------------------------- -/*static*/ ScienceType INI::scanScience(const char* token) -{ - return TheScienceStore->friend_lookupScience( token ); -} - -//------------------------------------------------------------------------------------------------- -/*static*/ Int INI::scanInt(const char* token) -{ - Int value; - if (sscanf( token, "%d", &value ) != 1) - throw INI_INVALID_DATA; - return value; -} - -//------------------------------------------------------------------------------------------------- -/*static*/ UnsignedInt INI::scanUnsignedInt(const char* token) -{ - UnsignedInt value; - if (sscanf( token, "%u", &value ) != 1) // unsigned int is %u, not %d - throw INI_INVALID_DATA; - return value; -} - -//------------------------------------------------------------------------------------------------- -/*static*/ Real INI::scanReal(const char* token) -{ - Real value; - if (sscanf( token, "%f", &value ) != 1) - throw INI_INVALID_DATA; - return value; -} - -//------------------------------------------------------------------------------------------------- -/*static*/ Real INI::scanPercentToReal(const char* token) -{ - Real value; - if (sscanf( token, "%f", &value ) != 1) - throw INI_INVALID_DATA; - return value / 100.0f; -} - -//------------------------------------------------------------------------------------------------- -/*static*/ Int INI::scanIndexList(const char* token, ConstCharPtrArray nameList) -{ - if( nameList == nullptr || nameList[ 0 ] == nullptr ) - { - - DEBUG_ASSERTCRASH( 0, ("INTERNAL ERROR! scanIndexList, invalid name list") ); - throw INI_INVALID_NAME_LIST; - - } - - // search for matching name - Int count = 0; - for(ConstCharPtrArray name = nameList; *name; name++, count++ ) - { - if( stricmp( *name, token ) == 0 ) - { - return count; - } - } - - DEBUG_CRASH(("token %s is not a valid member of the index list",token)); - throw INI_INVALID_DATA; - return 0; // never executed, but keeps compiler happy - -} -//------------------------------------------------------------------------------------------------- -/*static*/ Int INI::scanLookupList(const char* token, ConstLookupListRecArray lookupList) -{ - if( lookupList == nullptr || lookupList[ 0 ].name == nullptr ) - { - DEBUG_ASSERTCRASH( 0, ("INTERNAL ERROR! scanLookupList, invalid name list") ); - throw INI_INVALID_NAME_LIST; - } - - // search for matching name - Bool found = false; - for( const LookupListRec* lookup = &lookupList[0]; lookup->name; lookup++ ) - { - if( stricmp( lookup->name, token ) == 0 ) - { - return lookup->value; - found = true; - break; - } - } - - DEBUG_CRASH(("token %s is not a valid member of the lookup list",token)); - throw INI_INVALID_DATA; - return 0; // never executed, but keeps compiler happy - -} - -//------------------------------------------------------------------------------------------------- -const char* INI::getNextSubToken(const char* expected) -{ - const char* token = getNextToken(getSepsColon()); - if (stricmp(token, expected) != 0) - throw INI_INVALID_DATA; - return getNextToken(getSepsColon()); -} - -//------------------------------------------------------------------------------------------------- -/** - * Parse a "random variable". - * The format is "FIELD = low high [distribution]". - */ -void INI::parseGameClientRandomVariable( INI* ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - GameClientRandomVariable *var = static_cast(store); - - const char* token; - - token = ini->getNextToken(); - Real low = INI::scanReal(token); - - token = ini->getNextToken(); - Real high = INI::scanReal(token); - - // if omitted, assume uniform - GameClientRandomVariable::DistributionType type = GameClientRandomVariable::UNIFORM; - token = ini->getNextTokenOrNull(); - if (token) - type = (GameClientRandomVariable::DistributionType)INI::scanIndexList(token, GameClientRandomVariable::DistributionTypeNames); - - // set the range of the random variable - var->setRange( low, high, type ); -} - -//------------------------------------------------------------------------------------------------- -// parse a duration in msec and convert to duration in frames -void INI::parseDurationReal( INI *ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - Real val = scanReal(ini->getNextToken()); - *(Real *)store = ConvertDurationFromMsecsToFrames(val); -} - -//------------------------------------------------------------------------------------------------- -// parse a duration in msec and convert to duration in integral number of frames, (unsignedint) rounding UP -void INI::parseDurationUnsignedInt( INI *ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - UnsignedInt val = scanUnsignedInt(ini->getNextToken()); - *(UnsignedInt *)store = (UnsignedInt)ceilf(ConvertDurationFromMsecsToFrames((Real)val)); -} - -// ------------------------------------------------------------------------------------------------ -// parse a duration in msec and convert to duration in integral number of frames, (unsignedshort) rounding UP -void INI::parseDurationUnsignedShort( INI *ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - UnsignedInt val = scanUnsignedInt(ini->getNextToken()); - *(UnsignedShort *)store = (UnsignedShort)ceilf(ConvertDurationFromMsecsToFrames((Real)val)); -} - -//------------------------------------------------------------------------------------------------- -// parse acceleration in (dist/sec) and convert to (dist/frame) -void INI::parseVelocityReal( INI *ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - const char *token = ini->getNextToken(); - Real val = scanReal(token); - *(Real *)store = ConvertVelocityInSecsToFrames(val); -} - -//------------------------------------------------------------------------------------------------- -// parse acceleration in (dist/sec^2) and convert to (dist/frame^2) -void INI::parseAccelerationReal( INI *ini, void * /*instance*/, void *store, const void* /*userData*/ ) -{ - const char *token = ini->getNextToken(); - Real val = scanReal(token); - *(Real *)store = ConvertAccelerationInSecsToFrames(val); -} - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -void INI::parseVeterancyLevelFlags(INI* ini, void* /*instance*/, void* store, const void* /*userData*/) -{ - VeterancyLevelFlags flags = VETERANCY_LEVEL_FLAGS_ALL; - for (const char* token = ini->getNextToken(); token; token = ini->getNextTokenOrNull()) - { - if (stricmp(token, "ALL") == 0) - { - flags = VETERANCY_LEVEL_FLAGS_ALL; - continue; - } - else if (stricmp(token, "NONE") == 0) - { - flags = VETERANCY_LEVEL_FLAGS_NONE; - continue; - } - else if (token[0] == '+') - { - VeterancyLevel dt = (VeterancyLevel)INI::scanIndexList(token+1, TheVeterancyNames); - flags = setVeterancyLevelFlag(flags, dt); - continue; - } - else if (token[0] == '-') - { - VeterancyLevel dt = (VeterancyLevel)INI::scanIndexList(token+1, TheVeterancyNames); - flags = clearVeterancyLevelFlag(flags, dt); - continue; - } - else - { - throw INI_UNKNOWN_TOKEN; - } - } - *(VeterancyLevelFlags*)store = flags; -} - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -void INI::parseSoundsList( INI* ini, void *instance, void *store, const void* /*userData*/ ) -{ - std::vector *vec = (std::vector*) store; - vec->clear(); - - const char* SEPS = " \t,="; - const char *c = ini->getNextTokenOrNull(SEPS); - while ( c ) - { - vec->push_back( c ); - c = ini->getNextTokenOrNull(SEPS); - } -} - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -void INI::parseDamageTypeFlags(INI* ini, void* /*instance*/, void* store, const void* /*userData*/) -{ - DamageTypeFlags flags = DAMAGE_TYPE_FLAGS_ALL; - - for (const char* token = ini->getNextToken(); token; token = ini->getNextTokenOrNull()) - { - if (stricmp(token, "ALL") == 0) - { - flags = DAMAGE_TYPE_FLAGS_ALL; - continue; - } - if (stricmp(token, "NONE") == 0) - { - flags = DAMAGE_TYPE_FLAGS_NONE; - continue; - } - if (token[0] == '+') - { - DamageType dt = (DamageType)DamageTypeFlags::getSingleBitFromName(token+1); - flags = setDamageTypeFlag(flags, dt); - continue; - } - if (token[0] == '-') - { - DamageType dt = (DamageType)DamageTypeFlags::getSingleBitFromName(token+1); - flags = clearDamageTypeFlag(flags, dt); - continue; - } - throw INI_UNKNOWN_TOKEN; - } - *(DamageTypeFlags*)store = flags; -} - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -void INI::parseDeathTypeFlags(INI* ini, void* /*instance*/, void* store, const void* /*userData*/) -{ - DeathTypeFlags flags = DEATH_TYPE_FLAGS_ALL; - for (const char* token = ini->getNextToken(); token; token = ini->getNextTokenOrNull()) - { - if (stricmp(token, "ALL") == 0) - { - flags = DEATH_TYPE_FLAGS_ALL; - continue; - } - if (stricmp(token, "NONE") == 0) - { - flags = DEATH_TYPE_FLAGS_NONE; - continue; - } - if (token[0] == '+') - { - DeathType dt = (DeathType)INI::scanIndexList(token+1, TheDeathNames); - flags = setDeathTypeFlag(flags, dt); - continue; - } - if (token[0] == '-') - { - DeathType dt = (DeathType)INI::scanIndexList(token+1, TheDeathNames); - flags = clearDeathTypeFlag(flags, dt); - continue; - } - throw INI_UNKNOWN_TOKEN; - } - *(DeathTypeFlags*)store = flags; -} - -//------------------------------------------------------------------------------------------------- -// parse the line and return whether the given line is a Block declaration of the form -// [whitespace] blockType [whitespace] blockName [EOL] -// both blockType and blockName are case insensitive -Bool INI::isDeclarationOfType( AsciiString blockType, AsciiString blockName, char *bufferToCheck ) -{ - if (!bufferToCheck || blockType.isEmpty() || blockName.isEmpty()) - return false; - - const char* tempBuff = bufferToCheck; - - while (isspace(*tempBuff)) - ++tempBuff; - - const int blockTypeLength = blockType.getLength(); - if (strnicmp(tempBuff, blockType.str(), blockTypeLength) != 0) - return false; - - tempBuff += blockTypeLength; - - if (!isspace(*tempBuff++)) - return false; - - while (isspace(*tempBuff)) - ++tempBuff; - - const int blockNameLength = blockName.getLength(); - if (strnicmp(tempBuff, blockName.str(), blockNameLength) != 0) - return false; - - tempBuff += blockNameLength; - - while (isspace(*tempBuff)) - ++tempBuff; - - if (*tempBuff != '\0') - return false; - - return true; -} - -//------------------------------------------------------------------------------------------------- -// parse the line and return whether the given line is a Block declaration of the form -// [whitespace] end [EOL] -Bool INI::isEndOfBlock( char *bufferToCheck ) -{ - Bool retVal = true; - if (!bufferToCheck) { - return false; - } - - // DO NOT RETURN EARLY FROM THIS FUNCTION (beyond this point) - // we have to restore the bufferToCheck to its previous state before returning, so - // it is important to get through all the checks. - - static const char* endString = "End"; - int endStringLength = strlen(endString); - char restoreChar; - char *tempBuff = bufferToCheck; - - - while (isspace(*tempBuff)) { - ++tempBuff; - } - - if (strlen(tempBuff) > endStringLength) { - restoreChar = tempBuff[endStringLength]; - tempBuff[endStringLength] = 0; - - if (stricmp(endString, tempBuff) != 0) { - retVal = false; - } - - tempBuff[endStringLength] = restoreChar; - tempBuff = tempBuff + endStringLength; - } else { - retVal = false; - } - - while (*tempBuff && retVal) { - retVal = isspace(*tempBuff); - ++tempBuff; - } - - return retVal; -} diff --git a/Generals/Code/GameEngine/Source/Common/System/GameCommon.cpp b/Generals/Code/GameEngine/Source/Common/System/GameCommon.cpp deleted file mode 100644 index 480e7e3464d..00000000000 --- a/Generals/Code/GameEngine/Source/Common/System/GameCommon.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// GameCommon.h -// Part of header detangling -// John McDonald, Aug 2002 - -#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine - -#include "Common/GameCommon.h" - -const char *const TheVeterancyNames[] = -{ - "REGULAR", - "VETERAN", - "ELITE", - "HEROIC", - nullptr -}; -static_assert(ARRAY_SIZE(TheVeterancyNames) == LEVEL_COUNT + 1, "Incorrect array size"); - -const char *const TheRelationshipNames[] = -{ - "ENEMIES", - "NEUTRAL", - "ALLIES", - nullptr -}; -static_assert(ARRAY_SIZE(TheRelationshipNames) == RELATIONSHIP_COUNT + 1, "Incorrect array size"); - -//------------------------------------------------------------------------------------------------- -// TheSuperHackers @todo DO NOT USE THIS FUNCTION! Use WWMath::Normalize_Angle instead. Delete this. -Real normalizeAngle(Real angle) -{ - DEBUG_ASSERTCRASH(!_isnan(angle), ("Angle is NAN in normalizeAngle!")); - - if( _isnan(angle) ) - return 0;// ARGH!!!! Don't assert and then not handle it! Error bad! Fix error! - - while (angle > PI) - angle -= 2*PI; - - while (angle <= -PI) - angle += 2*PI; - - return angle; -} - diff --git a/Generals/Code/GameEngine/Source/Common/System/GameType.cpp b/Generals/Code/GameEngine/Source/Common/System/GameType.cpp deleted file mode 100644 index f0f5adb9cd5..00000000000 --- a/Generals/Code/GameEngine/Source/Common/System/GameType.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// GameType.cpp /////////////////////////////////////////////////////////////////////////////////// - -#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine - -const char *const TimeOfDayNames[] = -{ - "NONE", - "MORNING", - "AFTERNOON", - "EVENING", - "NIGHT", - - nullptr -}; -static_assert(ARRAY_SIZE(TimeOfDayNames) == TIME_OF_DAY_COUNT + 1, "Incorrect array size"); - -const char *const WeatherNames[] = -{ - "NORMAL", - "SNOWY", - - nullptr -}; -static_assert(ARRAY_SIZE(WeatherNames) == WEATHER_COUNT + 1, "Incorrect array size"); diff --git a/Generals/Code/GameEngine/Source/Common/System/Snapshot.cpp b/Generals/Code/GameEngine/Source/Common/System/Snapshot.cpp deleted file mode 100644 index 9f8be6a2cba..00000000000 --- a/Generals/Code/GameEngine/Source/Common/System/Snapshot.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: Snapshot.cpp ///////////////////////////////////////////////////////////////////////////// -// Author: Colin Day, February 2002 -// Desc: The Snapshot object is the base class interface for data structures that will -// be considered during game saves, loads, and CRC checks. -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine -#include "Common/GameState.h" -#include "Common/Snapshot.h" - -// ------------------------------------------------------------------------------------------------ -// ------------------------------------------------------------------------------------------------ -Snapshot::Snapshot( void ) -{ - -} - -// ------------------------------------------------------------------------------------------------ -// ------------------------------------------------------------------------------------------------ -Snapshot::~Snapshot( void ) -{ - - // - // if we're loading, there are pathological cases where we could destroy snapshots while - // there is an entry for them in the post processing list ... need to clean this up - // - ///@ todo, this might be needed in theory in the future, but iterating the post process - // list in the game state is expensive because it's HUGE! - // -// TheGameState->notifySnapshotDeleted(); - -} diff --git a/Generals/Code/GameEngine/Source/Common/System/SubsystemInterface.cpp b/Generals/Code/GameEngine/Source/Common/System/SubsystemInterface.cpp deleted file mode 100644 index d7aad22f1cf..00000000000 --- a/Generals/Code/GameEngine/Source/Common/System/SubsystemInterface.cpp +++ /dev/null @@ -1,236 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: SubsystemInterface.cpp -// ---------------------------------------------------------------------------- -#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine - -#include "Common/SubsystemInterface.h" -#include "Common/Xfer.h" - - -#ifdef DUMP_PERF_STATS -#include "GameLogic/GameLogic.h" -#include "Common/PerfTimer.h" - -Real SubsystemInterface::s_msConsumed = 0; -#endif - -//----------------------------------------------------------------------------- -SubsystemInterface::SubsystemInterface() -#ifdef DUMP_PERF_STATS -:m_curDrawTime(0), -m_startDrawTimeConsumed(0), -m_startTimeConsumed(0), -m_curUpdateTime(0), -m_dumpUpdate(false), -m_dumpDraw(false) -#endif -{ - if (TheSubsystemList) { - TheSubsystemList->addSubsystem(this); - } -} - - -SubsystemInterface::~SubsystemInterface() -{ - if (TheSubsystemList) { - TheSubsystemList->removeSubsystem(this); - } -} - -#ifdef DUMP_PERF_STATS -static const Real MIN_TIME_THRESHOLD = 0.0002f; // .2 msec. [8/13/2003] -void SubsystemInterface::UPDATE(void) -{ - __int64 startTime64; - __int64 endTime64,freq64; - GetPrecisionTimerTicksPerSec(&freq64); - GetPrecisionTimer(&startTime64); - m_startTimeConsumed = s_msConsumed; - update(); - GetPrecisionTimer(&endTime64); - m_curUpdateTime = ((double)(endTime64-startTime64))/((double)(freq64)); - Real subTime = s_msConsumed - m_startTimeConsumed; - if (m_name.isEmpty()) return; - if (m_curUpdateTime>MIN_TIME_THRESHOLD) { - m_dumpUpdate = true; - } - if (m_curUpdateTime > MIN_TIME_THRESHOLD/10.0f) { - //DLOG(Debug::Format("Subsys %s total time %.2f, subTime %.2f, net time %.2f\n", - // m_name.str(), m_curUpdateTime*1000, subTime*1000, (m_curUpdateTime-subTime)*1000 )); - - m_curUpdateTime -= subTime; - s_msConsumed += m_curUpdateTime; - } else { - m_curUpdateTime = 0; - } - -} -void SubsystemInterface::DRAW(void) -{ - __int64 startTime64; - __int64 endTime64,freq64; - GetPrecisionTimerTicksPerSec(&freq64); - GetPrecisionTimer(&startTime64); - m_startDrawTimeConsumed = s_msConsumed; - draw(); - GetPrecisionTimer(&endTime64); - m_curDrawTime = ((double)(endTime64-startTime64))/((double)(freq64)); - Real subTime = s_msConsumed - m_startDrawTimeConsumed; - if (m_name.isEmpty()) return; - if (m_curDrawTime>MIN_TIME_THRESHOLD) { - m_dumpDraw = true; - } - if (m_curDrawTime > MIN_TIME_THRESHOLD/10.0f) { - //DLOG(Debug::Format("Subsys %s total time %.2f, subTime %.2f, net time %.2f\n", - // m_name.str(), m_curUpdateTime*1000, subTime*1000, (m_curUpdateTime-subTime)*1000 )); - - m_curDrawTime -= subTime; - s_msConsumed += m_curDrawTime; - } else { - m_curDrawTime = 0; - } - -} -#endif - - -//----------------------------------------------------------------------------- -SubsystemInterfaceList::SubsystemInterfaceList() -{ -} - -//----------------------------------------------------------------------------- -SubsystemInterfaceList::~SubsystemInterfaceList() -{ - DEBUG_ASSERTCRASH(m_subsystems.empty(), ("not empty")); - shutdownAll(); -} - -//----------------------------------------------------------------------------- -void SubsystemInterfaceList::addSubsystem(SubsystemInterface* sys) -{ -#ifdef DUMP_PERF_STATS - m_allSubsystems.push_back(sys); -#endif -} -//----------------------------------------------------------------------------- -void SubsystemInterfaceList::removeSubsystem(SubsystemInterface* sys) -{ -#ifdef DUMP_PERF_STATS - for (SubsystemList::iterator it = m_allSubsystems.begin(); it != m_allSubsystems.end(); ++it) - { - if ( (*it) == sys) { - m_allSubsystems.erase(it); - break; - } - } -#endif -} -//----------------------------------------------------------------------------- -void SubsystemInterfaceList::initSubsystem(SubsystemInterface* sys, const char* path1, const char* path2, Xfer *pXfer, AsciiString name) -{ - sys->setName(name); - sys->init(); - - INI ini; - if (path1) - ini.loadFileDirectory(path1, INI_LOAD_OVERWRITE, pXfer ); - if (path2) - ini.loadFileDirectory(path2, INI_LOAD_OVERWRITE, pXfer ); - - m_subsystems.push_back(sys); -} - -//----------------------------------------------------------------------------- -void SubsystemInterfaceList::postProcessLoadAll() -{ - for (SubsystemList::iterator it = m_subsystems.begin(); it != m_subsystems.end(); ++it) - { - (*it)->postProcessLoad(); - } -} - -//----------------------------------------------------------------------------- -void SubsystemInterfaceList::resetAll() -{ -// for (SubsystemList::iterator it = m_subsystems.begin(); it != m_subsystems.end(); ++it) - for (SubsystemList::reverse_iterator it = m_subsystems.rbegin(); it != m_subsystems.rend(); ++it) - { - (*it)->reset(); - } -} - -//----------------------------------------------------------------------------- -void SubsystemInterfaceList::shutdownAll() -{ - // must go in reverse order! - for (SubsystemList::reverse_iterator it = m_subsystems.rbegin(); it != m_subsystems.rend(); ++it) - { - SubsystemInterface* sys = *it; - delete sys; - } - m_subsystems.clear(); -} - -#ifdef DUMP_PERF_STATS -//----------------------------------------------------------------------------- -AsciiString SubsystemInterfaceList::dumpTimesForAll() -{ - - AsciiString buffer; - buffer = "ALL SUBSYSTEMS:\n"; - //buffer.format("\nSUBSYSTEMS: total time %.2f MS\n", - // SubsystemInterface::getTotalTime()*1000.0f); - Real misc = 0; - Real total = 0; - SubsystemInterface::clearTotalTime(); - for (SubsystemList::reverse_iterator it = m_allSubsystems.rbegin(); it != m_allSubsystems.rend(); ++it) - { - SubsystemInterface* sys = *it; - total += sys->getUpdateTime(); - if (sys->doDumpUpdate()) { - AsciiString curLine; - curLine.format(" Time %02.2f MS update() %s \n", sys->getUpdateTime()*1000.0f, sys->getName().str()); - buffer.concat(curLine); - } else { - misc += sys->getUpdateTime(); - } - total += sys->getDrawTime(); - if (sys->doDumpDraw()) { - AsciiString curLine; - curLine.format(" Time %02.2f MS draw () %s \n", sys->getDrawTime()*1000.0f, sys->getName().str()); - buffer.concat(curLine); - } else { - misc += sys->getDrawTime(); - } - } - AsciiString tmp; - tmp.format("TOTAL %.2f MS, Misc time %.2f MS\n", total*1000.0f, misc*1000.0f); - buffer.concat(tmp); - return buffer; -} -#endif diff --git a/GeneralsMD/Code/GameEngine/CMakeLists.txt b/GeneralsMD/Code/GameEngine/CMakeLists.txt index 189ab821ffb..d6990fc097c 100644 --- a/GeneralsMD/Code/GameEngine/CMakeLists.txt +++ b/GeneralsMD/Code/GameEngine/CMakeLists.txt @@ -36,12 +36,12 @@ set(GAMEENGINE_SRC # Include/Common/DynamicAudioEventInfo.h Include/Common/encrypt.h Include/Common/Energy.h - Include/Common/Errors.h +# Include/Common/Errors.h # Include/Common/file.h # Include/Common/FileSystem.h Include/Common/FunctionLexicon.h # Include/Common/GameAudio.h - Include/Common/GameCommon.h +# Include/Common/GameCommon.h # Include/Common/GameDefines.h Include/Common/GameEngine.h Include/Common/GameLOD.h @@ -51,12 +51,12 @@ set(GAMEENGINE_SRC Include/Common/GameSpyMiscPreferences.h Include/Common/GameState.h Include/Common/GameStateMap.h - Include/Common/GameType.h +# Include/Common/GameType.h Include/Common/Geometry.h Include/Common/GlobalData.h Include/Common/Handicap.h Include/Common/IgnorePreferences.h - Include/Common/INI.h +# Include/Common/INI.h Include/Common/INIException.h Include/Common/KindOf.h Include/Common/LadderPreferences.h @@ -103,7 +103,7 @@ set(GAMEENGINE_SRC # Include/Common/simpleplayer.h Include/Common/SkirmishBattleHonors.h Include/Common/SkirmishPreferences.h - Include/Common/Snapshot.h +# Include/Common/Snapshot.h Include/Common/SparseMatchFinder.h Include/Common/SpecialPower.h Include/Common/SpecialPowerMaskType.h @@ -111,9 +111,9 @@ set(GAMEENGINE_SRC Include/Common/StackDump.h Include/Common/StateMachine.h Include/Common/StatsCollector.h - Include/Common/STLTypedefs.h +# Include/Common/STLTypedefs.h # Include/Common/StreamingArchiveFile.h - Include/Common/SubsystemInterface.h +# Include/Common/SubsystemInterface.h Include/Common/SystemInfo.h Include/Common/Team.h Include/Common/Terrain.h @@ -140,7 +140,7 @@ set(GAMEENGINE_SRC Include/GameClient/AnimateWindowManager.h Include/GameClient/CampaignManager.h Include/GameClient/CDCheck.h - Include/GameClient/ChallengeGenerals.h +# Include/GameClient/ChallengeGenerals.h Include/GameClient/ClientInstance.h # Include/GameClient/ClientRandomValue.h Include/GameClient/Color.h @@ -572,7 +572,7 @@ set(GAMEENGINE_SRC Source/Common/GameLOD.cpp Source/Common/GameMain.cpp Source/Common/GlobalData.cpp - Source/Common/INI/INI.cpp +# Source/Common/INI/INI.cpp Source/Common/INI/INIAiData.cpp Source/Common/INI/INIAnimation.cpp # Source/Common/INI/INIAudioEventInfo.cpp @@ -643,9 +643,9 @@ set(GAMEENGINE_SRC # Source/Common/System/File.cpp # Source/Common/System/FileSystem.cpp Source/Common/System/FunctionLexicon.cpp - Source/Common/System/GameCommon.cpp +# Source/Common/System/GameCommon.cpp #Source/Common/System/GameMemory.cpp - Source/Common/System/GameType.cpp +# Source/Common/System/GameType.cpp Source/Common/System/Geometry.cpp Source/Common/System/KindOf.cpp Source/Common/System/List.cpp @@ -659,10 +659,10 @@ set(GAMEENGINE_SRC Source/Common/System/registry.cpp Source/Common/System/SaveGame/GameState.cpp Source/Common/System/SaveGame/GameStateMap.cpp - Source/Common/System/Snapshot.cpp +# Source/Common/System/Snapshot.cpp Source/Common/System/StackDump.cpp # Source/Common/System/StreamingArchiveFile.cpp - Source/Common/System/SubsystemInterface.cpp +# Source/Common/System/SubsystemInterface.cpp Source/Common/System/Trig.cpp # Source/Common/System/UnicodeString.cpp Source/Common/System/Upgrade.cpp @@ -699,7 +699,7 @@ set(GAMEENGINE_SRC Source/GameClient/GlobalLanguage.cpp Source/GameClient/GraphDraw.cpp Source/GameClient/GUI/AnimateWindowManager.cpp - Source/GameClient/GUI/ChallengeGenerals.cpp +# Source/GameClient/GUI/ChallengeGenerals.cpp Source/GameClient/GUI/ControlBar/ControlBar.cpp Source/GameClient/GUI/ControlBar/ControlBarBeacon.cpp Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp diff --git a/GeneralsMD/Code/GameEngine/Include/Common/ThingSort.h b/GeneralsMD/Code/GameEngine/Include/Common/ThingSort.h index dcd47453391..64ceb9a9b78 100644 --- a/GeneralsMD/Code/GameEngine/Include/Common/ThingSort.h +++ b/GeneralsMD/Code/GameEngine/Include/Common/ThingSort.h @@ -29,7 +29,7 @@ #pragma once -#include "GameCommon.h" +#include "Common/GameCommon.h" //------------------------------------------------------------------------------------------------- enum EditorSortingType CPP_11(: Int) diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ChallengeGenerals.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ChallengeGenerals.cpp deleted file mode 100644 index eb5adf62d1b..00000000000 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ChallengeGenerals.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: ChallengeGenerals.h ////////////////////////////////////////////////////////////////////// -// Author: Steve Copeland, 6/24/2003 -// Desc: This is a manager for data pertaining to the Generals' Challenge personas and related GUI. -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine - -#include "GameClient/ChallengeGenerals.h" - - -ChallengeGenerals *TheChallengeGenerals = nullptr; - -ChallengeGenerals *createChallengeGenerals( void ) -{ - return MSGNEW("ChallengeGenerals") ChallengeGenerals; -} - - -ChallengeGenerals::ChallengeGenerals() -{ - //ctor -} - - -ChallengeGenerals::~ChallengeGenerals() -{ - //dtor -} - - -void ChallengeGenerals::init( void ) -{ - INI ini; - ini.loadFileDirectory( "Data\\INI\\ChallengeMode", INI_LOAD_OVERWRITE, nullptr ); -} - - -void ChallengeGenerals::parseGeneralPersona(INI *ini, void *instance, void *store, const void *userData) -{ - static const FieldParse dataFieldParse[] = - { - { "StartsEnabled", INI::parseBool, nullptr, offsetof( GeneralPersona, m_bStartsEnabled ) }, - { "BioNameString", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strBioName ) }, - { "BioDOBString", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strBioDOB ) }, - { "BioBirthplaceString", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strBioBirthplace ) }, - { "BioStrategyString", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strBioStrategy ) }, - { "BioRankString", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strBioRank ) }, - { "BioBranchString", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strBioBranch ) }, - { "BioClassNumberString", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strBioClassNumber ) }, - { "BioPortraitSmall", INI::parseMappedImage, nullptr, offsetof( GeneralPersona, m_imageBioPortraitSmall ) }, - { "BioPortraitLarge", INI::parseMappedImage, nullptr, offsetof( GeneralPersona, m_imageBioPortraitLarge ) }, - { "Campaign", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strCampaign ) }, - { "PlayerTemplate", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strPlayerTemplateName ) }, - { "PortraitMovieLeftName", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strPortraitMovieLeftName ) }, - { "PortraitMovieRightName", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strPortraitMovieRightName ) }, - { "DefeatedImage", INI::parseMappedImage, nullptr, offsetof( GeneralPersona, m_imageDefeated ) }, - { "VictoriousImage", INI::parseMappedImage, nullptr, offsetof( GeneralPersona, m_imageVictorious ) }, - { "DefeatedString", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strDefeated ) }, - { "VictoriousString", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strVictorious ) }, - { "SelectionSound", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strSelectionSound ) }, - { "TauntSound1", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strTauntSound1 ) }, - { "TauntSound2", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strTauntSound2 ) }, - { "TauntSound3", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strTauntSound3 ) }, - { "WinSound", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strWinSound ) }, - { "LossSound", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strLossSound ) }, - { "PreviewSound", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strPreviewSound ) }, - { "NameSound", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strNameSound ) }, - - { nullptr, nullptr, nullptr, 0 } - }; - ini->initFromINI(store, dataFieldParse); -} - - -const FieldParse ChallengeGenerals::s_fieldParseTable[] = -{ - { "GeneralPersona0", ChallengeGenerals::parseGeneralPersona, nullptr, offsetof( ChallengeGenerals, m_position[0] ) }, - { "GeneralPersona1", ChallengeGenerals::parseGeneralPersona, nullptr, offsetof( ChallengeGenerals, m_position[1] ) }, - { "GeneralPersona2", ChallengeGenerals::parseGeneralPersona, nullptr, offsetof( ChallengeGenerals, m_position[2] ) }, - { "GeneralPersona3", ChallengeGenerals::parseGeneralPersona, nullptr, offsetof( ChallengeGenerals, m_position[3] ) }, - { "GeneralPersona4", ChallengeGenerals::parseGeneralPersona, nullptr, offsetof( ChallengeGenerals, m_position[4] ) }, - { "GeneralPersona5", ChallengeGenerals::parseGeneralPersona, nullptr, offsetof( ChallengeGenerals, m_position[5] ) }, - { "GeneralPersona6", ChallengeGenerals::parseGeneralPersona, nullptr, offsetof( ChallengeGenerals, m_position[6] ) }, - { "GeneralPersona7", ChallengeGenerals::parseGeneralPersona, nullptr, offsetof( ChallengeGenerals, m_position[7] ) }, - { "GeneralPersona8", ChallengeGenerals::parseGeneralPersona, nullptr, offsetof( ChallengeGenerals, m_position[8] ) }, - { "GeneralPersona9", ChallengeGenerals::parseGeneralPersona, nullptr, offsetof( ChallengeGenerals, m_position[9] ) }, - { "GeneralPersona10", ChallengeGenerals::parseGeneralPersona, nullptr, offsetof( ChallengeGenerals, m_position[10] ) }, - { "GeneralPersona11", ChallengeGenerals::parseGeneralPersona, nullptr, offsetof( ChallengeGenerals, m_position[11] ) }, - { nullptr, nullptr, nullptr, 0 } -}; - - -//------------------------------------------------------------------------------------------------- -/** Parse Gen Challenge entries */ -//------------------------------------------------------------------------------------------------- -void INI::parseChallengeModeDefinition( INI* ini ) -{ - if( TheChallengeGenerals ) - { - ini->initFromINI( TheChallengeGenerals, TheChallengeGenerals->getFieldParse() ); - } -} - -const GeneralPersona* ChallengeGenerals::getPlayerGeneralByCampaignName( AsciiString name ) const -{ - for (Int i = 0; i < NUM_GENERALS; i++) - { - AsciiString campaignName = m_position[i].getCampaign(); - if (campaignName.compareNoCase( name.str() ) == 0) - return &m_position[i]; - } - DEBUG_CRASH(("Can't find General by Campaign Name")); - return nullptr; -} - -const GeneralPersona* ChallengeGenerals::getGeneralByGeneralName( AsciiString name ) const -{ - for (Int i = 0; i < NUM_GENERALS; i++) - { - AsciiString generalName = m_position[i].getBioName(); - if (generalName.compareNoCase( name.str() ) == 0) - return &m_position[i]; - } - return nullptr; -} - -const GeneralPersona* ChallengeGenerals::getGeneralByTemplateName( AsciiString name ) const -{ - for (Int i = 0; i < NUM_GENERALS; i++) - { - AsciiString templateName = m_position[i].getPlayerTemplateName(); - if (templateName.compareNoCase( name.str() ) == 0) - return &m_position[i]; - } - return nullptr; -} diff --git a/scripts/cpp/unify_move_files.py b/scripts/cpp/unify_move_files.py index f0845dd95f3..458d51e38e1 100644 --- a/scripts/cpp/unify_move_files.py +++ b/scripts/cpp/unify_move_files.py @@ -262,6 +262,20 @@ def main(): #unify_file(Game.ZEROHOUR, "Libraries/Include/Lib/BaseType.h", Game.CORE, "Libraries/Include/Lib/BaseType.h") #unify_file(Game.ZEROHOUR, "Libraries/Include/Lib/trig.h", Game.CORE, "Libraries/Include/Lib/trig.h") + #unify_file(Game.ZEROHOUR, "GameEngine/Include/Common/Errors.h", Game.CORE, "GameEngine/Include/Common/Errors.h") + #unify_file(Game.ZEROHOUR, "GameEngine/Include/Common/GameCommon.h", Game.CORE, "GameEngine/Include/Common/GameCommon.h") + #unify_file(Game.ZEROHOUR, "GameEngine/Include/Common/GameType.h", Game.CORE, "GameEngine/Include/Common/GameType.h") + #unify_file(Game.ZEROHOUR, "GameEngine/Include/Common/INI.h", Game.CORE, "GameEngine/Include/Common/INI.h") + #unify_file(Game.ZEROHOUR, "GameEngine/Include/Common/Snapshot.h", Game.CORE, "GameEngine/Include/Common/Snapshot.h") + #unify_file(Game.ZEROHOUR, "GameEngine/Include/Common/STLTypedefs.h", Game.CORE, "GameEngine/Include/Common/STLTypedefs.h") + #unify_file(Game.ZEROHOUR, "GameEngine/Include/Common/SubsystemInterface.h", Game.CORE, "GameEngine/Include/Common/SubsystemInterface.h") + #unify_file(Game.ZEROHOUR, "GameEngine/Include/GameClient/ChallengeGenerals.h", Game.CORE, "GameEngine/Include/GameClient/ChallengeGenerals.h") + #unify_file(Game.ZEROHOUR, "GameEngine/Source/Common/INI/INI.cpp", Game.CORE, "GameEngine/Source/Common/INI/INI.cpp") + #unify_file(Game.ZEROHOUR, "GameEngine/Source/Common/System/GameCommon.cpp", Game.CORE, "GameEngine/Source/Common/System/GameCommon.cpp") + #unify_file(Game.ZEROHOUR, "GameEngine/Source/Common/System/GameType.cpp", Game.CORE, "GameEngine/Source/Common/System/GameType.cpp") + #unify_file(Game.ZEROHOUR, "GameEngine/Source/Common/System/Snapshot.cpp", Game.CORE, "GameEngine/Source/Common/System/Snapshot.cpp") + #unify_file(Game.ZEROHOUR, "GameEngine/Source/Common/System/SubsystemInterface.cpp", Game.CORE, "GameEngine/Source/Common/System/SubsystemInterface.cpp") + #unify_file(Game.ZEROHOUR, "GameEngine/Source/GameClient/GUI/ChallengeGenerals.cpp", Game.CORE, "GameEngine/Source/GameClient/GUI/ChallengeGenerals.cpp") return