Skip to content

Commit 3318bf5

Browse files
committed
[CMAKE][CORE] Move WWLib and WWDebug to Core
1 parent 0e0a875 commit 3318bf5

File tree

172 files changed

+7008
-690
lines changed

Some content is hidden

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

172 files changed

+7008
-690
lines changed

Core/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
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)
6+
add_library(corei_always INTERFACE)
37

48
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")
12+
target_link_libraries(corei_always INTERFACE
13+
core_utility
14+
corei_libraries_include
15+
)
516

617
# Do we want to build extra SDK stuff or just the game binary?
718
option(RTS_BUILD_CORE_TOOLS "Build core tools" ON)

Core/Libraries/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
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)
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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(WW3D2)
30+
# add_subdirectory(WWDownload)
31+
# add_subdirectory(wwshade)
32+
33+
# Helpful interface to bundle the ww modules together.
34+
add_library(core_wwvegas INTERFACE)
35+
36+
target_include_directories(core_wwvegas INTERFACE
37+
.
38+
#WW3D2
39+
WWDebug
40+
#WWDownload
41+
WWLib
42+
#WWMath
43+
#WWSaveLoad
44+
#Wwutil
45+
#wwshade
46+
)
47+
48+
target_link_libraries(core_wwvegas INTERFACE
49+
# core_ww3d2
50+
core_wwdebug
51+
# core_wwdownload
52+
core_wwlib
53+
# core_wwmath
54+
# core_wwsaveload
55+
# core_wwshade
56+
# core_wwutil
57+
)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Set source files
2+
set(WWDEBUG_SRC
3+
wwdebug.cpp
4+
wwmemlog.cpp
5+
wwprofile.cpp
6+
wwdebug.h
7+
wwhack.h
8+
wwmemlog.h
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+
)

Generals/Code/Libraries/Source/WWVegas/WWDebug/wwdebug.cpp renamed to Core/Libraries/Source/WWVegas/WWDebug/wwdebug.cpp

Lines changed: 78 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** Command & Conquer Generals(tm)
2+
** Command & Conquer Generals Zero Hour(tm)
33
** Copyright 2025 Electronic Arts Inc.
44
**
55
** This program is free software: you can redistribute it and/or modify
@@ -22,13 +22,13 @@
2222
* *
2323
* Project Name : WWDebug *
2424
* *
25-
* $Archive:: /VSS_Sync/wwdebug/wwdebug.cpp $*
25+
* $Archive:: /Commando/Code/wwdebug/wwdebug.cpp $*
2626
* *
27-
* $Author:: Vss_sync $*
27+
* $Author:: Greg_h $*
2828
* *
29-
* $Modtime:: 10/19/00 2:12p $*
29+
* $Modtime:: 1/13/02 1:46p $*
3030
* *
31-
* $Revision:: 13 $*
31+
* $Revision:: 16 $*
3232
* *
3333
*---------------------------------------------------------------------------------------------*
3434
* Functions: *
@@ -50,6 +50,8 @@
5050
#include <stdio.h>
5151
#include <assert.h>
5252
#include <string.h>
53+
#include <signal.h>
54+
#include "Except.h"
5355

5456

5557
static PrintFunc _CurMessageHandler = NULL;
@@ -93,7 +95,7 @@ int Get_Last_System_Error()
9395
* 2/19/98 GTH : Created. *
9496
*=============================================================================================*/
9597
PrintFunc WWDebug_Install_Message_Handler(PrintFunc func)
96-
{
98+
{
9799
PrintFunc tmp = _CurMessageHandler;
98100
_CurMessageHandler = func;
99101
return tmp;
@@ -192,13 +194,13 @@ ProfileFunc WWDebug_Install_Profile_Stop_Handler(ProfileFunc func)
192194
* HISTORY: *
193195
* 2/19/98 GTH : Created. *
194196
*=============================================================================================*/
195-
#ifdef WWDEBUG
197+
196198
void WWDebug_Printf(const char * format,...)
197199
{
198200
if (_CurMessageHandler != NULL) {
199-
201+
200202
va_list va;
201-
char buffer[1024];
203+
char buffer[4096];
202204

203205
va_start(va, format);
204206
vsprintf(buffer, format, va);
@@ -209,7 +211,6 @@ void WWDebug_Printf(const char * format,...)
209211

210212
}
211213
}
212-
#endif
213214

214215
/***********************************************************************************************
215216
* WWDebug_Printf_Warning -- Internal function for passing messages to installed handler *
@@ -223,13 +224,13 @@ void WWDebug_Printf(const char * format,...)
223224
* HISTORY: *
224225
* 2/19/98 GTH : Created. *
225226
*=============================================================================================*/
226-
#ifdef WWDEBUG
227+
227228
void WWDebug_Printf_Warning(const char * format,...)
228229
{
229230
if (_CurMessageHandler != NULL) {
230-
231+
231232
va_list va;
232-
char buffer[1024];
233+
char buffer[4096];
233234

234235
va_start(va, format);
235236
vsprintf(buffer, format, va);
@@ -240,7 +241,6 @@ void WWDebug_Printf_Warning(const char * format,...)
240241

241242
}
242243
}
243-
#endif
244244

245245
/***********************************************************************************************
246246
* WWDebug_Printf_Error -- Internal function for passing messages to installed handler *
@@ -254,13 +254,13 @@ void WWDebug_Printf_Warning(const char * format,...)
254254
* HISTORY: *
255255
* 2/19/98 GTH : Created. *
256256
*=============================================================================================*/
257-
#ifdef WWDEBUG
257+
258258
void WWDebug_Printf_Error(const char * format,...)
259259
{
260260
if (_CurMessageHandler != NULL) {
261-
261+
262262
va_list va;
263-
char buffer[1024];
263+
char buffer[4096];
264264

265265
va_start(va, format);
266266
vsprintf(buffer, format, va);
@@ -271,7 +271,6 @@ void WWDebug_Printf_Error(const char * format,...)
271271

272272
}
273273
}
274-
#endif
275274

276275
/***********************************************************************************************
277276
* WWDebug_Assert_Fail -- Internal function for passing assert messages to installed handler *
@@ -289,20 +288,70 @@ void WWDebug_Printf_Error(const char * format,...)
289288
void WWDebug_Assert_Fail(const char * expr,const char * file, int line)
290289
{
291290
if (_CurAssertHandler != NULL) {
292-
293-
char buffer[1024];
291+
292+
char buffer[4096];
294293
sprintf(buffer,"%s (%d) Assert: %s\n",file,line,expr);
295294
_CurAssertHandler(buffer);
296295

297296
} else {
298297

299-
assert(0);
298+
/*
299+
// If the exception handler is try to quit the game then don't show an assert.
300+
*/
301+
if (Is_Trying_To_Exit()) {
302+
ExitProcess(0);
303+
}
300304

301-
}
305+
char assertbuf[4096];
306+
sprintf(assertbuf, "Assert failed\n\n. File %s Line %d", file, line);
307+
308+
int code = MessageBoxA(NULL, assertbuf, "WWDebug_Assert_Fail", MB_ABORTRETRYIGNORE|MB_ICONHAND|MB_SETFOREGROUND|MB_TASKMODAL);
309+
310+
if (code == IDABORT) {
311+
raise(SIGABRT);
312+
_exit(3);
313+
}
314+
315+
if (code == IDRETRY) {
316+
WWDEBUG_BREAK
317+
return;
318+
}
319+
}
302320
}
303321
#endif
304322

