No more gcc/clang warnings (#169)

* Change type of DRPixelmapCleverText2 to char*

* Fix warnings emitted due to -Wreturn-type

* Fix BR_ONE_LS redefinition warning

* Fix warnings emitted by -Wparentheses

* Tag FatalError and PDFatalError with noreturn attribute, fixing -Wreturn-type warnings

* Fix string type of TransBrPixelmapText~

* Fix a few -Wmaybe-uninitialized warnings

* Fix -Wformat and -Wpointer-sign warnings in test_datafile.c

* Fix -Wshift-negative-value warning

* Fix -Wpointer-sign warning

* chdir is declared with attribute 'warn_unused_result'

* Fix -Wmaybe-uninitialized warning

* Fix -Warray-bounds warning

* Fix -Wmaybe-unitialized warning

* Fix -Wmaybe-unitialized warning

* Fix -Wmaybe-unitialized warning

* Fix -Wmaybe-unitialized warnings

* Fix a few -Wmaybe-uninitialized warnings

* cmake: unify warnings amongst gcc and clang

* fatalerror_fixup

* Fix -Wabsolute-value warning

* Fix all warnings when building with MinGW on Windows

* Fix warning caused by -Wimplicit-fallthrough

* Fix warnings caused by -Wcast-function-type

Fixes these types of warnings:
cast between incompatible function types from ‘br_uint_32 (*)(br_actor *, void *)’ {aka ‘unsigned int (*)(struct br_actor *, void *)’} to ‘intptr_t (*)(br_actor *, void *)’ {aka ‘long int (*)(struct br_actor *, void *)’} [-Wcast-function-type]

* Fix warning caused by -Wmissing-field-initializers

* Normalize direction_v vector and store in displacement
This commit is contained in:
Anonymous Maarten 2022-09-24 07:42:58 +02:00 committed by GitHub
parent 8e576ddbe3
commit b5ccfe7dd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 259 additions and 150 deletions

View File

@ -8,6 +8,7 @@ project(dethrace C)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/")
include(CheckCCompilerFlag)
include(GNUInstallDirs)
include(TestBigEndian)
@ -28,6 +29,21 @@ option(BUILD_TESTS "Build unit tests." OFF)
option(DETHRACE_INSTALL "Add install target" OFF)
option(DETHRACE_WERROR "Treat warnings as errors")
function(add_compile_flag_if_supported TARGET FLAG)
string(MAKE_C_IDENTIFIER "${FLAG}" FLAG_TO_IDENTIFIER)
set(HAVE_FLAG_VARIABLE_NAME "HAVE_${FLAG_TO_IDENTIFIER}")
check_c_compiler_flag("${FLAG}" "${HAVE_FLAG_VARIABLE_NAME}")
if(${HAVE_FLAG_VARIABLE_NAME})
target_compile_options("${TARGET}" PRIVATE "${FLAG}")
endif()
endfunction()
function(add_compile_flags_if_supported TARGET)
foreach(FLAG ${ARGN})
add_compile_flag_if_supported("${TARGET}" "${FLAG}")
endforeach()
endfunction()
test_big_endian(IS_BIGENDIAN)
find_package(SDL2 REQUIRED)

View File

@ -2,8 +2,8 @@
#define _FIXED_H_
#include "brender/br_types.h"
#include "brender/br_inline_funcs.h"
#define BR_ONE_LS ((br_fixed_ls)0x00010000)
#define BR_ONE_LU ((br_fixed_lu)0x00010000)
#define BR_ONE_LSF ((br_fixed_ls)0x00008000)
#define BR_ONE_LUF ((br_fixed_lu)0x00010000)
@ -11,10 +11,10 @@
#define BR_ONE_SU ((br_fixed_ss)0x0100)
#define BR_ONE_SSF ((br_fixed_ss)0x0080)
#define BR_ONE_SUF ((br_fixed_ss)0x0100)
#define BrIntToFixed(i) ((i)<<16)
#define BrIntToFixed(i) ((br_fixed_ls)(((unsigned)(i))<<16))
#define BrFloatToFixed(f) ((br_fixed_ls)((f)*65536.f))
#define BrFixedToInt(i) ((i)>>16)
#define BrFixedToFloat(i) ((float)((i)*(1.f/65536.f)))
//#define BrFixedToFloat(i) ((float)((i)*(1.f/65536.f)))
#define BrFloatToFixedFraction(f) ((br_fixed_lsf)((f)*32768.f))
#define BrFixedFractionToFloat(f) ((float)(((br_fixed_lsf)(f))*(1.f/32768.f)))

View File

@ -3,29 +3,29 @@
#include "brender/br_types.h"
br_face default_model_faces[12] = {
{ { 0, 1, 2, }, 1, NULL, 0, 0, 0, 0, BR_MATF_SMOOTH, },
{ { 0, 2, 3, }, 1, NULL, 0, 0, 0, 0, BR_MATF_LIGHT, },
{ { 0, 4, 5, }, 1, NULL, 0, 0, 0, 0, BR_MATF_SMOOTH, },
{ { 0, 5, 1, }, 1, NULL, 0, 0, 0, 0, BR_MATF_LIGHT, },
{ { 1, 5, 6, }, 1, NULL, 0, 0, 0, 0, BR_MATF_SMOOTH, },
{ { 1, 6, 2, }, 1, NULL, 0, 0, 0, 0, BR_MATF_LIGHT, },
{ { 2, 6, 7, }, 1, NULL, 0, 0, 0, 0, BR_MATF_SMOOTH, },
{ { 2, 7, 3, }, 1, NULL, 0, 0, 0, 0, BR_MATF_LIGHT, },
{ { 3, 7, 4, }, 1, NULL, 0, 0, 0, 0, BR_MATF_SMOOTH, },
{ { 3, 4, 0, }, 1, NULL, 0, 0, 0, 0, BR_MATF_LIGHT, },
{ { 4, 7, 6, }, 1, NULL, 0, 0, 0, 0, BR_MATF_SMOOTH, },
{ { 4, 6, 5, }, 1, NULL, 0, 0, 0, 0, BR_MATF_LIGHT, },
{ { 0, 1, 2, }, 1, NULL, 0, 0, 0, 0, BR_MATF_SMOOTH, 0, 0, { { 0 } }, 0.f },
{ { 0, 2, 3, }, 1, NULL, 0, 0, 0, 0, BR_MATF_LIGHT, 0, 0, { { 0 } }, 0.f, },
{ { 0, 4, 5, }, 1, NULL, 0, 0, 0, 0, BR_MATF_SMOOTH, 0, 0, { { 0 } }, 0.f, },
{ { 0, 5, 1, }, 1, NULL, 0, 0, 0, 0, BR_MATF_LIGHT, 0, 0, { { 0 } }, 0.f, },
{ { 1, 5, 6, }, 1, NULL, 0, 0, 0, 0, BR_MATF_SMOOTH, 0, 0, { { 0 } }, 0.f, },
{ { 1, 6, 2, }, 1, NULL, 0, 0, 0, 0, BR_MATF_LIGHT, 0, 0, { { 0 } }, 0.f, },
{ { 2, 6, 7, }, 1, NULL, 0, 0, 0, 0, BR_MATF_SMOOTH, 0, 0, { { 0 } }, 0.f, },
{ { 2, 7, 3, }, 1, NULL, 0, 0, 0, 0, BR_MATF_LIGHT, 0, 0, { { 0 } }, 0.f, },
{ { 3, 7, 4, }, 1, NULL, 0, 0, 0, 0, BR_MATF_SMOOTH, 0, 0, { { 0 } }, 0.f, },
{ { 3, 4, 0, }, 1, NULL, 0, 0, 0, 0, BR_MATF_LIGHT, 0, 0, { { 0 } }, 0.f, },
{ { 4, 7, 6, }, 1, NULL, 0, 0, 0, 0, BR_MATF_SMOOTH, 0, 0, { { 0 } }, 0.f, },
{ { 4, 6, 5, }, 1, NULL, 0, 0, 0, 0, BR_MATF_LIGHT, 0, 0, { { 0 } }, 0.f, },
};
br_vertex default_model_vertices[8] = {
{ { { -1.f, -1.f, 1.f }, }, { { .0f, .99f, }, }, },
{ { { 1.f, -1.f, 1.f }, }, { { .99f, .99f, }, }, },
{ { { 1.f, 1.f, 1.f }, }, { { .99f, .99f, }, }, },
{ { { -1.f, 1.f, 1.f }, }, { { .0f, .99f, }, }, },
{ { { -1.f, -1.f, -1.f }, }, { { .0f, .0f, }, }, },
{ { { 1.f, -1.f, -1.f }, }, { { .99f, .0f, }, }, },
{ { { 1.f, 1.f, -1.f }, }, { { .99f, .0f, }, }, },
{ { { -1.f, 1.f, -1.f }, }, { { .0f, .0f, }, }, },
{ { { -1.f, -1.f, 1.f }, }, { { .0f, .99f, }, }, 0, 0, 0, 0, 0, { { 0 } }, },
{ { { 1.f, -1.f, 1.f }, }, { { .99f, .99f, }, }, 0, 0, 0, 0, 0, { { 0 } }, },
{ { { 1.f, 1.f, 1.f }, }, { { .99f, .99f, }, }, 0, 0, 0, 0, 0, { { 0 } }, },
{ { { -1.f, 1.f, 1.f }, }, { { .0f, .99f, }, }, 0, 0, 0, 0, 0, { { 0 } }, },
{ { { -1.f, -1.f, -1.f }, }, { { .0f, .0f, }, }, 0, 0, 0, 0, 0, { { 0 } }, },
{ { { 1.f, -1.f, -1.f }, }, { { .99f, .0f, }, }, 0, 0, 0, 0, 0, { { 0 } }, },
{ { { 1.f, 1.f, -1.f }, }, { { .99f, .0f, }, }, 0, 0, 0, 0, 0, { { 0 } }, },
{ { { -1.f, 1.f, -1.f }, }, { { .0f, .0f, }, }, 0, 0, 0, 0, 0, { { 0 } }, },
};
br_model _BrDefaultModel = {
@ -37,4 +37,11 @@ br_model _BrDefaultModel = {
BR_ASIZE(default_model_faces),
{ { 0.f, 0.f, 0.f,}, },
BR_MODF_UPDATEABLE,
NULL,
NULL,
0,
0.f,
{ { { 0 } }, { { 0 } } },
NULL,
NULL,
};

View File

@ -40,7 +40,7 @@ fmt_vertex bounds_vertices[8] = {
{ { { 1.0f, 1.0f, 1.0f } }, { { 1.0f, 1.0f } }, { { 0.333f, 0.666f, 0.666f } } },
};
v11group bounds_face_groups[1] = {
{ NULL, bounds_faces, bounds_colours, NULL, bounds_vertices, bounds_colours, NULL, BR_ASIZE(bounds_faces), BR_ASIZE(bounds_vertices), 18 },
{ NULL, bounds_faces, bounds_colours, NULL, bounds_vertices, bounds_colours, NULL, BR_ASIZE(bounds_faces), BR_ASIZE(bounds_vertices), 18, NULL },
};
v11model bounds_prepared = { 0, 0, BR_ASIZE(bounds_face_groups), { { 0 } }, bounds_face_groups };
br_model bounds_model = {

View File

@ -107,6 +107,6 @@
BrVector3Scale(v1, v2, _scale); \
} while (0)
#define BR_ONE_LS 65536
#define BR_ONE_LS (0x00010000)
#define BrFixedToFloat(s) ((float)((s) * (1.0 / (float)BR_ONE_LS)))
#endif

View File

@ -12,32 +12,28 @@ target_include_directories(dethrace_obj
target_link_libraries(dethrace_obj PUBLIC SDL2::SDL2 smacker harness brender s3)
if (CMAKE_C_COMPILER_ID MATCHES "Clang")
target_compile_options(dethrace_obj PRIVATE
-Wall
-Wno-return-type
-Wno-unused-variable
-Wno-unused-parameter
-Wno-unused-result
-Wno-error=sign-compare
)
elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(dethrace_obj PRIVATE
-Wall
-Wno-return-type
-Wno-unused-variable
-Wno-unused-parameter
-Wno-unused-result
-Wno-error=sign-compare
-Wno-error=format-overflow
-Wno-error=unused-but-set-variable # (SelectRaceDraw::test2), etc
)
else()
if (CMAKE_C_COMPILER_ID MATCHES "MSVC")
target_compile_definitions(dethrace_obj PRIVATE -D_CRT_SECURE_NO_WARNINGS)
target_compile_options(dethrace_obj PRIVATE
/wd4101
/wd4996
)
else()
target_compile_options(dethrace_obj PRIVATE
-Wall
)
add_compile_flags_if_supported(dethrace_obj
-Wformat
-Wno-unused-but-set-variable
-Wno-unused-variable
-Wno-unused-result
-Wno-error=sign-compare
-Wno-error=format-overflow
-Wno-error=unused-but-set-variable # (SelectRaceDraw::test2), etc
-Wno-format-overflow
)
endif()
if(BRENDER_FIX_BUGS)
target_compile_definitions(dethrace_obj PRIVATE DETHRACE_FIX_BUGS)

View File

@ -6266,7 +6266,7 @@ int FacePointCarCarCollide(tCollision_info* car1, tCollision_info* car2, br_matr
BrMatrix34ApplyV(&pNorm_list[j], &norm, pMsos);
BrMatrix34TApplyV(&pNorm_list[l], &pNorm_list[j], pMoms);
BrVector3Negate(&pNorm_list[l], &pNorm_list[l]);
if (pNorm_list[l].v[0] >= 0.0f != centre.v[0] <= a.v[0] || pNorm_list[l].v[1] >= 0.0f != centre.v[1] <= a.v[1] || pNorm_list[l].v[2] >= 0.0f != a.v[2] >= centre.v[2]
if ((pNorm_list[l].v[0] >= 0.0f) != (centre.v[0] <= a.v[0]) || (pNorm_list[l].v[1] >= 0.0f) != (centre.v[1] <= a.v[1]) || (pNorm_list[l].v[2] >= 0.0f) != (a.v[2] >= centre.v[2])
|| !TestOldMats(car1, car2, 0)) {
pPoint_list[l] = a;
pPoint_list[j] = hp;
@ -6649,25 +6649,22 @@ br_scalar ThreePointCollRecB(br_scalar* f, br_matrix4* m, br_scalar* d, br_vecto
if (f[0] >= 0.0f && f[1] >= 0.0f && f[2] >= 0.0f) {
return ts;
}
if (f[2] >= 0.0f) {
if (f[1] >= 0.0f) {
if (f[0] >= 0.0f) {
return 0.0f;
}
i = 1;
j = 2;
} else {
i = 0;
j = 2;
}
} else {
if (f[2] < 0.f) {
i = 0;
j = 1;
} else if (f[1] < 0.f) {
i = 0;
j = 2;
} else if (f[0] < 0.f) {
i = 1;
j = 2;
} else {
return 0.0f;
}
m->m[0][0] = m->m[0][5 * i];
m->m[0][0] = ((br_scalar*)(m->m))[5 * i];
m->m[1][0] = m->m[j][i];
m->m[0][1] = m->m[i][j];
m->m[1][1] = m->m[0][5 * j];
m->m[1][1] = ((br_scalar*)(m->m))[5 * j];
tau[0] = tau[i];
tau[1] = tau[j];
tau[4] = tau[i + 4];

View File

@ -657,6 +657,12 @@ void DamageSystems(tCar_spec* pCar, br_vector3* pImpact_point, br_vector3* pEner
tImpact_location modified_location;
LOG_TRACE("(%p, %p, %p, %d)", pCar, pImpact_point, pEnergy_vector, pWas_hitting_a_car);
#if defined(DETHRACE_FIX_BUGS)
proportion_x = 0;
proportion_y = 0;
proportion_z = 0;
#endif
pure_energy_magnitude = BrVector3Length(pEnergy_vector);
if (pure_energy_magnitude == 0.0f && !pWas_hitting_a_car) {
return;
@ -932,6 +938,9 @@ int DoCrashEarnings(tCar_spec* pCar1, tCar_spec* pCar2) {
mutual_culpability = 0;
the_time = PDGetTotalTime();
inherited_damage = 0;
#if defined(DETHRACE_FIX_BUGS)
total_units_of_damage = 0;
#endif
if (pCar1->driver <= eDriver_non_car) {
dam_acc_1 = 0;
} else {
@ -971,11 +980,11 @@ int DoCrashEarnings(tCar_spec* pCar1, tCar_spec* pCar2) {
impact_in_moving_direction_2 = car_direction_2 == modified_location_2;
}
if (pCar1->driver >= eDriver_net_human && pCar2) {
if (impact_in_moving_direction_1 && (pCar1->driver < eDriver_net_human || (pCar1->pre_car_col_velocity_car_space.v[2] != 0.0 && pCar1->pre_car_col_velocity_car_space.v[2] > 0.0 != pCar1->gear > 0 && (pCar1->keys.acc != 0 || pCar1->joystick.acc > 0x8000)))) {
if (impact_in_moving_direction_1 && (pCar1->driver < eDriver_net_human || (pCar1->pre_car_col_velocity_car_space.v[2] != 0.0 && (pCar1->pre_car_col_velocity_car_space.v[2] > 0.0) != (pCar1->gear > 0) && (pCar1->keys.acc != 0 || pCar1->joystick.acc > 0x8000)))) {
pCar2->time_last_hit = the_time;
pCar2->last_hit_by = pCar1;
}
} else if (pCar2 && pCar2->driver >= eDriver_net_human && impact_in_moving_direction_2 && (pCar2->driver < eDriver_net_human || (pCar2->pre_car_col_velocity_car_space.v[2] != 0.0f && pCar2->pre_car_col_velocity_car_space.v[2] > 0.0f != pCar2->gear > 0 && (pCar2->keys.acc != 0 || pCar2->joystick.acc > 0x8000)))) {
} else if (pCar2 && pCar2->driver >= eDriver_net_human && impact_in_moving_direction_2 && (pCar2->driver < eDriver_net_human || (pCar2->pre_car_col_velocity_car_space.v[2] != 0.0f && (pCar2->pre_car_col_velocity_car_space.v[2] > 0.0f) != (pCar2->gear > 0) && (pCar2->keys.acc != 0 || pCar2->joystick.acc > 0x8000)))) {
pCar1->time_last_hit = the_time;
pCar1->last_hit_by = pCar2;
}
@ -985,7 +994,7 @@ int DoCrashEarnings(tCar_spec* pCar1, tCar_spec* pCar2) {
&& pCar1->pre_car_col_speed > 0.0005f
&& (pCar1->driver < eDriver_net_human
|| (pCar1->pre_car_col_velocity_car_space.v[2] != 0.0f
&& pCar1->pre_car_col_velocity_car_space.v[2] > 0.0f != pCar1->gear > 0
&& (pCar1->pre_car_col_velocity_car_space.v[2] > 0.0f) != (pCar1->gear > 0)
&& (pCar1->keys.acc != 0 || pCar1->joystick.acc > 0x8000)))) {
car_1_culpable = 1;
}
@ -994,7 +1003,7 @@ int DoCrashEarnings(tCar_spec* pCar1, tCar_spec* pCar2) {
&& pCar2->pre_car_col_speed > 0.0005f
&& (pCar2->driver < eDriver_net_human
|| (pCar2->pre_car_col_velocity_car_space.v[2] != 0.0f
&& pCar2->pre_car_col_velocity_car_space.v[2] > 0.0f != pCar2->gear > 0
&& (pCar2->pre_car_col_velocity_car_space.v[2] > 0.0f) != (pCar2->gear > 0)
&& (pCar2->keys.acc != 0 || pCar2->joystick.acc > 0x8000)))) {
car_2_culpable = 1;
}
@ -1269,6 +1278,7 @@ void DoWheelDamage(tU32 pFrame_period) {
}
break;
default:
TELL_ME_IF_WE_PASS_THIS_WAY();
break;
}
if (gNet_mode == eNet_mode_none || car->driver == eDriver_local_human) {

View File

@ -167,7 +167,7 @@ void DRPixelmapText(br_pixelmap* pPixelmap, int pX, int pY, tDR_font* pFont, cha
}
// IDA: void __usercall DRPixelmapCleverText2(br_pixelmap *pPixelmap@<EAX>, int pX@<EDX>, int pY@<EBX>, tDR_font *pFont@<ECX>, signed char *pText, int pRight_edge)
void DRPixelmapCleverText2(br_pixelmap* pPixelmap, int pX, int pY, tDR_font* pFont, signed char* pText, int pRight_edge) {
void DRPixelmapCleverText2(br_pixelmap* pPixelmap, int pX, int pY, tDR_font* pFont, char* pText, int pRight_edge) {
int i;
int x;
int len;
@ -178,7 +178,7 @@ void DRPixelmapCleverText2(br_pixelmap* pPixelmap, int pX, int pY, tDR_font* pFo
LOG_TRACE("(%p, %d, %d, %p, %p, %d)", pPixelmap, pX, pY, pFont, pText, pRight_edge);
x = pX;
len = strlen((char*)pText);
len = strlen(pText);
ch = (unsigned char*)pText;
if (pX >= 0 && pPixelmap->width >= pRight_edge && pY >= 0 && pY + pFont->height <= pPixelmap->height) {
for (i = 0; i < len; i++) {
@ -395,7 +395,7 @@ void DoHeadups(tU32 pThe_time) {
y_offset + the_headup->y,
the_headup->data.text_info.colour,
the_headup->data.text_info.font,
(signed char*)the_headup->data.text_info.text);
the_headup->data.text_info.text);
break;
case eHeadup_coloured_text:
if (the_headup->clever) {
@ -1574,5 +1574,5 @@ void TransDRPixelmapCleverText(br_pixelmap* pPixelmap, int pX, int pY, tDR_font*
gCached_font = pFont;
}
LoadFont(pFont - gFonts);
DRPixelmapCleverText2(pPixelmap, pX, pY - (TranslationMode() == 0 ? 0 : 2), pFont, (signed char*)pText, pRight_edge);
DRPixelmapCleverText2(pPixelmap, pX, pY - (TranslationMode() == 0 ? 0 : 2), pFont, pText, pRight_edge);
}

View File

@ -46,7 +46,7 @@ int HeadupActive(int pIndex);
void DRPixelmapText(br_pixelmap* pPixelmap, int pX, int pY, tDR_font* pFont, char* pText, int pRight_edge);
void DRPixelmapCleverText2(br_pixelmap* pPixelmap, int pX, int pY, tDR_font* pFont, signed char* pText, int pRight_edge);
void DRPixelmapCleverText2(br_pixelmap* pPixelmap, int pX, int pY, tDR_font* pFont, char* pText, int pRight_edge);
void DeviouslyDimRectangle(br_pixelmap* pPixelmap, int pLeft, int pTop, int pRight, int pBottom, int pKnock_out_corners);

View File

@ -2,6 +2,7 @@
#define _ERRORS_H_
#include "brender/br_types.h"
#include "harness/compiler.h"
#include "dr_types.h"
extern char* gError_messages[126];
@ -11,7 +12,7 @@ extern int gPixel_buffer_size__errors; // suffix added to avoid duplicate symbol
extern int gMouse_was_started__errors; // suffix added to avoid duplicate symbol
extern char* gPixels_copy__errors; // suffix added to avoid duplicate symbol
void FatalError(int pStr_index, ...);
HARNESS_NORETURN void FatalError(int pStr_index, ...);
void NonFatalError(int pStr_index, ...);

View File

@ -1212,6 +1212,8 @@ void DrawTranslations(tFlic_descriptor* pFlic_info, int pLast_frame) {
x = trans->x - width / 2;
right_edge = x + width / 2;
break;
default:
TELL_ME_IF_WE_PASS_THIS_WAY();
}
TransDRPixelmapText(
pFlic_info->the_pixelmap,

View File

@ -1094,6 +1094,9 @@ void ProcessShadow(tCar_spec* pCar, br_actor* pWorld, tTrack_spec* pTrack_spec,
br_face faces[16];
LOG_TRACE("(%p, %p, %p, %p, %p, %f)", pCar, pWorld, pTrack_spec, pCamera, pCamera_to_world_transform, pDistance_factor);
#if defined(DETHRACE_FIX_BUGS)
ray_length = 0.f;
#endif
f_num = 0;
bounds_x_min = pCar->bounds[1].min.v[0] / WORLD_SCALE;
bounds_x_max = pCar->bounds[1].max.v[0] / WORLD_SCALE;
@ -2986,7 +2989,7 @@ void SaveShadeTables() {
PossibleService();
gSaved_table_count = 0;
return BrTableEnum("*", SaveShadeTable, 0);
BrTableEnum("*", SaveShadeTable, 0);
}
// IDA: void __cdecl DisposeSavedShadeTables()
@ -3005,9 +3008,9 @@ void ShadowMode() {
gFancy_shadow = !gFancy_shadow;
if (gFancy_shadow) {
return NewTextHeadupSlot(4, 0, 2000, -4, "Translucent shadow");
NewTextHeadupSlot(4, 0, 2000, -4, "Translucent shadow");
} else {
return NewTextHeadupSlot(4, 0, 2000, -4, "Solid shadow");
NewTextHeadupSlot(4, 0, 2000, -4, "Solid shadow");
}
}

View File

@ -391,10 +391,13 @@ int AddRollingLetter(char pChar, int pX, int pY, tRolling_type rolling_type) {
switch (rolling_type) {
case eRT_looping_random:
let->number_of_letters = 9;
break;
case eRT_looping_single:
let->number_of_letters = 2;
break;
default:
let->number_of_letters = IRandomBetween(3, 9);
break;
}
let->current_offset = (gCurrent_graf_data->save_slot_letter_height * let->number_of_letters);
@ -560,6 +563,9 @@ void ChangeTextTo(int pXcoord, int pYcoord, char* pNew_str, char* pOld_str) {
len = strlen(pOld_str);
len2 = strlen(pNew_str);
#if defined(DETHRACE_FIX_BUGS)
new_type = eRT_looping_random;
#endif
for (i = 0; i < len; i++) {
if (i < len2) {

View File

@ -186,6 +186,9 @@ int DoInterfaceScreen(tInterface_spec* pSpec, int pOptions, int pCurrent_choice)
void* palette_copy;
LOG_TRACE("(%p, %d, %d)", pSpec, pOptions, pCurrent_choice);
#if defined(DETHRACE_FIX_BUGS)
mouse_down = 0;
#endif
entry_status = gProgram_state.prog_status;
gTyping_slot = -1;
EdgeTriggerModeOn();

View File

@ -239,12 +239,19 @@ tS16 FindNearestGeneralSection(tCar_spec* pPursuee, br_vector3* pActor_coords, b
br_vector3* start;
br_vector3* finish;
br_vector3* nearest_node_v;
#if defined(DETHRACE_FIX_BUGS)
br_vector3 zero_vector;
#endif
LOG_TRACE("(%p, %p, %p, %p, %p)", pPursuee, pActor_coords, pPath_direction, pIntersect, pDistance);
nearest_section = -1;
nearest_node_section_no = -1;
closest_distance_squared = BR_SCALAR_MAX;
nearest_node_distance_squared = BR_SCALAR_MAX;
#if defined(DETHRACE_FIX_BUGS)
BrVector3Set(&zero_vector, 0.f, 0.f, 0.f);
nearest_node_v = &zero_vector;
#endif
if (pPursuee != NULL) {
no_sections = pPursuee->my_trail.number_of_nodes - 1;
@ -1761,33 +1768,32 @@ int MassageOpponentPosition(tOpponent_spec* pOpponent_spec, int pMassage_count)
br_vector3 direction_v;
LOG_TRACE("(%p, %d)", pOpponent_spec, pMassage_count);
BrVector3Set(&positive_y_vector, 0, 1, 0);
BrVector3Set(&positive_y_vector, 0.f, 1.f, 0.f);
mat = &pOpponent_spec->car_spec->car_master_actor->t.t.mat;
car_trans = &pOpponent_spec->car_spec->car_master_actor->t.t.translate.t;
if (pMassage_count > 22) {
return 0;
}
if (pMassage_count <= 20) {
} else if (pMassage_count > 20) {
car_trans->v[1] += (pMassage_count - 20) * 2.0f;
return 1;
} else {
direction_v.v[0] = -pOpponent_spec->car_spec->car_master_actor->t.t.mat.m[2][0];
direction_v.v[1] = -pOpponent_spec->car_spec->car_master_actor->t.t.mat.m[2][1];
direction_v.v[2] = -pOpponent_spec->car_spec->car_master_actor->t.t.mat.m[2][2];
if (pMassage_count % 4 >= 2) {
BrVector3Cross(&displacement, &positive_y_vector, &direction_v);
BrVector3Normalise(&displacement, &displacement);
BrVector3Scale(&displacement, &displacement, (pMassage_count / 4) * 0.1f);
} else {
BrVector3Normalise(&displacement, &displacement);
BrVector3Normalise(&displacement, &direction_v);
BrVector3Scale(&displacement, &displacement, (pMassage_count / 4) * 0.5f);
}
if (pMassage_count % 2) {
BrVector3Negate(&displacement, &displacement);
}
BrVector3Accumulate(car_trans, &displacement);
} else {
car_trans->v[1] = (pMassage_count - 20) * 2.0f + car_trans->v[1];
return 1;
}
return 1;
}
// IDA: int __usercall RematerialiseOpponentOnThisSection@<EAX>(tOpponent_spec *pOpponent_spec@<EAX>, br_scalar pSpeed, tS16 pSection_no)

View File

@ -806,6 +806,9 @@ void DrawKeyAssignments(int pCurrent_choice, int pCurrent_mode) {
static int on_radios_last_time;
LOG_TRACE("(%d, %d)", pCurrent_choice, pCurrent_mode);
#if defined(DETHRACE_FIX_BUGS)
font_k = &gFonts[11];
#endif
if (gMouse_in_use && pCurrent_choice == 4) {
GetMousePosition(&x_coord, &y_coord);
if (y_coord >= gCurrent_graf_data->key_assign_key_map_y
@ -1134,6 +1137,7 @@ int MouseyClickBastard(int* pCurrent_choice, int* pCurrent_mode, int pX_offset,
} else {
KeyAssignGoAhead(pCurrent_choice, pCurrent_mode);
}
return 0;
}
// IDA: void __cdecl DrawInitialKMRadios()

View File

@ -375,6 +375,10 @@ int BurstPedestrian(tPedestrian_data* pPedestrian, float pSplattitudinalitude, i
tU32 the_time;
LOG_TRACE("(%p, %f, %d)", pPedestrian, pSplattitudinalitude, pAllow_explosion);
#if defined(DETHRACE_FIX_BUGS)
min_speed = 0;
max_speed = 0;
#endif
exploded = 0;
for (i = 0; i < COUNT_OF(gPed_gib_counts); i++) {
for (j = 0; j < gPed_size_counts[i]; j++) {
@ -716,6 +720,10 @@ int PedestrianNextInstruction(tPedestrian_data* pPedestrian, float pDanger_level
if ((instruction->type == ePed_instruc_fchoice && pPedestrian->instruction_direction > 0)
|| (instruction->type == ePed_instruc_bchoice && pPedestrian->instruction_direction < 0)) {
most_dangerous = -1.f;
#if defined(DETHRACE_FIX_BUGS)
start_index = 0;
end_index = 0;
#endif
for (i = 0; i < instruction->data.choice_data.number_of_choices; i++) {
if (instruction->data.choice_data.choices[i].danger_level <= pDanger_level) {
if (instruction->data.choice_data.choices[i].danger_level > most_dangerous) {
@ -923,6 +931,9 @@ void MungePedestrianFrames(tPedestrian_data* pPedestrian) {
case ePed_frame_variable:
frame_period = 1000.f / FRandomBetween(the_sequence->frame_rate_factor1, the_sequence->frame_rate_factor2);
break;
default:
TELL_ME_IF_WE_PASS_THIS_WAY();
break;
}
if (frame_period == 0.f) {
pPedestrian->current_frame = 0;
@ -1152,6 +1163,10 @@ int MungePedestrianAction(tPedestrian_data* pPedestrian, float pDanger_level) {
return 1;
}
most_dangerous = -1.f;
#if defined(DETHRACE_FIX_BUGS)
start_index = 0;
end_index = 0;
#endif
for (i = 0; i < pPedestrian->number_of_actions; i++) {
if (pPedestrian->action_list[i].danger_level < 999.f
&& pPedestrian->action_list[i].danger_level <= pDanger_level
@ -2943,6 +2958,9 @@ br_actor* BuildPedPaths(tPedestrian_instruction* pInstructions, int pInstruc_cou
}
SquirtPathVertex(&the_model->vertices[vertex_count], &the_point);
vertex_count += 4;
#if defined(DETHRACE_FIX_BUGS)
last_vertex_count = vertex_count;
#endif
if (point_count != 0) {
// Connect previous path vertex cross with current path vertex cross
the_model->faces[face_count].vertices[0] = vertex_count - 4;
@ -3418,7 +3436,7 @@ void DropInitPedPointAir() {
}
// IDA: br_uint_32 __cdecl KillActorsModel(br_actor *pActor, void *pArg)
br_uint_32 KillActorsModel(br_actor* pActor, void* pArg) {
intptr_t KillActorsModel(br_actor* pActor, void* pArg) {
LOG_TRACE("(%p, %p)", pActor, pArg);
if (pActor->model != NULL) {
@ -3433,7 +3451,7 @@ void DisposePedPaths() {
LOG_TRACE("()");
if (gPath_actor != NULL) {
DRActorEnumRecurse(gPath_actor, (br_actor_enum_cbfn*)KillActorsModel, NULL);
DRActorEnumRecurse(gPath_actor, KillActorsModel, NULL);
BrActorRemove(gPath_actor);
BrActorFree(gPath_actor);
BrMaterialRemove(gPath_mat_normal);

View File

@ -239,7 +239,7 @@ void DropPedPointAir();
void DropInitPedPointAir();
br_uint_32 KillActorsModel(br_actor* pActor, void* pArg);
intptr_t KillActorsModel(br_actor* pActor, void* pArg);
void DisposePedPaths();

View File

@ -1115,8 +1115,8 @@ int HitMine(tPowerup* pPowerup, tCar_spec* pCar) {
pCar->omega.v[2] = FRandomPosNeg(pPowerup->float_params[2]) * TAU / pCar->M + pCar->omega.v[2];
pCar->omega.v[0] = FRandomPosNeg(pPowerup->float_params[3]) * TAU / pCar->M + pCar->omega.v[0];
if (pCar->driver != eDriver_non_car_unused_slot && !pCar->invulnerable) {
fudge_multiplier = pCar->car_model_actors[pCar->principal_car_actor].crush_data.softness_factor / .7f;
for (i = 0; i < pCar->car_actor_count; i++) {
fudge_multiplier = pCar->car_model_actors[pCar->principal_car_actor].crush_data.softness_factor / .7f;
TotallySpamTheModel(pCar, i, pCar->car_model_actors[i].actor,
&pCar->car_model_actors[i].crush_data, fudge_multiplier * .1f);
}
@ -1272,6 +1272,9 @@ void SendCurrentPowerups() {
} else {
car = GetCarSpec(cat, i);
}
#if defined(DETHRACE_FIX_BUGS)
ID = gNet_players[0].ID;
#endif
for (j = 0; j < gNumber_of_net_players; j++) {
if (gNet_players[j].car == car) {
ID = gNet_players[j].ID;

View File

@ -194,6 +194,7 @@ int UpRace(int* pCurrent_choice, int* pCurrent_mode) {
MoveRaceList(gCurrent_race_index, gCurrent_race_index - 1, 150);
gCurrent_race_index--;
}
return 0;
}
// IDA: int __usercall DownRace@<EAX>(int *pCurrent_choice@<EAX>, int *pCurrent_mode@<EDX>)
@ -210,6 +211,7 @@ int DownRace(int* pCurrent_choice, int* pCurrent_mode) {
MoveRaceList(gCurrent_race_index, gCurrent_race_index + 1, 150);
gCurrent_race_index++;
}
return 0;
}
// IDA: int __usercall ClickOnRace@<EAX>(int *pCurrent_choice@<EAX>, int *pCurrent_mode@<EDX>, int pX_offset@<EBX>, int pY_offset@<ECX>)
@ -1300,6 +1302,7 @@ int UpOpponent(int* pCurrent_choice, int* pCurrent_mode) {
gCurrent_graf_data->start_race_panel_top,
gCurrent_graf_data->start_race_panel_top_clip,
gCurrent_graf_data->start_race_panel_bottom_clip);
return 0;
}
// IDA: int __usercall DownOpponent@<EAX>(int *pCurrent_choice@<EAX>, int *pCurrent_mode@<EDX>)
@ -1326,6 +1329,7 @@ int DownOpponent(int* pCurrent_choice, int* pCurrent_mode) {
gCurrent_graf_data->start_race_panel_top,
gCurrent_graf_data->start_race_panel_top_clip,
gCurrent_graf_data->start_race_panel_bottom_clip);
return 0;
}
// IDA: int __usercall UpClickOpp@<EAX>(int *pCurrent_choice@<EAX>, int *pCurrent_mode@<EDX>, int pX_offset@<EBX>, int pY_offset@<ECX>)
@ -2268,6 +2272,7 @@ int GridClickLeft(int* pCurrent_choice, int* pCurrent_mode, int pX_offset, int p
LOG_TRACE("(%p, %p, %d, %d)", pCurrent_choice, pCurrent_mode, pX_offset, pY_offset);
GridMoveLeft(pCurrent_choice, pCurrent_mode);
return 0;
}
// IDA: int __usercall GridClickRight@<EAX>(int *pCurrent_choice@<EAX>, int *pCurrent_mode@<EDX>, int pX_offset@<EBX>, int pY_offset@<ECX>)
@ -2275,6 +2280,7 @@ int GridClickRight(int* pCurrent_choice, int* pCurrent_mode, int pX_offset, int
LOG_TRACE("(%p, %p, %d, %d)", pCurrent_choice, pCurrent_mode, pX_offset, pY_offset);
GridMoveRight(pCurrent_choice, pCurrent_mode);
return 0;
}
// IDA: int __usercall CheckChallenge@<EAX>(int *pCurrent_choice@<EAX>, int *pCurrent_mode@<EDX>)

View File

@ -859,7 +859,7 @@ void DamageScrnDraw(int pCurrent_choice, int pCurrent_mode) {
gCurrent_graf_data->wreck_name_base_line,
84,
gFont_7,
(signed char*)name); // FIXME: remove (signed char*) cast
name);
}
}
@ -957,7 +957,7 @@ int DamageScrnUp(int* pCurrent_choice, int* pCurrent_mode) {
new_selection = i;
break;
}
difference = abs(gWreck_array[i].pos_x - gWreck_array[gWreck_selected].pos_x);
difference = abs((int)(gWreck_array[i].pos_x - gWreck_array[gWreck_selected].pos_x));
if (difference < new_difference) {
new_selection = i;
new_difference = difference;

View File

@ -104,18 +104,24 @@ void InitSound() {
if (gSound_available == 0) {
return;
}
if (gSound_detail_level == 0) {
switch (gSound_detail_level) {
case 0:
engine_channel_count = 2;
car_channel_count = 2;
ped_channel_count = 3;
} else if (gSound_detail_level == 1) {
break;
case 1:
engine_channel_count = 2;
car_channel_count = 3;
ped_channel_count = 4;
} else if (gSound_detail_level == 2) {
break;
case 2:
engine_channel_count = 6;
car_channel_count = 4;
ped_channel_count = 5;
break;
default:
TELL_ME_IF_WE_PASS_THIS_WAY();
}
if (gDriver_outlet == NULL) {
gDriver_outlet = S3CreateOutlet(1, 1);
@ -247,12 +253,14 @@ int DRS3ChangePitch(tS3_sound_tag pTag, tS3_pitch pNew_pitch) {
int DRS3ChangeSpeed(tS3_sound_tag pTag, tS3_pitch pNew_speed) {
LOG_TRACE("(%d, %d)", pTag, pNew_speed);
NOT_IMPLEMENTED();
return 0;
}
// IDA: int __usercall DRS3ChangePitchSpeed@<EAX>(tS3_sound_tag pTag@<EAX>, tS3_pitch pNew_pitch@<EDX>)
int DRS3ChangePitchSpeed(tS3_sound_tag pTag, tS3_pitch pNew_pitch) {
LOG_TRACE("(%d, %d)", pTag, pNew_pitch);
STUB_ONCE();
return 0;
}
// IDA: int __usercall DRS3StopSound@<EAX>(tS3_sound_tag pSound_tag@<EAX>)
@ -348,6 +356,7 @@ int DRS3StopAllOutletSounds() {
if (gSound_enabled) {
S3StopAllOutletSounds();
}
return 0;
}
// IDA: void __cdecl ToggleSoundEnable()

View File

@ -1749,7 +1749,7 @@ void ChangeSubdivToPersp() {
}
// IDA: br_uint_32 __cdecl ProcessFaceMaterials(br_actor *pActor, tPMFMCB pCallback)
br_uint_32 ProcessFaceMaterials(br_actor* pActor, tPMFMCB pCallback) {
intptr_t ProcessFaceMaterials(br_actor* pActor, tPMFMCB pCallback) {
LOG_TRACE("(%p, %d)", pActor, pCallback);
if (pActor->identifier == NULL || pActor->identifier[0] != '&') {
@ -2778,20 +2778,21 @@ void LoadTrack(char* pFile_name, tTrack_spec* pTrack_spec, tRace_info* pRace_inf
}
// IDA: br_uint_32 __cdecl RemoveBounds(br_actor *pActor, void *pArg)
br_uint_32 RemoveBounds(br_actor* pActor, void* pArg) {
intptr_t RemoveBounds(br_actor* pActor, void* pArg) {
LOG_TRACE("(%p, %p)", pActor, pArg);
if (pActor->type == BR_ACTOR_BOUNDS || pActor->type == BR_ACTOR_BOUNDS_CORRECT) {
BrResFree(pActor->type_data);
pActor->type_data = NULL;
}
return 0;
}
// IDA: void __usercall RemoveBoundsStructures(br_actor *pActor@<EAX>)
void RemoveBoundsStructures(br_actor* pActor) {
LOG_TRACE("(%p)", pActor);
DRActorEnumRecurse(pActor, (br_actor_enum_cbfn*)RemoveBounds, NULL);
DRActorEnumRecurse(pActor, RemoveBounds, NULL);
}
// IDA: void __usercall FreeTrack(tTrack_spec *pTrack_spec@<EAX>)

View File

@ -183,7 +183,7 @@ void ChangeSubdivToPerspCB(br_material* pMaterial);
void ChangeSubdivToPersp();
br_uint_32 ProcessFaceMaterials(br_actor* pActor, tPMFMCB pCallback);
intptr_t ProcessFaceMaterials(br_actor* pActor, tPMFMCB pCallback);
int DRPixelmapHasZeros(br_pixelmap* pm);
@ -255,7 +255,7 @@ void FreeExceptions();
void LoadTrack(char* pFile_name, tTrack_spec* pTrack_spec, tRace_info* pRace_info);
br_uint_32 RemoveBounds(br_actor* pActor, void* pArg);
intptr_t RemoveBounds(br_actor* pActor, void* pArg);
void RemoveBoundsStructures(br_actor* pActor);

View File

@ -2,6 +2,10 @@
#include "pd/sys.h"
#include <stdlib.h>
#ifdef _WIN32
#include <io.h>
#endif
extern int original_main(int pArgc, char* pArgv[]);
int main(int argc, char* argv[]) {

View File

@ -349,7 +349,7 @@ tPlayer_ID PDNetExtractPlayerID(tNet_game_details* pDetails) {
// IDA: void __usercall PDNetObtainSystemUserName(char *pName@<EAX>, int pMax_length@<EDX>)
void PDNetObtainSystemUserName(char* pName, int pMax_length) {
#ifdef _WIN32
int size;
DWORD size;
char buffer[16];
BOOL result;
@ -359,10 +359,13 @@ void PDNetObtainSystemUserName(char* pName, int pMax_length) {
#ifdef _WIN32
size = COUNT_OF(buffer);
result = GetComputerNameA(buffer, &size);
if (result && size != 0) {
strncpy(pName, buffer, pMax_length - 1);
pName[pMax_length - 1] = '\0';
if (result == 0) {
LOG_WARN("GetComputerNameA failed with code=%u", GetLastError());
buffer[0] = '\0';
size = 0;
}
strncpy(pName, buffer, pMax_length - 1);
pName[pMax_length - 1] = '\0';
while (1) {
pName = strpbrk(pName, "_=(){}[]<>!$%^&*/:@~;'#,?\\|`\"");
if (pName == NULL || *pName == '\0') {

View File

@ -61,7 +61,6 @@ int gReal_back_screen_locked;
void (*gPrev_keyboard_handler)();
tU8 gScan_code[123][2];
int _unittest_do_not_exit = 0;
char* _unittest_last_fatal_error;
// IDA: void __cdecl KeyboardHandler()
@ -254,9 +253,7 @@ void PDFatalError(char* pThe_str) {
LOG_TRACE("(\"%s\")", pThe_str);
if (been_here) {
if (!_unittest_do_not_exit) {
exit(1);
}
exit(1);
}
been_here = 1;
@ -267,9 +264,7 @@ void PDFatalError(char* pThe_str) {
// wait for keypress
if (!_unittest_do_not_exit) {
exit(1);
}
exit(1);
}
// IDA: void __usercall PDNonFatalError(char *pThe_str@<EAX>)

View File

@ -10,6 +10,8 @@
#include "brender/br_types.h"
#include "dr_types.h"
#include "harness/compiler.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
@ -44,7 +46,6 @@ extern int gReal_back_screen_locked;
extern void (*gPrev_keyboard_handler)();
extern tU8 gScan_code[123][2];
extern int _unittest_do_not_exit;
extern char* _unittest_last_fatal_error;
// void KeyboardHandler();
@ -63,7 +64,7 @@ void PDSetKeyArray(int* pKeys, int pMark);
int PDGetASCIIFromKey(int pKey);
void PDFatalError(char* pThe_str);
HARNESS_NORETURN void PDFatalError(char* pThe_str);
void PDNonFatalError(char* pThe_str);

View File

@ -39,6 +39,7 @@ else()
endif()
target_sources(harness PRIVATE
include/harness/compiler.h
include/harness/hooks.h
include/harness/trace.h
include/harness/config.h

View File

@ -0,0 +1,10 @@
#ifndef HARNESS_COMPILER_H
#define HARNESS_COMPILER_H
#if defined(_MSC_VER)
#define HARNESS_NORETURN __declspec(noreturn)
#else
#define HARNESS_NORETURN __attribute__((noreturn))
#endif
#endif

View File

@ -42,10 +42,10 @@ void debug_print_matrix4(const char* fmt, const char* fn, char* name, br_matrix4
#define LOG_PANIC(...) \
do { \
debug_printf("\033[0;31m[PANIC] %s ", __FUNCTION__, __VA_ARGS__); \
if (OS_IsDebuggerPresent()) \
if (OS_IsDebuggerPresent()) { \
abort(); \
else \
exit(1); \
} \
exit(1); \
} while (0)
#define LOG_WARN_ONCE(...) \

View File

@ -1,5 +1,6 @@
#include "tests.h"
#include "CORE/FW/bswap.h"
#include "CORE/FW/datafile.h"
#include "CORE/FW/file.h"
#include "CORE/MATH/fixed.h"
@ -12,6 +13,15 @@
char *text_magics = TEXT_MAGICS;
uint8_t binary_magics[] = {BINARY_MAGICS};
static unsigned float_to_binary(float f) {
union {
float f;
unsigned v;
} u;
u.f = f;
return BrHtoNL(u.v);
}
static void test_datafile_stack() {
int dummy1;
@ -64,9 +74,9 @@ static void test_datafile_stack() {
}
static void test_datafile_magics() {
TEST_ASSERT_EQUAL_INT(BR_FS_MODE_TEXT, DfFileIdentify(text_magics, sizeof(text_magics)));
TEST_ASSERT_EQUAL_INT(BR_FS_MODE_BINARY, DfFileIdentify(binary_magics, sizeof(binary_magics)));
TEST_ASSERT_EQUAL_INT(BR_FS_MODE_UNKNOWN, DfFileIdentify("nonsense", sizeof("nonsense")));
TEST_ASSERT_EQUAL_INT(BR_FS_MODE_TEXT, DfFileIdentify((br_uint_8 *)text_magics, sizeof(text_magics)));
TEST_ASSERT_EQUAL_INT(BR_FS_MODE_BINARY, DfFileIdentify((br_uint_8 *)binary_magics, sizeof(binary_magics)));
TEST_ASSERT_EQUAL_INT(BR_FS_MODE_UNKNOWN, DfFileIdentify((br_uint_8 *)"nonsense", sizeof("nonsense")));
}
typedef struct struct_br_int_8 {
@ -2364,10 +2374,18 @@ static void test_datafile_text_br_vector2_f() {
DfStructReadText(df_r, &struct_br_vector2_f_file, &read_struct);
DfClose(df_r);
printf("0x%08x 0x%08x ", br_vector2_f_ref.m1.v[0], read_struct.m1.v[0]);printf("0x%08x 0x%08x\n", br_vector2_f_ref.m1.v[1], read_struct.m1.v[0]);
printf("0x%08x 0x%08x ", br_vector2_f_ref.m2.v[0], read_struct.m2.v[0]);printf("0x%08x 0x%08x\n", br_vector2_f_ref.m2.v[1], read_struct.m2.v[0]);
printf("0x%08x 0x%08x ", br_vector2_f_ref.m3.v[0], read_struct.m3.v[0]);printf("0x%08x 0x%08x\n", br_vector2_f_ref.m3.v[1], read_struct.m3.v[0]);
printf("0x%08x 0x%08x ", br_vector2_f_ref.m4.v[0], read_struct.m4.v[0]);printf("0x%08x 0x%08x\n", br_vector2_f_ref.m4.v[1], read_struct.m4.v[0]);
printf("0x%08x 0x%08x ", float_to_binary(br_vector2_f_ref.m1.v[0]), float_to_binary(read_struct.m1.v[0]));
printf("0x%08x 0x%08x\n", float_to_binary(br_vector2_f_ref.m1.v[1]), float_to_binary(read_struct.m1.v[0]));
printf("0x%08x 0x%08x ", float_to_binary(br_vector2_f_ref.m2.v[0]), float_to_binary(read_struct.m2.v[0]));
printf("0x%08x 0x%08x\n", float_to_binary(br_vector2_f_ref.m2.v[1]), float_to_binary(read_struct.m2.v[0]));
printf("0x%08x 0x%08x ", float_to_binary(br_vector2_f_ref.m3.v[0]), float_to_binary(read_struct.m3.v[0]));
printf("0x%08x 0x%08x\n", float_to_binary(br_vector2_f_ref.m3.v[1]), float_to_binary(read_struct.m3.v[0]));
printf("0x%08x 0x%08x ", float_to_binary(br_vector2_f_ref.m4.v[0]), float_to_binary(read_struct.m4.v[0]));
printf("0x%08x 0x%08x\n", float_to_binary(br_vector2_f_ref.m4.v[1]), float_to_binary(read_struct.m4.v[0]));
TEST_ASSERT_EQUAL_MEMORY(&br_vector2_f_ref, &read_struct, sizeof(br_vector2_f_ref));
}
@ -2466,10 +2484,18 @@ static void test_datafile_text_br_vector3_f() {
DfStructReadText(df_r, &struct_br_vector3_f_file, &read_struct);
DfClose(df_r);
printf("0x%08x 0x%08x ", br_vector3_f_ref.m1.v[0], read_struct.m1.v[0]);printf("0x%08x 0x%08x\n", br_vector3_f_ref.m1.v[1], read_struct.m1.v[0]);
printf("0x%08x 0x%08x ", br_vector3_f_ref.m2.v[0], read_struct.m2.v[0]);printf("0x%08x 0x%08x\n", br_vector3_f_ref.m2.v[1], read_struct.m2.v[0]);
printf("0x%08x 0x%08x ", br_vector3_f_ref.m3.v[0], read_struct.m3.v[0]);printf("0x%08x 0x%08x\n", br_vector3_f_ref.m3.v[1], read_struct.m3.v[0]);
printf("0x%08x 0x%08x ", br_vector3_f_ref.m4.v[0], read_struct.m4.v[0]);printf("0x%08x 0x%08x\n", br_vector3_f_ref.m4.v[1], read_struct.m4.v[0]);
printf("0x%08x 0x%08x ", float_to_binary(br_vector3_f_ref.m1.v[0]), float_to_binary(read_struct.m1.v[0]));
printf("0x%08x 0x%08x\n", float_to_binary(br_vector3_f_ref.m1.v[1]), float_to_binary(read_struct.m1.v[0]));
printf("0x%08x 0x%08x ", float_to_binary(br_vector3_f_ref.m2.v[0]), float_to_binary(read_struct.m2.v[0]));
printf("0x%08x 0x%08x\n", float_to_binary(br_vector3_f_ref.m2.v[1]), float_to_binary(read_struct.m2.v[0]));
printf("0x%08x 0x%08x ", float_to_binary(br_vector3_f_ref.m3.v[0]), float_to_binary(read_struct.m3.v[0]));
printf("0x%08x 0x%08x\n", float_to_binary(br_vector3_f_ref.m3.v[1]), float_to_binary(read_struct.m3.v[0]));
printf("0x%08x 0x%08x ", float_to_binary(br_vector3_f_ref.m4.v[0]), float_to_binary(read_struct.m4.v[0]));
printf("0x%08x 0x%08x\n", float_to_binary(br_vector3_f_ref.m4.v[1]), float_to_binary(read_struct.m4.v[0]));
TEST_ASSERT_EQUAL_MEMORY(&br_vector3_f_ref, &read_struct, sizeof(br_vector3_f_ref));
}
@ -3039,7 +3065,7 @@ static void test_datafile_binary_block_continguous() {
br_datafile* df_w;
br_datafile* df_r;
char tmpfilename[PATH_MAX+1];
br_uint_32 read_count;
int read_count;
br_uint_16 read_block_continguous[20][8];
br_uint_8 *read_blocks;
@ -3078,7 +3104,7 @@ static void test_datafile_text_block_continguous() {
br_datafile* df_w;
br_datafile* df_r;
char tmpfilename[PATH_MAX+1];
br_uint_32 read_count;
int read_count;
br_uint_16 read_block_continguous[20][8];
br_uint_8 *read_blocks;
@ -3147,7 +3173,7 @@ static void test_datafile_binary_block_striped() {
br_datafile* df_w;
br_datafile* df_r;
char tmpfilename[PATH_MAX+1];
br_uint_32 read_count;
int read_count;
br_uint_16 read_block_striped[20][8];
br_uint_8 *read_blocks;
@ -3186,7 +3212,7 @@ static void test_datafile_text_block_striped() {
br_datafile* df_w;
br_datafile* df_r;
char tmpfilename[PATH_MAX+1];
br_uint_32 read_count;
int read_count;
br_uint_16 read_block_striped[20][8];
br_uint_8 *read_blocks;

View File

@ -60,7 +60,6 @@ target_sources(dethrace_test PRIVATE
BRSRC13/test_v1dbfile.c
DETHRACE/test_controls.c
DETHRACE/test_dossys.c
DETHRACE/test_errors.c
DETHRACE/test_flicplay.c
DETHRACE/test_graphics.c
DETHRACE/test_init.c

View File

@ -1,15 +0,0 @@
#include "tests.h"
#include "common/errors.h"
#include "pd/sys.h"
#include <string.h>
void test_errors_FatalError() {
FatalError(107, "test_errors", "FATAL");
TEST_ASSERT_EQUAL_STRING("Can't open 'test_errors'", _unittest_last_fatal_error);
}
void test_errors_suite() {
UnitySetTestFile(__FILE__);
RUN_TEST(test_errors_FatalError);
}

View File

@ -62,7 +62,7 @@ void test_utility_GetALineWithNoPossibleService() {
fclose(file);
file = fopen(tmpPath, "rt");
char s[256];
unsigned char s[256];
char* result = GetALineWithNoPossibleService(file, s);
TEST_ASSERT_NOT_NULL(result);

View File

@ -30,8 +30,6 @@
#define debug(format_, ...) fprintf(stderr, format_, __VA_ARGS__)
extern int _unittest_do_not_exit;
extern void test_assocarr_suite();
extern void test_brprintf_suite();
extern void test_bswap_suite();
@ -39,7 +37,6 @@ extern void test_utility_suite();
extern void test_loading_suite();
extern void test_controls_suite();
extern void test_input_suite();
extern void test_errors_suite();
extern void test_dossys_suite();
extern void test_init_suite();
extern void test_brlists_suite();
@ -147,7 +144,9 @@ void setup_global_vars(int argc, char* argv[]) {
root_dir = getenv("DETHRACE_ROOT_DIR");
if (root_dir != NULL) {
printf("DETHRACE_ROOT_DIR: %s\n", root_dir);
chdir(root_dir);
if (chdir(root_dir)) {
fprintf(stderr, "Failed to chdir to \"%s\" (reason=\"%s\")\n", root_dir, strerror(errno));
}
strncpy(gApplication_path, root_dir, 256);
strcat(gApplication_path, "/DATA");
} else {
@ -174,7 +173,6 @@ void setup_global_vars(int argc, char* argv[]) {
setup_temp_folder();
printf("INFO: temp folder is \"%s\"\n", temp_folder);
_unittest_do_not_exit = 1;
harness_debug_level = 7;
harness_game_info.mode = eGame_carmageddon;
@ -286,7 +284,6 @@ int main(int argc, char** argv) {
test_loading_suite();
test_controls_suite();
test_input_suite();
test_errors_suite();
test_dossys_suite();
test_graphics_suite();
test_powerup_suite();