Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
35cd301
Remove unit tests and Unity test framework
jeff-1amstudios Apr 10, 2026
c0a483f
Remove leftover _unittest symbols
jeff-1amstudios Apr 10, 2026
ede2efb
Build dethrace directly without object library
jeff-1amstudios Apr 10, 2026
9d52269
Remove null harness platform
jeff-1amstudios Apr 10, 2026
4b3ce4d
massage
jeff-1amstudios Apr 10, 2026
f08480d
Merge branch 'main' into remove-unit-tests-and-framework
jeff-1amstudios Apr 10, 2026
57f45e8
Merge branch 'main' into remove-unit-tests-and-framework
madebr Jun 30, 2026
4e30d9e
Merge branch 'main' into remove-unit-tests-and-framework
madebr Jun 30, 2026
44c3193
Add DETHRACE_DEFAULT_BREAK
madebr Jun 30, 2026
e91c283
fixes
madebr Jun 30, 2026
6d404df
Fix -Wsometimes-uninitialized warning
madebr Jun 30, 2026
38f79dc
Use identical indentation for DETHRACE_DEFAULT_BREAK
madebr Jun 30, 2026
c24f84f
Fix -Warray-bounds warning warning
madebr Jun 30, 2026
9796594
Fix -Warray-bounds warning warning
madebr Jun 30, 2026
3ee651c
Fix -Warray-bounds warning warning
madebr Jun 30, 2026
997e197
Fix -Wpointer-sign warning
madebr Jun 30, 2026
6696c44
Ignore Wformat-overflow
madebr Jun 30, 2026
349481d
Fix -Wmaybe-uninitialized warning
madebr Jun 30, 2026
2b8c232
Fix -Wmaybe-uninitialized warning (nodes_referenced_by_sections_array…
madebr Jun 30, 2026
3edb7bb
Fix -Wmaybe-uninitialized warning (nodes_referenced_by_sections_array…
madebr Jun 30, 2026
bfedf52
Fix -Wmaybe-uninitialized warning (nodes_referenced_by_sections_array…
madebr Jun 30, 2026
2c090dc
Fix -Wmaybe-uninitialized warning
madebr Jun 30, 2026
2870505
Fix -Wmaybe-uninitialized warning
madebr Jun 30, 2026
357b8d3
Fix -Wmaybe-uninitialized warning
madebr Jun 30, 2026
10db63c
Fix -Wmaybe-uninitialized warning
madebr Jun 30, 2026
cabbbfc
Fix -Wmaybe-uninitialized warning
madebr Jun 30, 2026
1e9ea6f
Fix -Wmaybe-uninitialized warning
madebr Jun 30, 2026
a957ee9
Fix -Wmaybe-uninitialized warning
madebr Jun 30, 2026
5d46db4
Fix -Wmaybe-uninitialized warning
madebr Jun 30, 2026
e4e2798
Fix -Wmaybe-uninitialized warning
madebr Jun 30, 2026
7e65552
Fix -Wmaybe-uninitialized warning
madebr Jun 30, 2026
78a5e4b
Fix -Wmaybe-uninitialized warning
madebr Jun 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")

set(DETHRACE_IDE_ARGUMENTS "" CACHE STRING "DethRace arguments (only used by MSVC when debugging")
set(DETHRACE_IDE_ROOT_DIR "" CACHE PATH "DethRace rootdir (only used by MSVC when debugging)")
option(BUILD_TESTS "Build unit tests." OFF)
option(DETHRACE_INSTALL "Add install target" OFF)
option(DETHRACE_WERROR "Treat warnings as errors")
option(DETHRACE_FIX_BUGS "Fix Dethrace bugs" ON)
Expand Down Expand Up @@ -165,11 +164,6 @@ if(DETHRACE_WERROR)
endif()
endif()

if(BUILD_TESTS)
enable_testing()
add_subdirectory(test)
endif()

if(DETHRACE_INSTALL)
install(FILES LICENSE
DESTINATION "${CMAKE_INSTALL_DOCDIR}"
Expand Down
108 changes: 52 additions & 56 deletions src/DETHRACE/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,36 +1,66 @@
# Create object files so we can link them into the main binary and into tests without building twice.
add_library(dethrace_obj OBJECT)

option(DETHRACE_REPLAY_DEBUG "Debug replay" OFF)

target_include_directories(dethrace_obj
# Create our main game binary.
if(MSVC_42_FOR_RECCMP)
add_executable(dethrace WIN32)

set(CMAKE_C_FLAGS_DEBUG "/Oi /Zi /MLd /G5 /w")

add_compile_definitions(_DEBUG)
set_target_properties(dethrace PROPERTIES OUTPUT_NAME "CARM95")
target_link_options(dethrace PRIVATE /INCREMENTAL:NO /subsystem:windows /ENTRY:mainCRTStartup)
target_link_libraries(dethrace PRIVATE ws2_32)

file(GLOB DETHRACE_COMMON_C_FILES "${CMAKE_CURRENT_SOURCE_DIR}/common/*.c")
set_source_files_properties(${DETHRACE_COMMON_C_FILES} PROPERTIES COMPILE_FLAGS "/FAs")

reccmp_add_target(dethrace ID CARM95)
reccmp_configure()
else()
add_executable(dethrace
WIN32
${CMAKE_SOURCE_DIR}/packaging/macos/dethrace.icns
${CMAKE_SOURCE_DIR}/packaging/windows/dethrace.rc
)
get_property(build_rpaths GLOBAL PROPERTY DETHRACE_BUILD_RPATHS)
set_property(TARGET dethrace APPEND PROPERTY BUILD_RPATH "${build_rpaths}")

if(MSVC)
target_link_libraries(dethrace PRIVATE dbghelp)
target_link_options(dethrace PRIVATE /subsystem:windows /ENTRY:mainCRTStartup)
target_compile_definitions(dethrace PRIVATE -D_CRT_SECURE_NO_WARNINGS -DSDL_MAIN_HANDLED -DWIN32_LEAN_AND_MEAN)
endif()
endif()

target_include_directories(dethrace
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
common
pd
)

if(DETHRACE_ASAN)
target_compile_options(dethrace_obj PUBLIC -fsanitize=address)
target_link_options(dethrace_obj PUBLIC -fsanitize=address)
target_compile_options(dethrace PUBLIC -fsanitize=address)
target_link_options(dethrace PUBLIC -fsanitize=address)
endif()

target_link_libraries(dethrace_obj PUBLIC smackw32 harness BRender::Full BRender::DDI s3)
target_link_libraries(dethrace PRIVATE smackw32 harness BRender::Full BRender::DDI s3 compile_with_werror)

if(MSVC_42_FOR_RECCMP)
# do nothing
elseif(MSVC)
target_compile_definitions(dethrace_obj PRIVATE -D_CRT_SECURE_NO_WARNINGS)
target_compile_options(dethrace_obj PRIVATE
target_compile_definitions(dethrace PRIVATE -D_CRT_SECURE_NO_WARNINGS)
target_compile_options(dethrace PRIVATE
/wd4101
/wd4996
)
else()
target_compile_options(dethrace_obj PRIVATE
target_compile_options(dethrace PRIVATE
-Wall
)
add_compile_flags_if_supported(dethrace_obj
add_compile_flags_if_supported(dethrace
-Wformat
-Wno-format-overflow
-Wno-unused-but-set-variable
-Wno-unused-variable
-Wno-unused-result
Expand All @@ -39,31 +69,31 @@ else()
)
endif()

target_compile_definitions(dethrace_obj PRIVATE INSIDE_DETHRACE)
target_compile_definitions(dethrace PRIVATE INSIDE_DETHRACE)

if(DETHRACE_FIX_BUGS)
target_compile_definitions(dethrace_obj PRIVATE DETHRACE_FIX_BUGS)
target_compile_definitions(dethrace PRIVATE DETHRACE_FIX_BUGS)
endif()

if(DETHRACE_3DFX_PATCH)
target_compile_definitions(dethrace_obj PRIVATE DETHRACE_3DFX_PATCH)
target_compile_definitions(dethrace PRIVATE DETHRACE_3DFX_PATCH)
endif()

if(IS_BIGENDIAN)
target_compile_definitions(dethrace_obj PRIVATE BR_ENDIAN_BIG=1)
target_compile_definitions(dethrace PRIVATE BR_ENDIAN_BIG=1)
else()
target_compile_definitions(dethrace_obj PRIVATE BR_ENDIAN_LITTLE=1)
target_compile_definitions(dethrace PRIVATE BR_ENDIAN_LITTLE=1)
endif()

if(DETHRACE_REPLAY_DEBUG)
target_compile_definitions(dethrace_obj PRIVATE DETHRACE_REPLAY_DEBUG)
target_compile_definitions(dethrace PRIVATE DETHRACE_REPLAY_DEBUG)
endif()

if(MINGW)
target_compile_options(dethrace_obj PRIVATE -Wno-error=incompatible-pointer-types)
target_compile_options(dethrace PRIVATE -Wno-error=incompatible-pointer-types)
endif()

target_sources(dethrace_obj PRIVATE
target_sources(dethrace PRIVATE
common/skidmark.c
common/opponent.c
common/oil.c
Expand Down Expand Up @@ -177,45 +207,11 @@ target_sources(dethrace_obj PRIVATE
)

if(MSVC_42_FOR_RECCMP)
target_sources(dethrace_obj PRIVATE pc-win95/win95net.c)
target_sources(dethrace PRIVATE pc-win95/win95net.c)
else()
# dethrace-added cross platform sys and network implementation
target_sources(dethrace_obj PRIVATE pc-all/allnet.c)
target_sources(dethrace PRIVATE pc-all/allnet.c)
endif()

# Create our main game binary.
if(MSVC_42_FOR_RECCMP)
add_executable(dethrace WIN32)

set(CMAKE_C_FLAGS_DEBUG "/Oi /Zi /MLd /G5 /w")

add_compile_definitions(_DEBUG)
set_target_properties(dethrace PROPERTIES OUTPUT_NAME "CARM95")
target_link_options(dethrace PRIVATE /INCREMENTAL:NO /subsystem:windows /ENTRY:mainCRTStartup)
target_link_libraries(dethrace PRIVATE ws2_32)

file(GLOB DETHRACE_COMMON_C_FILES "${CMAKE_CURRENT_SOURCE_DIR}/common/*.c")
set_source_files_properties(${DETHRACE_COMMON_C_FILES} PROPERTIES COMPILE_FLAGS "/FAs")

reccmp_add_target(dethrace ID CARM95)
reccmp_configure()
else()
add_executable(dethrace
WIN32
${CMAKE_SOURCE_DIR}/packaging/macos/dethrace.icns
${CMAKE_SOURCE_DIR}/packaging/windows/dethrace.rc
)
get_property(build_rpaths GLOBAL PROPERTY DETHRACE_BUILD_RPATHS)
set_property(TARGET dethrace APPEND PROPERTY BUILD_RPATH "${build_rpaths}")

if(MSVC)
target_link_libraries(dethrace PRIVATE dbghelp)
target_link_options(dethrace PRIVATE /subsystem:windows /ENTRY:mainCRTStartup)
target_compile_definitions(dethrace PRIVATE -D_CRT_SECURE_NO_WARNINGS -DSDL_MAIN_HANDLED -DWIN32_LEAN_AND_MEAN)
endif()
endif()

target_link_libraries(dethrace PRIVATE dethrace_obj compile_with_werror)
target_sources(dethrace PRIVATE main.c)

if(DETHRACE_IDE_ROOT_DIR)
Expand Down Expand Up @@ -252,7 +248,7 @@ if(DETHRACE_INSTALL)
set_source_files_properties(${CMAKE_SOURCE_DIR}/packaging/macos/dethrace.icns PROPERTIES
MACOSX_PACKAGE_LOCATION "Resources"
)
target_sources(dethrace_obj PRIVATE
target_sources(dethrace PRIVATE
${CMAKE_SOURCE_DIR}/packaging/macos/dethrace.icns
)

Expand Down
6 changes: 4 additions & 2 deletions src/DETHRACE/common/car.c
Original file line number Diff line number Diff line change
Expand Up @@ -762,8 +762,6 @@ void GetFacesInBox(tCollision_info* c) {
}
}

condition_met:

BrMatrix34Mul(&mat5, &mat4, &mat4);
BrMatrix34Mul(&mat6, &mat5, &mat4);
BrMatrix34LPInverse(&mat5, &mat6);
Expand Down Expand Up @@ -7118,6 +7116,10 @@ int DoCollide(tCollision_info* car1, tCollision_info* car2, br_vector3* r, br_ve
ts = FourPointCollB(f, &M, d, tau1, n);
break;
default:
#ifdef DETHRACE_FIX_BUGS
// Fixes -Wsometimes-uninitialized warning
ts = 0.0f;
#endif
break;
}
if (k > 3) {
Expand Down
12 changes: 6 additions & 6 deletions src/DETHRACE/common/controls.c
Original file line number Diff line number Diff line change
Expand Up @@ -573,8 +573,6 @@ int gInstant_handbrake;
// GLOBAL: CARM95 0x00550554
int gAuto_repair;

int _unittest_controls_lastGetPowerup = 0;

// IDA: void __cdecl AbortRace()
// FUNCTION: CARM95 0x004a0c70
void AbortRace(void) {
Expand Down Expand Up @@ -1872,10 +1870,6 @@ void FlipUpCar(tCar_spec* car) {
// IDA: void __usercall GetPowerup(int pNum@<EAX>)
// FUNCTION: CARM95 0x004a291d
void GetPowerup(int pNum) {

// FIXME: remove unittest variables from dethrace
_unittest_controls_lastGetPowerup = pNum;

GotPowerup(&gProgram_state.current_car, pNum);
}

Expand Down Expand Up @@ -2305,6 +2299,8 @@ void CycleCarTexturingLevel(void) {
case eCTL_full:
NewTextHeadupSlot(eHeadupSlot_misc, 0, 2000, -kFont_MEDIUMHD, GetMiscString(kMiscString_FullCarTextures));
break;

DETHRACE_DEFAULT_BREAK
}
}

Expand All @@ -2326,6 +2322,8 @@ void CycleWallTexturingLevel(void) {
case eWTL_full:
NewTextHeadupSlot(eHeadupSlot_misc, 0, 2000, -kFont_MEDIUMHD, GetMiscString(kMiscString_BestWallTextures));
break;

DETHRACE_DEFAULT_BREAK
}
}

Expand All @@ -2344,6 +2342,8 @@ void CycleRoadTexturingLevel(void) {
case eRTL_full:
NewTextHeadupSlot(eHeadupSlot_misc, 0, 2000, -kFont_MEDIUMHD, GetMiscString(kMiscString_RoadTextures));
break;

DETHRACE_DEFAULT_BREAK
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/DETHRACE/common/crush.c
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,8 @@ void DamageSystems(tCar_spec* pCar, br_vector3* pImpact_point, br_vector3* pEner
FRandomBetween(-energy_magnitude * 50.0f, energy_magnitude * 150.0f),
FRandomBetween(7.0f / energy_magnitude, 25.0f / energy_magnitude));
break;

DETHRACE_DEFAULT_BREAK
}
CheckPiledriverBonus(pCar, pImpact_point, pEnergy_vector);
}
Expand Down
15 changes: 15 additions & 0 deletions src/DETHRACE/common/displays.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,12 @@ void DRPixelmapCleverText2(br_pixelmap* pPixelmap, int pX, int pY, tDR_font* pFo
ch = (unsigned char*)pText;
for (; i < len; i++, ch++) {
if (*ch >= 224) {
#ifdef DETHRACE_FIX_BUGS
// Fixes -Warray-bounds warning (array index 256 is past the end of the array 'tDR_font[21]')
new_font = &gFonts[256 - *ch];
#else
new_font = &gFonts[256] - *ch;
#endif
pY -= (new_font->height - pFont->height) / 2;
pFont = new_font;
} else {
Expand All @@ -264,7 +269,12 @@ void DRPixelmapCleverText2(br_pixelmap* pPixelmap, int pX, int pY, tDR_font* pFo
ch = (unsigned char*)pText;
for (; i < len; i++, ch++) {
if (*ch >= 224) {
#ifdef DETHRACE_FIX_BUGS
// Fixes -Warray-bounds warning (array index 256 is past the end of the array 'tDR_font[21]')
new_font = &gFonts[256 - *ch];
#else
new_font = &gFonts[256] - *ch;
#endif
pY -= (new_font->height - pFont->height) / 2;
pFont = new_font;
} else {
Expand Down Expand Up @@ -747,7 +757,12 @@ int DRTextCleverWidth(tDR_font* pFont, signed char* pText) {

for (i = 0, c = (unsigned char*)pText; i < len; i++, c++) {
if (*c >= 224) {
#ifdef DETHRACE_FIX_BUGS
// Fixes -Warray-bounds warning (array index 256 is past the end of the array 'tDR_font[21]')
pFont = &gFonts[256 - *c];
#else
pFont = &gFonts[256] - *c;
#endif
} else {
result += pFont->width_table[*c - pFont->offset] + (i < (len - 1) ? pFont->spacing : 0);
}
Expand Down
6 changes: 5 additions & 1 deletion src/DETHRACE/common/flicplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -1380,6 +1380,10 @@ void DrawTranslations(tFlic_descriptor* pFlic_info, int pLast_frame) {
width = DRTextWidth(gTrans_fonts[trans->font_index], trans->text);
switch (trans->justification) {
case eJust_left:
#ifdef DETHRACE_FIX_BUGS
// Fix -Wmaybe-uninitialized warning
default:
#endif
x = trans->x;
right_edge = x + width;
break;
Expand Down Expand Up @@ -1989,7 +1993,7 @@ void ServicePanelFlics(int pCopy_to_buffer) {
gPanel_flic[j].the_index,
&gPanel_flic[j],
gPanel_flic_data_length[j],
gPanel_flic_data[j],
(tS8*)gPanel_flic_data[j],
gPanel_buffer[j],
0,
0,
Expand Down
2 changes: 1 addition & 1 deletion src/DETHRACE/common/globvars.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ tSave_game* gPre_race_saved_game;
FILE* gDiagnostic_file;

// GLOBAL: CARM95 0x00521360
br_vector3 gDisabled_vector = { 1000.f, 1000.f, 1000.f };
br_vector3 gDisabled_vector = { { 1000.f, 1000.f, 1000.f } };

// GLOBAL: CARM95 0x0052136c
tU32 gI_am_cheating;
Expand Down
18 changes: 15 additions & 3 deletions src/DETHRACE/common/graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -547,14 +547,18 @@ void BuildColourTable(br_pixelmap* pPalette) {
float distance;

for (i = 0; i < COUNT_OF(gRGB_colours); i++) {
nearest_distance = 196608.f;
nearest_distance = 3.0f * 256.0f * 256.0f;
#ifdef DETHRACE_FIX_BUGS
// Fix -Wmaybe-uninitialized warning
nearest_index = 0;
#endif
red = (gRGB_colours[i] >> 16) & 0xFF;
green = (gRGB_colours[i] >> 8) & 0xFF;
blue = gRGB_colours[i] & 0xFF;
blue = (gRGB_colours[i] >> 0) & 0xFF;
for (j = 0; j < 256; j++) {
distance = sqr(((br_uint_8*)pPalette->pixels)[4 * j + 2] - red)
+ sqr(((br_uint_8*)pPalette->pixels)[4 * j + 1] - green)
+ sqr(((br_uint_8*)pPalette->pixels)[4 * j] - blue);
+ sqr(((br_uint_8*)pPalette->pixels)[4 * j + 0] - blue);

if (distance < nearest_distance) {
nearest_distance = distance;
Expand Down Expand Up @@ -631,6 +635,10 @@ void Copy8BitStripImageTo16Bit(br_pixelmap* pDest, br_int_16 pDest_x, br_int_16
if (height + pDest_y + pOffset_y > pDest->height) {
height = pDest->height - pDest_y - pOffset_y;
}
#ifdef DETHRACE_FIX_BUGS
// Fix -Wmaybe-uninitialized warning
destn_width = 2 * pDest->width;
#endif
if (gBack_screen->type == BR_PMT_RGB_565) {
pDest_x *= 2;
pOffset_x *= 2;
Expand Down Expand Up @@ -1779,6 +1787,10 @@ void RenderShadows(br_actor* pWorld, tTrack_spec* pTrack_spec, br_actor* pCamera
continue;
}

#ifdef DETHRACE_FIX_BUGS
// Fix -Wmaybe-uninitialized warning
distance_factor = 0.0f;
#endif
if (!gAction_replay_mode) {
BrVector3Sub(&camera_to_car, (br_vector3*)gCamera_to_world.m[3], &the_car->car_master_actor->t.t.translate.t);
distance_factor = BrVector3LengthSquared(&camera_to_car);
Expand Down
2 changes: 2 additions & 0 deletions src/DETHRACE/common/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ void ReinitialiseForwardCamera(void) {
&gCamera->t.t.mat,
BrDegreeToAngle(gProgram_state.current_car.head_right_angle));
break;

DETHRACE_DEFAULT_BREAK
}
gCamera->t.t.mat.m[3][0] = gProgram_state.current_car.driver_x_offset;
gCamera->t.t.mat.m[3][1] = gProgram_state.current_car.driver_y_offset;
Expand Down
Loading
Loading