Skip to content

Commit 5fba809

Browse files
committed
Merge branch 'main' of https://github.com/TheSuperHackers/GeneralsGameCode into headless_sh
2 parents 40a9407 + c47c202 commit 5fba809

File tree

331 files changed

+283
-38200
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

331 files changed

+283
-38200
lines changed

Core/CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
# c stands for core, i stands for Interface
22
add_library(corei_libraries_include INTERFACE)
3+
add_library(corei_libraries_source_wwvegas INTERFACE)
4+
add_library(corei_libraries_source_wwvegas_wwdebug INTERFACE)
5+
add_library(corei_libraries_source_wwvegas_wwlib INTERFACE)
36
add_library(corei_always INTERFACE)
47

58
target_include_directories(corei_libraries_include INTERFACE "Libraries/Include")
9+
target_include_directories(corei_libraries_source_wwvegas INTERFACE "Libraries/Source/WWVegas")
10+
target_include_directories(corei_libraries_source_wwvegas_wwdebug INTERFACE "Libraries/Source/WWVegas/WWDebug")
11+
target_include_directories(corei_libraries_source_wwvegas_wwlib INTERFACE "Libraries/Source/WWVegas/WWLib")
612
target_link_libraries(corei_always INTERFACE
713
core_utility
814
corei_libraries_include

Core/Libraries/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# WW common libraries decended from earliest C&C games
2-
#add_subdirectory(Source/WWVegas)
2+
add_subdirectory(Source/WWVegas)
33

44
# profiling library
55
#add_subdirectory(Source/profile)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Interface libraries to set common defines and includes, avoid duplication later
2+
add_library(core_wwcommon INTERFACE)
3+
4+
target_compile_definitions(core_wwcommon INTERFACE
5+
#NOMINMAX
6+
WIN32_LEAN_AND_MEAN
7+
)
8+
9+
target_link_libraries(core_wwcommon INTERFACE
10+
d3d8lib
11+
core_config
12+
core_utility
13+
milesstub
14+
stlport
15+
)
16+
17+
target_include_directories(core_wwcommon INTERFACE
18+
.
19+
WWDebug
20+
WWLib
21+
)
22+
23+
# add_subdirectory(WWAudio)
24+
add_subdirectory(WWDebug)
25+
add_subdirectory(WWLib)
26+
# add_subdirectory(WWMath)
27+
# add_subdirectory(Wwutil)
28+
# add_subdirectory(WWSaveLoad)
29+
add_subdirectory(WWStub)
30+
# add_subdirectory(WW3D2)
31+
# add_subdirectory(WWDownload)
32+
# add_subdirectory(wwshade)
33+
34+
# Helpful interface to bundle the ww modules together.
35+
add_library(core_wwvegas INTERFACE)
36+
37+
target_include_directories(core_wwvegas INTERFACE
38+
.
39+
#WW3D2
40+
WWDebug
41+
#WWDownload
42+
WWLib
43+
#WWMath
44+
#WWSaveLoad
45+
#Wwutil
46+
#wwshade
47+
)
48+
49+
target_link_libraries(core_wwvegas INTERFACE
50+
# core_ww3d2
51+
core_wwdebug
52+
# core_wwdownload
53+
core_wwlib
54+
# core_wwmath
55+
# core_wwsaveload
56+
# core_wwshade
57+
# core_wwutil
58+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Set source files
2+
set(WWDEBUG_SRC
3+
wwdebug.cpp
4+
wwdebug.h
5+
wwhack.h
6+
wwmemlog.cpp
7+
wwmemlog.h
8+
wwprofile.cpp
9+
wwprofile.h
10+
)
11+
12+
# Targets to build.
13+
add_library(core_wwdebug STATIC)
14+
set_target_properties(core_wwdebug PROPERTIES OUTPUT_NAME wwdebug)
15+
16+
target_sources(core_wwdebug PRIVATE ${WWDEBUG_SRC})
17+
18+
target_link_libraries(core_wwdebug PRIVATE
19+
core_wwcommon
20+
corei_always
21+
)

GeneralsMD/Code/Libraries/Source/WWVegas/WWDebug/wwdebug.h renamed to Core/Libraries/Source/WWVegas/WWDebug/wwdebug.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ void WWDebug_DBWin32_Message_Handler( const char * message);
110110
** WWDEBUG_SAY(("dir = %f\n",dir));
111111
*/
112112

113-
#include "../../../../GameEngine/Include/Common/Debug.h"
113+
// TheSuperHackers @compile feliwir 12/04/2025 Both Debug headers are identical. Use ZH.
114+
#include "../../../../../GeneralsMD/Code/GameEngine/Include/Common/Debug.h"
114115

115116
#ifdef DEBUG_LOGGING
116117
#define WWDEBUG_SAY(x) DEBUG_LOG(x)

GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/CMakeLists.txt renamed to Core/Libraries/Source/WWVegas/WWLib/CMakeLists.txt

+7-7
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,16 @@ set(WWLIB_SRC
153153
)
154154

155155
# Targets to build.
156-
add_library(z_wwlib STATIC)
157-
set_target_properties(z_wwlib PROPERTIES OUTPUT_NAME wwlib)
156+
add_library(core_wwlib STATIC)
157+
set_target_properties(core_wwlib PROPERTIES OUTPUT_NAME wwlib)
158158

159-
target_sources(z_wwlib PRIVATE ${WWLIB_SRC})
159+
target_sources(core_wwlib PRIVATE ${WWLIB_SRC})
160160

161-
target_include_directories(z_wwlib PUBLIC
161+
target_include_directories(core_wwlib PUBLIC
162162
.
163163
)
164164

165-
target_link_libraries(z_wwlib PRIVATE
166-
z_wwcommon
167-
zi_always
165+
target_link_libraries(core_wwlib PRIVATE
166+
core_wwcommon
167+
corei_always
168168
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Set source files
2+
set(WWSTUB_SRC
3+
wwallocstub.cpp
4+
wwdebugstub.cpp
5+
)
6+
7+
# Targets to build.
8+
add_library(core_wwstub STATIC)
9+
set_target_properties(core_wwstub PROPERTIES OUTPUT_NAME wwstub)
10+
11+
target_sources(core_wwstub PRIVATE ${WWSTUB_SRC})
12+
13+
target_link_libraries(core_wwstub PRIVATE
14+
core_wwcommon
15+
corei_always
16+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
** Command & Conquer Generals Zero Hour(tm)
3+
** Copyright 2025 TheSuperHackers
4+
**
5+
** This program is free software: you can redistribute it and/or modify
6+
** it under the terms of the GNU General Public License as published by
7+
** the Free Software Foundation, either version 3 of the License, or
8+
** (at your option) any later version.
9+
**
10+
** This program is distributed in the hope that it will be useful,
11+
** but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
** GNU General Public License for more details.
14+
**
15+
** You should have received a copy of the GNU General Public License
16+
** along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
// TheSuperHackers @compile feliwir 15/04/2025 Simple allocator implementation useful for tools
20+
#include "always.h"
21+
#include <stdlib.h>
22+
23+
#ifdef _OPERATOR_NEW_DEFINED_
24+
25+
void *operator new(size_t size)
26+
{
27+
return malloc(size);
28+
}
29+
30+
void *operator new[](size_t size)
31+
{
32+
return malloc(size);
33+
}
34+
35+
void operator delete(void *p)
36+
{
37+
free(p);
38+
}
39+
40+
void operator delete[](void *p)
41+
{
42+
free(p);
43+
}
44+
45+
void* operator new(size_t size, const char * fname, int)
46+
{
47+
return malloc(size);
48+
}
49+
50+
void operator delete(void * p, const char *, int)
51+
{
52+
free(p);
53+
}
54+
55+
void* operator new[](size_t size, const char * fname, int)
56+
{
57+
return malloc(size);
58+
}
59+
60+
void operator delete[](void * p, const char *, int)
61+
{
62+
free(p);
63+
}
64+
65+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
** Command & Conquer Generals Zero Hour(tm)
3+
** Copyright 2025 TheSuperHackers
4+
**
5+
** This program is free software: you can redistribute it and/or modify
6+
** it under the terms of the GNU General Public License as published by
7+
** the Free Software Foundation, either version 3 of the License, or
8+
** (at your option) any later version.
9+
**
10+
** This program is distributed in the hope that it will be useful,
11+
** but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
** GNU General Public License for more details.
14+
**
15+
** You should have received a copy of the GNU General Public License
16+
** along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
// TheSuperHackers @compile feliwir 15/04/2025 Simple debug implementation useful for tools
20+
#include "wwdebug.h"
21+
#include <stdarg.h>
22+
#include <stdlib.h>
23+
#include <stdio.h>
24+
25+
char* TheCurrentIgnoreCrashPtr = NULL;
26+
27+
28+
#ifdef DEBUG_LOGGING
29+
30+
void DebugLog(const char *format, ...)
31+
{
32+
// Print it to the console
33+
char theBuffer[8192];
34+
35+
va_list arg;
36+
va_start(arg, format);
37+
vsprintf(theBuffer, format, arg);
38+
va_end(arg);
39+
}
40+
41+
#endif
42+
43+
#ifdef DEBUG_CRASHING
44+
45+
void DebugCrash(const char *format, ...)
46+
{
47+
// Print it to the console
48+
char theCrashBuffer[8192];
49+
va_list arg;
50+
va_start(arg, format);
51+
vsprintf(theCrashBuffer, format, arg);
52+
va_end(arg);
53+
54+
// Quit
55+
exit(EXIT_FAILURE);
56+
}
57+
58+
#endif

Generals/Code/CMakeLists.txt

-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ add_library(gi_gameenginedevice_include INTERFACE)
55
add_library(gi_libraries_include INTERFACE)
66
add_library(gi_libraries_source_wwvegas INTERFACE)
77
add_library(gi_libraries_source_wwvegas_ww3d2 INTERFACE)
8-
add_library(gi_libraries_source_wwvegas_wwdebug INTERFACE)
9-
add_library(gi_libraries_source_wwvegas_wwlib INTERFACE)
108
add_library(gi_libraries_source_wwvegas_wwmath INTERFACE)
119
add_library(gi_libraries_source_wwvegas_wwsaveload INTERFACE)
1210
add_library(gi_main INTERFACE)
@@ -18,8 +16,6 @@ target_include_directories(gi_gameenginedevice_include INTERFACE "GameEngineDevi
1816
target_include_directories(gi_libraries_include INTERFACE "Libraries/Include")
1917
target_include_directories(gi_libraries_source_wwvegas INTERFACE "Libraries/Source/WWVegas")
2018
target_include_directories(gi_libraries_source_wwvegas_ww3d2 INTERFACE "Libraries/Source/WWVegas/WW3D2")
21-
target_include_directories(gi_libraries_source_wwvegas_wwdebug INTERFACE "Libraries/Source/WWVegas/WWDebug")
22-
target_include_directories(gi_libraries_source_wwvegas_wwlib INTERFACE "Libraries/Source/WWVegas/WWLib")
2319
target_include_directories(gi_libraries_source_wwvegas_wwmath INTERFACE "Libraries/Source/WWVegas/WWMath")
2420
target_include_directories(gi_libraries_source_wwvegas_wwsaveload INTERFACE "Libraries/Source/WWVegas/WWSaveLoad")
2521
target_include_directories(gi_main INTERFACE "Main")

Generals/Code/GameEngine/Include/GameLogic/Module/BehaviorModule.h

+2
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ class SpecialPowerTemplate;
7979
class WeaponTemplate;
8080
class DamageInfo;
8181
class ParticleSystemTemplate;
82+
class StealthUpdate;
8283

8384

8485
//-------------------------------------------------------------------------------------------------
@@ -163,6 +164,7 @@ class BehaviorModule : public ObjectModule, public BehaviorModuleInterface
163164
virtual SpecialPowerModuleInterface* getSpecialPower() { return NULL; }
164165
virtual UpdateModuleInterface* getUpdate() { return NULL; }
165166
virtual UpgradeModuleInterface* getUpgrade() { return NULL; }
167+
virtual StealthUpdate* getStealth() { return NULL; }
166168

167169
virtual ParkingPlaceBehaviorInterface* getParkingPlaceBehaviorInterface() { return NULL; }
168170
virtual RebuildHoleBehaviorInterface* getRebuildHoleBehaviorInterface() { return NULL; }

Generals/Code/GameEngine/Include/GameLogic/Module/StealthUpdate.h

+2
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ class StealthUpdate : public UpdateModule
123123
StealthUpdate( Thing *thing, const ModuleData* moduleData );
124124
// virtual destructor prototype provided by memory pool declaration
125125

126+
virtual StealthUpdate* getStealth() { return this; }
127+
126128
virtual UpdateSleepTime update();
127129

128130
//Still gets called, even if held -ML

Generals/Code/GameEngine/Include/GameLogic/Object.h

+3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include "GameLogic/WeaponBonusConditionFlags.h"
4646
#include "GameLogic/WeaponSet.h"
4747
#include "GameLogic/WeaponSetFlags.h"
48+
#include "GameLogic/Module/StealthUpdate.h"
4849

4950
//-----------------------------------------------------------------------------
5051
// Forward References
@@ -271,6 +272,7 @@ class Object : public Thing, public Snapshot
271272

272273
BodyModuleInterface* getBodyModule() const { return m_body; }
273274
ContainModuleInterface* getContain() const { return m_contain; }
275+
StealthUpdate* getStealth() const { return m_stealth; }
274276
SpawnBehaviorInterface* getSpawnBehaviorInterface() const;
275277

276278

@@ -691,6 +693,7 @@ class Object : public Thing, public Snapshot
691693
// cache these, for convenience
692694
ContainModuleInterface* m_contain;
693695
BodyModuleInterface* m_body;
696+
StealthUpdate* m_stealth;
694697

695698
AIUpdateInterface* m_ai; ///< ai interface (if any), cached for handy access. (duplicate of entry in the module array!)
696699
PhysicsBehavior* m_physics; ///< physics interface (if any), cached for handy access. (duplicate of entry in the module array!)

Generals/Code/GameEngine/Source/Common/RTS/Player.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -1093,8 +1093,7 @@ void Player::becomingLocalPlayer(Bool yes)
10931093
Drawable *draw = object->getDrawable();
10941094
if( draw )
10951095
{
1096-
static NameKeyType key_StealthUpdate = NAMEKEY( "StealthUpdate" );
1097-
StealthUpdate *update = (StealthUpdate*)object->findUpdateModule( key_StealthUpdate );
1096+
StealthUpdate *update = object->getStealth();
10981097
if( update && update->isDisguised() )
10991098
{
11001099
Player *disguisedPlayer = ThePlayerList->getNthPlayer( update->getDisguisedPlayerIndex() );

Generals/Code/GameEngine/Source/Common/System/Radar.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,7 @@ void Radar::addObject( Object *obj )
426426
//Because we have support for disguised units pretending to be units from another
427427
//team, we need to intercept it here and make sure it's rendered appropriately
428428
//based on which client is rendering it.
429-
static NameKeyType key_StealthUpdate = NAMEKEY( "StealthUpdate" );
430-
StealthUpdate *update = (StealthUpdate*)obj->findUpdateModule( key_StealthUpdate );
429+
StealthUpdate *update = obj->getStealth();
431430
if( update )
432431
{
433432
if( update->isDisguised() )

Generals/Code/GameEngine/Source/GameClient/Drawable.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -2126,8 +2126,7 @@ void Drawable::setStealthLook(StealthLookType look)
21262126
if( obj )
21272127
{
21282128
//Try to get the stealthupdate module and see if the opacity value is overriden.
2129-
static NameKeyType key_StealthUpdate = NAMEKEY("StealthUpdate");
2130-
StealthUpdate* stealth = (StealthUpdate *)obj->findUpdateModule(key_StealthUpdate);
2129+
StealthUpdate* stealth = obj->getStealth();
21312130
if( stealth )
21322131
{
21332132
if( stealth->isDisguised() )

Generals/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -2506,8 +2506,7 @@ void ControlBar::setPortraitByObject( Object *obj )
25062506
setPortraitByObject( NULL );
25072507
return;
25082508
}
2509-
static NameKeyType key_StealthUpdate = NAMEKEY("StealthUpdate");
2510-
StealthUpdate* stealth = (StealthUpdate *)obj->findUpdateModule(key_StealthUpdate);
2509+
StealthUpdate* stealth = obj->getStealth();
25112510
if( stealth && stealth->isDisguised() )
25122511
{
25132512
//Fake player upgrades too!

Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -2218,8 +2218,7 @@ void InGameUI::createMouseoverHint( const GameMessage *msg )
22182218
//Because we have support for disguised units pretending to be units from another
22192219
//team, we need to intercept it here and make sure it's rendered appropriately
22202220
//based on which client is rendering it.
2221-
static NameKeyType key_StealthUpdate = NAMEKEY( "StealthUpdate" );
2222-
StealthUpdate *update = (StealthUpdate*)obj->findUpdateModule( key_StealthUpdate );
2221+
StealthUpdate *update = obj->getStealth();
22232222
if( update )
22242223
{
22252224
if( update->isDisguised() )

0 commit comments

Comments
 (0)