diff --git a/Core/Libraries/Source/WWVegas/WWLib/CMakeLists.txt b/Core/Libraries/Source/WWVegas/WWLib/CMakeLists.txt index 65bb3fcc65..dcd56f3208 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/CMakeLists.txt +++ b/Core/Libraries/Source/WWVegas/WWLib/CMakeLists.txt @@ -71,8 +71,6 @@ set(WWLIB_SRC #md5.h mempool.h mmsys.h - mpu.cpp - MPU.H multilist.cpp multilist.h mutex.cpp @@ -91,8 +89,6 @@ set(WWLIB_SRC RANDOM.H rawfile.cpp RAWFILE.H - rcfile.cpp - rcfile.h readline.cpp readline.h realcrc.cpp @@ -102,8 +98,6 @@ set(WWLIB_SRC refcount.h #regexpr.cpp #regexpr.h - registry.cpp - registry.h #search.h sharebuf.h Signaler.h @@ -134,14 +128,10 @@ set(WWLIB_SRC uarray.h vector.cpp Vector.H - verchk.cpp - verchk.h visualc.h widestring.cpp widestring.h win.h - WWCOMUtil.cpp - WWCOMUtil.h wwfile.cpp WWFILE.H wwstring.cpp @@ -152,6 +142,21 @@ set(WWLIB_SRC XSTRAW.H ) +if(WIN32) + list(APPEND WWLIB_SRC + mpu.cpp + MPU.H + rcfile.cpp + rcfile.h + registry.cpp + registry.h + verchk.cpp + verchk.h + WWCOMUtil.cpp + WWCOMUtil.h + ) +endif() + # Targets to build. add_library(core_wwlib STATIC) set_target_properties(core_wwlib PROPERTIES OUTPUT_NAME wwlib) diff --git a/Core/Libraries/Source/WWVegas/WWLib/CRC.H b/Core/Libraries/Source/WWVegas/WWLib/CRC.H index 6a8f8292ae..dcc5790680 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/CRC.H +++ b/Core/Libraries/Source/WWVegas/WWLib/CRC.H @@ -41,9 +41,9 @@ #define CRC_H #include -#ifdef _UNIX - #include "osdep.h" -#endif + +// TheSuperHackers @compile feliwir 17/04/2025 include _ltrotl macros +#include /* ** This is a CRC engine class. It will process submitted data and generate a CRC from it. diff --git a/Core/Libraries/Source/WWVegas/WWLib/FastAllocator.cpp b/Core/Libraries/Source/WWVegas/WWLib/FastAllocator.cpp index a53c83f6df..f3bf1b6f3f 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/FastAllocator.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/FastAllocator.cpp @@ -17,7 +17,7 @@ */ #include "FastAllocator.h" -#include +#include static FastAllocatorGeneral* generalAllocator; //This general allocator will do all allocations for us. diff --git a/Core/Libraries/Source/WWVegas/WWLib/Vector.H b/Core/Libraries/Source/WWVegas/WWLib/Vector.H index 4e331d2a18..b5e458b0d2 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/Vector.H +++ b/Core/Libraries/Source/WWVegas/WWLib/Vector.H @@ -61,7 +61,7 @@ #include #include #include -#include +#include #ifdef _MSC_VER #pragma warning (disable : 4702) // unreachable code, happens with some uses of these templates diff --git a/Core/Libraries/Source/WWVegas/WWLib/WWFILE.H b/Core/Libraries/Source/WWVegas/WWLib/WWFILE.H index b8a7066b30..3d4fd1ccee 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/WWFILE.H +++ b/Core/Libraries/Source/WWVegas/WWLib/WWFILE.H @@ -40,10 +40,6 @@ #ifndef WWFILE_Hx #define WWFILE_Hx -#ifdef _UNIX -#include "osdep.h" -#endif - #define YEAR(dt) (((dt & 0xFE000000) >> (9 + 16)) + 1980) #define MONTH(dt) ((dt & 0x01E00000) >> (5 + 16)) #define DAY(dt) ((dt & 0x001F0000) >> (0 + 16)) diff --git a/Core/Libraries/Source/WWVegas/WWLib/always.h b/Core/Libraries/Source/WWVegas/WWLib/always.h index 2df70428da..d9eadee1fe 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/always.h +++ b/Core/Libraries/Source/WWVegas/WWLib/always.h @@ -43,6 +43,9 @@ #include #include +// TheSuperHackers @compile feliwir 17/04/2025 include utility macros for cross-platform compatibility +#include + // Disable warning about exception handling not being enabled. It's used as part of STL - in a part of STL we don't use. #pragma warning(disable : 4530) diff --git a/Core/Libraries/Source/WWVegas/WWLib/argv.h b/Core/Libraries/Source/WWVegas/WWLib/argv.h index 8fe1ce4bac..8e8ccb7776 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/argv.h +++ b/Core/Libraries/Source/WWVegas/WWLib/argv.h @@ -47,10 +47,6 @@ #include "always.h" #endif -#ifdef _UNIX -#include "osdep.h" -#endif - // Used to parse command line that is passed into WinMain. // It also has the ability to load a file with values to append to the command line. // Normally in WinMain() there would be a call Argv::Init(lpCmdLine, fileprefix). diff --git a/Core/Libraries/Source/WWVegas/WWLib/cpudetect.cpp b/Core/Libraries/Source/WWVegas/WWLib/cpudetect.cpp index 3dde46736b..857ff0d812 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/cpudetect.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/cpudetect.cpp @@ -21,10 +21,13 @@ #include "wwdebug.h" #include "thread.h" #pragma warning (disable : 4201) // Nonstandard extension - nameless struct -#include #include "systimer.h" #include +#ifdef _WIN32 +#include +#endif + #ifdef _UNIX # include // for time(), localtime() and timezone variable. #endif @@ -57,7 +60,7 @@ int CPUDetectClass::ProcessorFamily; int CPUDetectClass::ProcessorModel; int CPUDetectClass::ProcessorRevision; int CPUDetectClass::ProcessorSpeed; -__int64 CPUDetectClass::ProcessorTicksPerSecond; // Ticks per second +sint64 CPUDetectClass::ProcessorTicksPerSecond; // Ticks per second double CPUDetectClass::InvProcessorTicksPerSecond; // 1.0 / Ticks per second unsigned CPUDetectClass::FeatureBits; @@ -125,10 +128,10 @@ const char* CPUDetectClass::Get_Processor_Manufacturer_Name() #define ASM_RDTSC _asm _emit 0x0f _asm _emit 0x31 -static unsigned Calculate_Processor_Speed(__int64& ticks_per_second) +static unsigned Calculate_Processor_Speed(sint64& ticks_per_second) { - unsigned __int64 timer0=0; - unsigned __int64 timer1=0; + sint64 timer0=0; + sint64 timer1=0; timer0=_rdtsc(); @@ -138,8 +141,8 @@ static unsigned Calculate_Processor_Speed(__int64& ticks_per_second) timer1=_rdtsc(); } - __int64 t=timer1-timer0; - ticks_per_second=(__int64)((1000.0/(double)elapsed)*(double)t); // Ticks per second + sint64 t=timer1-timer0; + ticks_per_second=(sint64)((1000.0/(double)elapsed)*(double)t); // Ticks per second return unsigned((double)t/(double)(elapsed*1000)); } @@ -898,8 +901,8 @@ void CPUDetectClass::Init_Memory() void CPUDetectClass::Init_OS() { - OSVERSIONINFO os; #ifdef WIN32 + OSVERSIONINFO os; os.dwOSVersionInfoSize = sizeof(os); GetVersionEx(&os); @@ -940,9 +943,11 @@ void CPUDetectClass::Init_Processor_Log() SYSLOG(("Operating System: ")); switch (OSVersionPlatformId) { +#ifdef _WIN32 case VER_PLATFORM_WIN32s: SYSLOG(("Windows 3.1")); break; case VER_PLATFORM_WIN32_WINDOWS: SYSLOG(("Windows 9x")); break; case VER_PLATFORM_WIN32_NT: SYSLOG(("Windows NT")); break; +#endif } SYSLOG(("\r\n")); @@ -1223,6 +1228,7 @@ void Get_OS_Info( switch (OSVersionPlatformId) { default: break; +#ifdef _WIN32 case VER_PLATFORM_WIN32_WINDOWS: { for(int i=0;i diff --git a/Core/Libraries/Source/WWVegas/WWLib/mempool.h b/Core/Libraries/Source/WWVegas/WWLib/mempool.h index 9b1c4e5902..e1712b813f 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/mempool.h +++ b/Core/Libraries/Source/WWVegas/WWLib/mempool.h @@ -53,7 +53,7 @@ #include "bittype.h" #include "wwdebug.h" #include "mutex.h" -#include +#include #include #include @@ -157,8 +157,14 @@ class AutoPoolClass ** Macro to declare the allocator for your class. Put this in the cpp file for ** the class. */ +#if defined(_MSC_VER) && _MSC_VER < 1300 #define DEFINE_AUTO_POOL(T,BLOCKSIZE) \ ObjectPoolClass AutoPoolClass::Allocator; +#else +#define DEFINE_AUTO_POOL(T,BLOCKSIZE) \ +template<>\ +ObjectPoolClass AutoPoolClass::Allocator = {} +#endif /*********************************************************************************************** diff --git a/Core/Libraries/Source/WWVegas/WWLib/mutex.cpp b/Core/Libraries/Source/WWVegas/WWLib/mutex.cpp index f63cc81e3b..946090a282 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/mutex.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/mutex.cpp @@ -18,8 +18,9 @@ #include "mutex.h" #include "wwdebug.h" +#ifdef _WIN32 #include - +#endif // ---------------------------------------------------------------------------- diff --git a/Core/Libraries/Source/WWVegas/WWLib/refcount.cpp b/Core/Libraries/Source/WWVegas/WWLib/refcount.cpp index 39dd095ef0..8b0fdecba3 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/refcount.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/refcount.cpp @@ -40,8 +40,9 @@ #include "refcount.h" -#include +// TheSuperHackers @compile feliwir 17/04/2025 include __debugbreak macros +#include #ifndef NDEBUG @@ -174,7 +175,7 @@ void RefCountClass::Add_Ref(void) const // See if programmer set break on for a specific address. if (this == BreakOnReference) { - DebugBreak(); // trigger the debugger + __debugbreak(); // trigger the debugger } Inc_Total_Refs(this); } @@ -201,7 +202,7 @@ void RefCountClass::Dec_Total_Refs(const RefCountClass * obj) // See if programmer set break on for a specific address. if (obj == BreakOnReference) { - DebugBreak(); // trigger the debugger + __debugbreak(); // trigger the debugger } } diff --git a/Core/Libraries/Source/WWVegas/WWLib/systimer.h b/Core/Libraries/Source/WWVegas/WWLib/systimer.h index 44d03a8ba1..4c8ea01624 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/systimer.h +++ b/Core/Libraries/Source/WWVegas/WWLib/systimer.h @@ -38,11 +38,25 @@ #ifndef _SYSTIMER_H #include "always.h" +#ifdef _WIN32 #include #include "mmsys.h" #define TIMEGETTIME SystemTime.Get #define MS_TIMER_SECOND 1000 +#else +#include + +inline unsigned long systimerGetMS(void) +{ + struct timeval tv; + gettimeofday(&tv, NULL); + return (tv.tv_sec * 1000) + (tv.tv_usec / 1000); +} + +#define TIMEGETTIME systimerGetMS +#define MS_TIMER_SECOND 1000 +#endif /* ** Class that just wraps around timeGetTime() diff --git a/Core/Libraries/Source/WWVegas/WWLib/thread.cpp b/Core/Libraries/Source/WWVegas/WWLib/thread.cpp index c6c1f20561..4c8b2f27ed 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/thread.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/thread.cpp @@ -21,13 +21,15 @@ #include "thread.h" #include "Except.h" #include "wwdebug.h" -#include -#include #pragma warning ( push ) #pragma warning ( disable : 4201 ) #include "systimer.h" #pragma warning ( pop ) +#ifdef _WIN32 +#include +#include +#endif ThreadClass::ThreadClass(const char *thread_name, ExceptionHandlerType exception_handler) : handle(0), running(false), thread_priority(0) { diff --git a/Core/Libraries/Source/WWVegas/WWLib/thread.h b/Core/Libraries/Source/WWVegas/WWLib/thread.h index 62259d0b35..4e57301646 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/thread.h +++ b/Core/Libraries/Source/WWVegas/WWLib/thread.h @@ -22,9 +22,6 @@ #if defined(_MSC_VER) #pragma once #endif -#ifdef _UNIX -#include "osdep.h" -#endif #include "always.h" #include "Vector.H" diff --git a/Core/Libraries/Source/WWVegas/WWLib/widestring.h b/Core/Libraries/Source/WWVegas/WWLib/widestring.h index 5d31aa0d16..ed3728483e 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/widestring.h +++ b/Core/Libraries/Source/WWVegas/WWLib/widestring.h @@ -49,9 +49,6 @@ #include "wwstring.h" #include "trim.h" #include -#ifdef _UNIX -#include "osdep.h" -#endif ////////////////////////////////////////////////////////////////////// // diff --git a/Core/Libraries/Source/WWVegas/WWLib/win.h b/Core/Libraries/Source/WWVegas/WWLib/win.h index cf9e4e05d8..a28cfd076c 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/win.h +++ b/Core/Libraries/Source/WWVegas/WWLib/win.h @@ -49,6 +49,8 @@ ** 4069, 4200, 4237, 4103, 4001, 4035, 4164. Makes you wonder, eh? */ +#ifdef _WIN32 + // When including windows, lets just bump the warning level back to 3... #if (_MSC_VER >= 1200) #pragma warning(push, 3) @@ -69,7 +71,6 @@ #pragma warning(pop) #endif -#ifdef _WINDOWS extern HINSTANCE ProgramInstance; extern HWND MainWindow; extern bool GameInFocus; @@ -84,8 +85,8 @@ void __cdecl Print_Win32Error(unsigned long win32Error); #endif // _DEBUG -#else // _WINDOWS +#else // _WIN32 //#include // file does not exist -#endif // _WINDOWS +#endif // _WIN32 #endif // WIN_H diff --git a/Core/Libraries/Source/WWVegas/WWLib/wwfile.cpp b/Core/Libraries/Source/WWVegas/WWLib/wwfile.cpp index 8d724d7f97..0d3c47e535 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/wwfile.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/wwfile.cpp @@ -39,6 +39,9 @@ #include #include "WWFILE.H" +// TheSuperHackers @compile feliwir 17/04/2025 include _vsnprintf macros +#include + #pragma warning(disable : 4514) int FileClass::Printf(char *str, ...) diff --git a/Core/Libraries/Source/WWVegas/WWLib/wwstring.cpp b/Core/Libraries/Source/WWVegas/WWLib/wwstring.cpp index 3a8aaa6728..84c2556bd3 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/wwstring.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/wwstring.cpp @@ -35,7 +35,6 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "wwstring.h" -#include "win.h" #include "wwmemlog.h" #include "mutex.h" #include @@ -102,7 +101,7 @@ StringClass::Get_String (int length, bool is_temp) // // Grab this unused buffer for our string // - unsigned temp_string=reinterpret_cast(m_TempStrings); + unsigned long temp_string=reinterpret_cast(m_TempStrings); temp_string+=MAX_TEMP_BYTES*MAX_TEMP_STRING; temp_string&=~(MAX_TEMP_BYTES*MAX_TEMP_STRING-1); temp_string+=index*MAX_TEMP_BYTES; @@ -197,8 +196,8 @@ StringClass::Free_String (void) { if (m_Buffer != m_EmptyString) { - unsigned buffer_base=reinterpret_cast(m_Buffer-sizeof (StringClass::_HEADER)); - unsigned temp_base=reinterpret_cast(m_TempStrings+MAX_TEMP_BYTES*MAX_TEMP_STRING); + unsigned long buffer_base=reinterpret_cast(m_Buffer-sizeof (StringClass::_HEADER)); + unsigned long temp_base=reinterpret_cast(m_TempStrings+MAX_TEMP_BYTES*MAX_TEMP_STRING); if ((buffer_base>>11)==(temp_base>>11)) { m_Buffer[0] = 0; @@ -321,7 +320,7 @@ bool StringClass::Copy_Wide (const WCHAR *source) if (source != NULL) { int length; - BOOL unmapped; + int unmapped; length = WideCharToMultiByte (CP_ACP, 0 , source, -1, NULL, 0, NULL, &unmapped); if (length > 0) { diff --git a/Core/Libraries/Source/WWVegas/WWLib/wwstring.h b/Core/Libraries/Source/WWVegas/WWLib/wwstring.h index 6d8f9d76cc..be8e25e560 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/wwstring.h +++ b/Core/Libraries/Source/WWVegas/WWLib/wwstring.h @@ -46,11 +46,10 @@ #include "win.h" #include #include -#include #include "trim.h" #include "wwdebug.h" -#ifdef _UNIX -#include "osdep.h" +#ifdef _WIN32 +#include #endif diff --git a/GeneralsMD/Code/Tools/wdump/CMakeLists.txt b/GeneralsMD/Code/Tools/wdump/CMakeLists.txt index 417d751ab6..a363e40260 100644 --- a/GeneralsMD/Code/Tools/wdump/CMakeLists.txt +++ b/GeneralsMD/Code/Tools/wdump/CMakeLists.txt @@ -19,6 +19,7 @@ target_sources(z_wdump PRIVATE ${WDUMP_SRC}) target_link_libraries(z_wdump PRIVATE core_config + core_utility core_wwstub # avoid linking GameEngine dbghelplib imm32 diff --git a/cmake/config-build.cmake b/cmake/config-build.cmake index 4fa2973928..ab82f88a5f 100644 --- a/cmake/config-build.cmake +++ b/cmake/config-build.cmake @@ -31,6 +31,10 @@ if(MSVC) target_compile_definitions(core_config INTERFACE _CRT_NONSTDC_NO_WARNINGS _CRT_SECURE_NO_WARNINGS $<$:_DEBUG_CRT>) endif() +if(UNIX) + target_compile_definitions(core_config INTERFACE _UNIX) +endif() + if(RTS_BUILD_OPTION_DEBUG) target_compile_definitions(core_config INTERFACE _DEBUG WWDEBUG DEBUG) else()