305323

324+
325+
326+
/***********************************************************************************************
327+
* _assert -- Catch all asserts by overriding lib function *
328+
* *
329+
* *
330+
* *
331+
* INPUT: Assert stuff *
332+
* *
333+
* OUTPUT: Nothing *
334+
* *
335+
* WARNINGS: None *
336+
* *
337+
* HISTORY: *
338+
* 12/11/2001 3:56PM ST : Created *
339+
*=============================================================================================*/
340+
#if 0 //(gth) this is giving me link errors for some reason...
341+
342+
#ifndef W3D_MAX4
343+
#ifdef WWDEBUG
344+
void __cdecl _assert(void *expr, void *filename, unsigned lineno)
345+
{
346+
WWDebug_Assert_Fail((const char*)expr, (const char*)filename, lineno);
347+
}
348+
#endif //WWDEBUG
349+
#endif
350+
351+
#endif
352+
353+
354+
306355
/***********************************************************************************************
307356
* WWDebug_Assert_Fail_Print -- Internal function, passes assert message to handler *
308357
* *
@@ -320,14 +369,14 @@ void WWDebug_Assert_Fail_Print(const char * expr,const char * file, int line,con
320369
{
321370
if (_CurAssertHandler != NULL) {
322371

323-
char buffer[1024];
372+
char buffer[4096];
324373
sprintf(buffer,"%s (%d) Assert: %s %s\n",file,line,expr, string);
325374
_CurAssertHandler(buffer);
326375

327376
} else {
328377

329378
assert(0);
330-
379+
331380
}
332381
}
333382
#endif
@@ -422,7 +471,7 @@ void WWDebug_DBWin32_Message_Handler( const char * str )
422471
if ( !heventDBWIN )
423472
{
424473
//MessageBox(NULL, "DBWIN_BUFFER_READY nonexistent", NULL, MB_OK);
425-
return;
474+
return;
426475
}
427476

428477
/* get a handle to the data synch object */
@@ -431,11 +480,11 @@ void WWDebug_DBWin32_Message_Handler( const char * str )
431480
{
432481
// MessageBox(NULL, "DBWIN_DATA_READY nonexistent", NULL, MB_OK);
433482
CloseHandle(heventDBWIN);
434-
return;
483+
return;
435484
}
436-
485+
437486
hSharedFile = CreateFileMapping((HANDLE)-1, NULL, PAGE_READWRITE, 0, 4096, "DBWIN_BUFFER");
438-
if (!hSharedFile)
487+
if (!hSharedFile)
439488
{
440489
//MessageBox(NULL, "DebugTrace: Unable to create file mapping object DBWIN_BUFFER", "Error", MB_OK);
441490
CloseHandle(heventDBWIN);
@@ -444,7 +493,7 @@ void WWDebug_DBWin32_Message_Handler( const char * str )
444493
}
445494

446495
lpszSharedMem = (LPSTR)MapViewOfFile(hSharedFile, FILE_MAP_WRITE, 0, 0, 512);
447-
if (!lpszSharedMem)
496+
if (!lpszSharedMem)
448497
{
449498
//MessageBox(NULL, "DebugTrace: Unable to map shared memory", "Error", MB_OK);
450499
CloseHandle(heventDBWIN);
@@ -470,4 +519,3 @@ void WWDebug_DBWin32_Message_Handler( const char * str )
470519
return;
471520
}
472521
#endif // WWDEBUG
473-

0 commit comments

Comments
 (0)