Skip to content

Commit f692775

Browse files
committed
merge: xezon/xezon/vs2022-compile-1
1 parent df05d31 commit f692775

File tree

376 files changed

+2085
-1556
lines changed

Some content is hidden

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

376 files changed

+2085
-1556
lines changed

CMakeLists.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,20 @@ endif()
3333
# Top level project, doesn't really affect anything.
3434
project(genzh LANGUAGES C CXX)
3535

36+
# Print some information
37+
message(STATUS "CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}")
38+
message(STATUS "CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID}")
39+
if (DEFINED MSVC_VERSION)
40+
message(STATUS "MSVC_VERSION: ${MSVC_VERSION}")
41+
endif()
42+
43+
# Set variable for VS6 to handle special cases.
44+
if (DEFINED MSVC_VERSION AND MSVC_VERSION LESS 1300)
45+
set(IS_VS6_BUILD TRUE)
46+
else()
47+
set(IS_VS6_BUILD FALSE)
48+
endif()
49+
3650
# Create PDB for Release as long as debug info was generated during compile.
3751
if(MSVC)
3852
string(APPEND CMAKE_EXE_LINKER_FLAGS_RELEASE " /DEBUG /OPT:REF /OPT:ICF")
@@ -57,6 +71,20 @@ add_subdirectory(Dependencies/Benchmark)
5771
add_subdirectory(Dependencies/SafeDisc)
5872
add_subdirectory(Dependencies/MaxSDK)
5973

74+
if (NOT IS_VS6_BUILD)
75+
# Set C++ standard
76+
set(CMAKE_CXX_STANDARD 20)
77+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
78+
set(CMAKE_CXX_EXTENSIONS OFF) # Ensures only ISO features are used
79+
80+
if (MSVC)
81+
# Multithreaded build.
82+
add_compile_options(/MP)
83+
# Enforce strict __cplusplus version
84+
add_compile_options(/Zc:__cplusplus)
85+
endif()
86+
endif()
87+
6088
# Do we want to build extra SDK stuff or just the game binary?
6189
option(GENZH_BUILD_ZEROHOUR "Build Zero Hour code." ON)
6290
option(GENZH_BUILD_GENERALS "Build Generals code." ON)

Generals/Code/Tools/Compress/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ target_link_libraries(g_compress PRIVATE
1616
)
1717

