Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes + add TestAutoSpecialVolume (=underwater) #237

Merged
merged 22 commits into from
Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
71c3c10
Add enum for splatpack xmas: they have a different demo screen (splat…
madebr Nov 7, 2022
d78eca8
Simplify sign
madebr Nov 7, 2022
8a6fefa
Fix DecodeLine2 + decode_datatxt.py
madebr Nov 8, 2022
bcc42f3
Compare against pointers
madebr Nov 8, 2022
ab85e82
Use float cos and sin functions
madebr Nov 8, 2022
40839c5
Implement StopGroovidelic
madebr Nov 8, 2022
874db5e
Implement TestAutoSpecialVolume
madebr Nov 8, 2022
8747449
Use floats in SmokeCircle related functions
madebr Nov 9, 2022
1e45bcf
gOffset is initialized to 0
madebr Nov 9, 2022
3345649
Don't stub DrawTheGlow: every crash is an opportunity to find a bug
madebr Nov 9, 2022
0ac8b10
Decrease indentation of LineBoxColl (no functional change)
madebr Nov 9, 2022
f2dda95
Use BrVector3XXX macro's in GetBoundsEdge (no functional change)
madebr Nov 9, 2022
dcf5416
Fix address sanitzier warning when using APC
madebr Nov 9, 2022
6dab7f3
Use BrVector3XXX macro in GetPlaneNormal (no functional change)
madebr Nov 9, 2022
4528e5e
Get rid of global is_full_screen variable
madebr Oct 25, 2022
23b7ed7
Add command line argument to start DethRace in full screen mode
madebr Oct 25, 2022
9a1ed19
cmake: move DETHRACE_FIX_BUGS cmake option to top cmake script
madebr Nov 9, 2022
40b6f29
Add DETHRACE_FIX_BUGS macro when DETHRACE_FIX_BUGS cmake variable is …
madebr Nov 9, 2022
a201fc6
harness: prescale mouse pointer so it works seamlessly with hires
madebr Nov 9, 2022
7905c40
Fix IWANTTOFIDDLE
madebr Nov 10, 2022
e2a0e9c
Add comments for the fixes
madebr Nov 11, 2022
264dec5
Revert "Don't stub DrawTheGlow: every crash is an opportunity to find…
madebr Nov 11, 2022
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
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ if(DETHRACE_WERROR)
endif()
endif()

option(DETHRACE_FIX_BUGS "Fix Dethrace bugs" ON)

add_subdirectory(src/harness)
add_subdirectory(src/S3)
add_subdirectory(src/BRSRC13)
Expand Down
4 changes: 2 additions & 2 deletions src/BRSRC13/CORE/V1DB/prepmesh.c
Original file line number Diff line number Diff line change
Expand Up @@ -604,8 +604,8 @@ void BrModelUpdate(br_model* model, br_uint_16 flags) {
if (model->flags & BR_MODF_PREPREPARED) {
return;
}
if (!model->faces || !model->vertices) {
BrFailure("BrModelUpdate: model has no faces or vertices (%s)", model->identifier ? model->identifier : "<NULL>");
if (model->faces == NULL || model->vertices == NULL) {
BrFailure("BrModelUpdate: model has no faces or vertices (%s)", model->identifier != NULL ? model->identifier : "<NULL>");
}
if (flags & BR_MODU_UNKNOWN) {
flags |= BR_MODU_NORMALS;
Expand Down
4 changes: 1 addition & 3 deletions src/DETHRACE/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# 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_FIX_BUGS "Fix Dethrace bugs" ON)

target_include_directories(dethrace_obj
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
Expand Down Expand Up @@ -35,7 +33,7 @@ else()
-Wno-format-overflow
)
endif()
if(BRENDER_FIX_BUGS)
if(DETHRACE_FIX_BUGS)
target_compile_definitions(dethrace_obj PRIVATE DETHRACE_FIX_BUGS)
endif()

Expand Down
374 changes: 157 additions & 217 deletions src/DETHRACE/common/car.c

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/DETHRACE/common/cutscene.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,11 @@ void DoFullVersionPowerpoint() {

FadePaletteDown();
DRSetPalette(gRender_palette);
ShowCutScene(9, 0, 8503, gCut_delay_4);
if (harness_game_info.mode == eGame_splatpack_demo) {
PlaySmackerFile("DEMOEND.SMK");
} else {
ShowCutScene(9, 0, 8503, gCut_delay_4);
}
FadePaletteDown();

gLast_demo_end_anim = PDGetTotalTime();
Expand Down
2 changes: 1 addition & 1 deletion src/DETHRACE/common/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ void InitGame(int pStart_race) {
gNo_races_yet = 1;
NetPlayerStatusChanged(ePlayer_status_loading);
gProgram_state.current_race_index = pStart_race;
if (harness_game_info.mode == eGame_carmageddon_demo || harness_game_info.mode == eGame_splatpack_demo) {
if (harness_game_info.mode == eGame_carmageddon_demo || harness_game_info.mode == eGame_splatpack_demo || harness_game_info.mode == eGame_splatpack_xmas_demo) {
gProgram_state.current_car.power_up_levels[0] = gDemo_armour;
gProgram_state.current_car.power_up_levels[1] = gDemo_power;
gProgram_state.current_car.power_up_levels[2] = gDemo_offensive;
Expand Down
11 changes: 8 additions & 3 deletions src/DETHRACE/common/loading.c
Original file line number Diff line number Diff line change
Expand Up @@ -1687,7 +1687,7 @@ void MungeWindscreen(br_model* pModel) {
void SetModelFlags(br_model* pModel, int pOwner) {
LOG_TRACE("(%p, %d)", pModel, pOwner);

if (pModel && pModel->nfaces) {
if (pModel != NULL&& pModel->nfaces != 0) {
#if defined(DETHRACE_FIX_BUGS) /* Show Squad Car in the wreck gallery. */
if (gAusterity_mode) {
#else
Expand Down Expand Up @@ -1795,7 +1795,12 @@ void LoadCar(char* pCar_name, tDriver pDriver, tCar_spec* pCar_spec, int pOwner,
FatalError(kFatalError_FileCorrupt_S, pCar_name);
}
if (*pDriver_name != '\0') {
#if defined(DETHRACE_FIX_BUGS)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add a comment documenting what the bug is that we are fixing?

// Make sure to not read and write out of bounds.
memcpy(pCar_spec->driver_name, pDriver_name, MIN(sizeof(pCar_spec->driver_name), strlen(pDriver_name)));
#else
memcpy(pCar_spec->driver_name, pDriver_name, sizeof(pCar_spec->driver_name));
#endif
pCar_spec->driver_name[sizeof(pCar_spec->driver_name) - 1] = '\0';
} else {
strcpy(pCar_spec->driver_name, "X");
Expand Down Expand Up @@ -2430,11 +2435,11 @@ void LoadRaces(tRace_list_spec* pRace_list, int* pCount, int pRace_type_index) {
*pCount = number_of_racers;
fclose(f);
j = 0;
if (harness_game_info.mode == eGame_carmageddon_demo || harness_game_info.mode == eGame_splatpack_demo) {
if (harness_game_info.mode == eGame_carmageddon_demo || harness_game_info.mode == eGame_splatpack_demo || harness_game_info.mode == eGame_splatpack_xmas_demo) {
j = 99;
}
for (i = 0; i < number_of_racers; i++) {
if (harness_game_info.mode == eGame_carmageddon_demo || harness_game_info.mode == eGame_splatpack_demo) {
if (harness_game_info.mode == eGame_carmageddon_demo || harness_game_info.mode == eGame_splatpack_demo || harness_game_info.mode == eGame_splatpack_xmas_demo) {
pRace_list[i].suggested_rank = gDemo_rank;
pRace_list[i].rank_required = j;
j -= 3;
Expand Down
4 changes: 2 additions & 2 deletions src/DETHRACE/common/loadsave.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ int DoLoadGame() {
int result;
LOG_TRACE("()");

if (harness_game_info.mode == eGame_carmageddon_demo || harness_game_info.mode == eGame_splatpack_demo) {
if (harness_game_info.mode == eGame_carmageddon_demo || harness_game_info.mode == eGame_splatpack_demo || harness_game_info.mode == eGame_splatpack_xmas_demo) {
DoFeatureUnavailableInDemo();
return 0;
}
Expand Down Expand Up @@ -933,7 +933,7 @@ int SaveGameInterface(int pDefault_choice) {
void DoSaveGame(int pSave_allowed) {
LOG_TRACE("()");

if (harness_game_info.mode == eGame_carmageddon_demo || harness_game_info.mode == eGame_splatpack_demo) {
if (harness_game_info.mode == eGame_carmageddon_demo || harness_game_info.mode == eGame_splatpack_demo || harness_game_info.mode == eGame_splatpack_xmas_demo) {
DoFeatureUnavailableInDemo();
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/DETHRACE/common/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
void QuitGame() {
LOG_TRACE("()");

if (harness_game_info.mode == eGame_carmageddon_demo || harness_game_info.mode == eGame_splatpack_demo) {
if (harness_game_info.mode == eGame_carmageddon_demo || harness_game_info.mode == eGame_splatpack_demo || harness_game_info.mode == eGame_splatpack_xmas_demo) {
DoDemoGoodbye();
}

Expand Down
2 changes: 1 addition & 1 deletion src/DETHRACE/common/mainloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ void CheckTimer() {
RaceCompleted(eRace_over_out_of_time);
}

if (harness_game_info.mode == eGame_carmageddon_demo || harness_game_info.mode == eGame_splatpack_demo) {
if (harness_game_info.mode == eGame_carmageddon_demo || harness_game_info.mode == eGame_splatpack_demo || harness_game_info.mode == eGame_splatpack_xmas_demo) {
if (harness_game_config.demo_timeout != 0) {
time_left = harness_game_config.demo_timeout - GetRaceTime();
time_in_seconds = (time_left + 500) / 1000;
Expand Down
4 changes: 2 additions & 2 deletions src/DETHRACE/common/mainmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ char* gPixels_copy__mainmenu; // suffix added to avoid duplicate symbol
int MainMenuDone1(int pCurrent_choice, int pCurrent_mode, int pGo_ahead, int pEscaped, int pTimed_out) {
LOG_TRACE("(%d, %d, %d, %d, %d)", pCurrent_choice, pCurrent_mode, pGo_ahead, pEscaped, pTimed_out);

if (harness_game_info.mode == eGame_carmageddon_demo || harness_game_info.mode == eGame_splatpack_demo) {
if (harness_game_info.mode == eGame_carmageddon_demo || harness_game_info.mode == eGame_splatpack_demo || harness_game_info.mode == eGame_splatpack_xmas_demo) {
if (pCurrent_mode == 0) {
if (pCurrent_choice == 7) {
PreloadBunchOfFlics(7);
Expand Down Expand Up @@ -74,7 +74,7 @@ int MainMenuDone1(int pCurrent_choice, int pCurrent_mode, int pGo_ahead, int pEs
int MainMenuDone2(int pCurrent_choice, int pCurrent_mode, int pGo_ahead, int pEscaped, int pTimed_out) {
LOG_TRACE("(%d, %d, %d, %d, %d)", pCurrent_choice, pCurrent_mode, pGo_ahead, pEscaped, pTimed_out);

if (harness_game_info.mode == eGame_carmageddon_demo || harness_game_info.mode == eGame_splatpack_demo) {
if (harness_game_info.mode == eGame_carmageddon_demo || harness_game_info.mode == eGame_splatpack_demo || harness_game_info.mode == eGame_splatpack_xmas_demo) {
if (pCurrent_mode == 0) {
if (pCurrent_choice == 4) {
PreloadBunchOfFlics(7);
Expand Down
4 changes: 2 additions & 2 deletions src/DETHRACE/common/newgame.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ int DoOnePlayerStart() {
memcpy(&gProgram_state, &saved_state, sizeof(tProgram_state));
return 0;
}
if ((harness_game_info.mode == eGame_carmageddon_demo || harness_game_info.mode == eGame_splatpack_demo) && gProgram_state.frank_or_anniness != eFrankie) {
if ((harness_game_info.mode == eGame_carmageddon_demo || harness_game_info.mode == eGame_splatpack_demo || harness_game_info.mode == eGame_splatpack_xmas_demo) && gProgram_state.frank_or_anniness != eFrankie) {
DoFeatureUnavailableInDemo();
memset(&gProgram_state, 0, sizeof(gProgram_state));
return 0;
Expand Down Expand Up @@ -851,7 +851,7 @@ int DoMultiPlayerStart() {
int car_index;
LOG_TRACE("()");

if (harness_game_info.mode == eGame_carmageddon_demo || harness_game_info.mode == eGame_splatpack_demo) {
if (harness_game_info.mode == eGame_carmageddon_demo || harness_game_info.mode == eGame_splatpack_demo || harness_game_info.mode == eGame_splatpack_xmas_demo) {
SuspendPendingFlic();
DoFeatureUnavailableInDemo();
return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/DETHRACE/common/racestrt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1672,7 +1672,7 @@ tSO_result DoSelectRace(int* pSecond_time_around) {
DisposeFlicPanel(0);

if (result == 2) {
if (harness_game_info.mode == eGame_carmageddon_demo || harness_game_info.mode == eGame_splatpack_demo) {
if (harness_game_info.mode == eGame_carmageddon_demo || harness_game_info.mode == eGame_splatpack_demo || harness_game_info.mode == eGame_splatpack_xmas_demo) {
DoFeatureUnavailableInDemo();
} else {
RunFlic(192);
Expand Down
2 changes: 1 addition & 1 deletion src/DETHRACE/common/racesumm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,7 @@ tSO_result DoEndRaceSummary(int* pFirst_summary_done, tRace_result pRace_result)
tSO_result result;
LOG_TRACE("(%p, %d)", pFirst_summary_done, pRace_result);

if (harness_game_info.mode == eGame_carmageddon_demo || harness_game_info.mode == eGame_splatpack_demo) {
if (harness_game_info.mode == eGame_carmageddon_demo || harness_game_info.mode == eGame_splatpack_demo || harness_game_info.mode == eGame_splatpack_xmas_demo) {
gRank_etc_munged = 1;
DoEndRaceSummary2();
return eSO_continue;
Expand Down
26 changes: 13 additions & 13 deletions src/DETHRACE/common/spark.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ int gShrapnel_flags;
br_model* gShrapnel_model[2];
int gSmoke_flags;
int gSmoke_num;
int gOffset;
int gOffset = 0;
int gColumn_flags;
int gNext_column;
br_pixelmap* gBlack_smoke_shade_table;
Expand Down Expand Up @@ -838,7 +838,7 @@ void SmokeLine(int l, int x, br_scalar zbuff, int r_squared, tU8* scr_ptr, tU16*
if (gProgram_state.cockpit_on) {
depth_ptr += gOffset;
}
z = (1.0 - zbuff) * 32768.0f;
z = (1.f - zbuff) * 32768.0f;
r_multiplier_int = r_multiplier * 65536.0f;
shade_offset_int = shade_offset * 65536.0f;

Expand Down Expand Up @@ -897,7 +897,7 @@ void SmokeCircle(br_vector3* o, br_scalar r, br_scalar extra_z, br_scalar streng
return;
}
shade_ptr = (tU8*)pShade_table->pixels + pShade_table->row_bytes * (pShade_table->base_y + 1);
shade_offset = strength * 14.99;
shade_offset = strength * 14.99f;
r_multiplier = shade_offset / (double)max_r_squared;
z_multiplier = extra_z / (double)max_r_squared;
max_x = pRender_screen->width - ox - 1;
Expand All @@ -910,7 +910,7 @@ void SmokeCircle(br_vector3* o, br_scalar r, br_scalar extra_z, br_scalar streng
osp = scr_ptr;
odp = depth_ptr;
if (pRender_screen->height > oy && oy + ry >= 0.0) {
r_squared = (r * r);
r_squared = r * r;
inc = -r;
y = 0;
y_limit = ry;
Expand Down Expand Up @@ -951,7 +951,7 @@ void SmokeCircle(br_vector3* o, br_scalar r, br_scalar extra_z, br_scalar streng
if (y_limit <= y) {
break;
}
++y;
y++;
scr_ptr -= pRender_screen->row_bytes;
depth_ptr -= pDepth_buffer->row_bytes / 2;
for (r_squared += (2 * y - 1) * aspect_squared; max_r_squared < r_squared && inc < 0; r_squared += 2 * inc - 1) {
Expand All @@ -961,19 +961,19 @@ void SmokeCircle(br_vector3* o, br_scalar r, br_scalar extra_z, br_scalar streng
l -= 2;
}
gOffset += IRandomBetween(-1, 1);
if (gOffset > r / 5.0) {
gOffset = r / 5.0;
if (gOffset > r / 5.f) {
gOffset = r / 5.f;
}
if (gOffset < -(r / 5.0)) {
gOffset = -(r / 5.0);
if (gOffset < -(r / 5.f)) {
gOffset = -(r / 5.f);
}
}
}
if (pAspect < 1.0) {
aspect_squared = 9.0;
ry = r / 3.0;
aspect_squared = 9.f;
ry = r / 3.f;
}
if (oy > 0 && oy <= pRender_screen->height + ry - 2.0) {
if (oy > 0 && oy <= pRender_screen->height + ry - 2.f) {
r_squared = (r * r);
inc = -r;
y = 0;
Expand All @@ -989,7 +989,7 @@ void SmokeCircle(br_vector3* o, br_scalar r, br_scalar extra_z, br_scalar streng
inc = -sqrtf(max_r_squared - r_squared);
r_squared += inc * inc;
}
if (oy - ry < 0.0) {
if (oy - ry < 0.f) {
y_limit = oy;
}
l = -2 * inc;
Expand Down
4 changes: 2 additions & 2 deletions src/DETHRACE/common/structur.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ void SelectOpponents(tRace_info* pRace_info) {
int had_scum;
LOG_TRACE("(%p)", pRace_info);

if (harness_game_info.mode == eGame_carmageddon_demo || harness_game_info.mode == eGame_splatpack_demo) {
if (harness_game_info.mode == eGame_carmageddon_demo || harness_game_info.mode == eGame_splatpack_demo || harness_game_info.mode == eGame_splatpack_xmas_demo) {
pRace_info->number_of_racers = OPPONENT_COUNT;
for (i = 0; i < OPPONENT_COUNT; i++) {
pRace_info->opponent_list[i].index = gDemo_opponents[i];
Expand Down Expand Up @@ -573,7 +573,7 @@ void DoGame() {
DisposeOpponentsCars(&gCurrent_race);
}
DisposeTrack();
if (harness_game_info.mode == eGame_carmageddon_demo || harness_game_info.mode == eGame_splatpack_demo) {
if (harness_game_info.mode == eGame_carmageddon_demo || harness_game_info.mode == eGame_splatpack_demo || harness_game_info.mode == eGame_splatpack_xmas_demo) {
DoFullVersionPowerpoint();
}
gProgram_state.loaded = 0;
Expand Down
Loading