1818
if(WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows")
19-
if(MSVC_VERSION LESS 1300) # VS6
19+
if(IS_VS6_BUILD)
2020
target_compile_definitions(g_compress PRIVATE vsnprintf=_vsnprintf)
2121
endif()
2222
target_link_options(g_compress PRIVATE /subsystem:console)

GeneralsMD/Code/GameEngine/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ set(GAMEENGINE_SRC
2222
Include/Common/ClientUpdateModule.h
2323
Include/Common/CommandLine.h
2424
Include/Common/CopyProtection.h
25+
Include/Common/CppMacros.h
2526
Include/Common/crc.h
2627
Include/Common/CRCDebug.h
2728
Include/Common/CriticalSection.h

GeneralsMD/Code/GameEngine/Include/Common/AudioEventInfo.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ enum AudioType
4848
AT_SoundEffect
4949
};
5050

51-
extern char *theAudioPriorityNames[];
51+
extern const char *theAudioPriorityNames[];
5252
enum AudioPriority
5353
{
5454
AP_LOWEST,
@@ -58,7 +58,7 @@ enum AudioPriority
5858
AP_CRITICAL
5959
};
6060

61-
extern char *theSoundTypeNames[];
61+
extern const char *theSoundTypeNames[];
6262
enum SoundType
6363
{
6464
ST_UI = 0x0001,
@@ -72,7 +72,7 @@ enum SoundType
7272
ST_EVERYONE = 0x0100,
7373
};
7474

75-
extern char *theAudioControlNames[];
75+
extern const char *theAudioControlNames[];
7676
enum AudioControl
7777
{
7878
AC_LOOP = 0x0001,
@@ -128,7 +128,7 @@ struct AudioEventInfo : public MemoryPoolObject
128128

129129
/// Is this a permenant sound? That is, if I start this sound up, will it ever end
130130
/// "on its own" or only if I explicitly kill it?
131-
Bool isPermanentSound() const { return BitTest( m_control, AC_LOOP ) && (m_loopCount == 0 ); }
131+
Bool isPermanentSound() const { return BitIsSet( m_control, AC_LOOP ) && (m_loopCount == 0 ); }
132132

133133
static const FieldParse m_audioEventInfo[]; ///< the parse table for INI definition
134134
const FieldParse *getFieldParse( void ) const { return m_audioEventInfo; }

GeneralsMD/Code/GameEngine/Include/Common/AudioRandomValue.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
#include "Lib/BaseType.h"
3636

3737
// do NOT use these functions directly, rather use the macros below
38-
extern Int GetGameAudioRandomValue( int lo, int hi, char *file, int line );
39-
extern Real GetGameAudioRandomValueReal( Real lo, Real hi, char *file, int line );
38+
extern Int GetGameAudioRandomValue( int lo, int hi, const char *file, int line );
39+
extern Real GetGameAudioRandomValueReal( Real lo, Real hi, const char *file, int line );
4040

4141
// use these macros to access the random value functions
4242
#define GameAudioRandomValue( lo, hi ) GetGameAudioRandomValue( lo, hi, __FILE__, __LINE__ )

GeneralsMD/Code/GameEngine/Include/Common/BorderColors.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
struct BorderColor
2424
{
25-
char *m_colorName;
25+
const char *m_colorName;
2626
long m_borderColor;
2727
};
2828

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// TheSuperHackers
2+
// This file contains macros to help upgrade the code for newer cpp standards.
3+
4+
#pragma once
5+
6+
#if __cplusplus >= 201703L
7+
#define NOEXCEPT_17 noexcept
8+
#else
9+
#define NOEXCEPT_17
10+
#endif

GeneralsMD/Code/GameEngine/Include/Common/DataChunk.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class DataChunkOutput
126126
DataChunkOutput( OutputStream *pOut );
127127
~DataChunkOutput();
128128

129-
void openDataChunk( char *name, DataChunkVersionType ver );
129+
void openDataChunk( const char *name, DataChunkVersionType ver );
130130
void closeDataChunk( void );
131131

132132
void writeReal(Real r);

GeneralsMD/Code/GameEngine/Include/Common/GameCommon.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ public: \
318318
inline DLINK_ITERATOR<OBJCLASS> iterate_##LISTNAME() const \
319319
{ \
320320
DEBUG_ASSERTCRASH(!BOGUSPTR(m_dlinkhead_##LISTNAME.m_head), ("bogus head ptr")); \
321-
return DLINK_ITERATOR<OBJCLASS>(m_dlinkhead_##LISTNAME.m_head, OBJCLASS::dlink_next_##LISTNAME); \
321+
return DLINK_ITERATOR<OBJCLASS>(m_dlinkhead_##LISTNAME.m_head, &OBJCLASS::dlink_next_##LISTNAME); \
322322
} \
323323
inline OBJCLASS *getFirstItemIn_##LISTNAME() const \
324324
{ \

GeneralsMD/Code/GameEngine/Include/Common/GameMemory.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,11 +875,13 @@ extern void userMemoryAdjustPoolSize(const char *poolName, Int& initialAllocatio
875875
extern void* __cdecl operator new[](size_t nSize, const char *, int);
876876
extern void __cdecl operator delete[](void *, const char *, int);
877877

878+
#if defined(_MSC_VER) && _MSC_VER < 1300
878879
// additional overloads for 'placement new'
879880
//inline void* __cdecl operator new (size_t s, void *p) { return p; }
880881
//inline void __cdecl operator delete (void *, void *p) { }
881882
inline void* __cdecl operator new[] (size_t s, void *p) { return p; }
882883
inline void __cdecl operator delete[] (void *, void *p) { }
884+
#endif
883885

884886
#endif
885887

0 commit comments

Comments
 (0)