From d123e4b651dde428e89ee291fa4aa1ebf5477e6a Mon Sep 17 00:00:00 2001 From: Dethrace Labs <78985374+dethrace-labs@users.noreply.github.com> Date: Tue, 23 Sep 2025 09:58:17 +1200 Subject: [PATCH] CalcReturnToStartPointRoute matching --- src/DETHRACE/CMakeLists.txt | 3 ++- src/DETHRACE/common/opponent.c | 29 +++++++++++++---------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/DETHRACE/CMakeLists.txt b/src/DETHRACE/CMakeLists.txt index db886e27..6f928f13 100644 --- a/src/DETHRACE/CMakeLists.txt +++ b/src/DETHRACE/CMakeLists.txt @@ -192,6 +192,7 @@ endif() if(MSVC_42_FOR_RECCMP) add_executable(dethrace WIN32) set(CMAKE_C_FLAGS_DEBUG "/Od /Oi /Zi /MLd /G5") + add_compile_definitions(_DEBUG) set_target_properties(dethrace PROPERTIES OUTPUT_NAME "CARM95") target_link_options(dethrace PRIVATE /INCREMENTAL:NO /subsystem:windows /ENTRY:mainCRTStartup) @@ -199,7 +200,7 @@ if(MSVC_42_FOR_RECCMP) set_source_files_properties(common/skidmark.c PROPERTIES COMPILE_FLAGS "/FAs") # set_source_files_properties(common/brucetrk.c PROPERTIES COMPILE_FLAGS "/G5") - set_source_files_properties(common/opponent.c PROPERTIES COMPILE_FLAGS "/FAs /GB") + set_source_files_properties(common/opponent.c PROPERTIES COMPILE_FLAGS "/FAs /G5") reccmp_add_target(dethrace ID CARM95) reccmp_configure() else() diff --git a/src/DETHRACE/common/opponent.c b/src/DETHRACE/common/opponent.c index 081178d6..13c63568 100644 --- a/src/DETHRACE/common/opponent.c +++ b/src/DETHRACE/common/opponent.c @@ -770,7 +770,7 @@ void CalcGetNearPlayerRoute(tOpponent_spec* pOpponent_spec, tCar_spec* pPlayer) gSFS_cycles_this_time = 0; SearchForSection(temp_store, perm_store, &num_of_perm_store_sections, players_section, 1, 0.f, pOpponent_spec); gSFS_total_cycles += gSFS_cycles_this_time; - if (gSFS_max_cycles < gSFS_cycles_this_time) { + if (gSFS_cycles_this_time > gSFS_max_cycles) { gSFS_max_cycles = gSFS_cycles_this_time; } dr_dprintf(">>>SearchForSection() - max %d, avg %.1f", gSFS_max_cycles, (float)gSFS_total_cycles / gSFS_count); @@ -806,34 +806,31 @@ void CalcReturnToStartPointRoute(tOpponent_spec* pOpponent_spec) { ClearOpponentsProjectedRoute(pOpponent_spec); section_no = FindNearestPathSection(&pOpponent_spec->car_spec->car_master_actor->t.t.translate.t, §ion_v, &intersect, &distance); - distance = BrVector3Length(§ion_v); BrVector3Normalise(§ion_v, §ion_v); - if (BrVector3Dot(&pOpponent_spec->car_spec->direction, §ion_v) <= 0.0f) { - AddToOpponentsProjectedRoute(pOpponent_spec, section_no, 0); - } else { + if (BrVector3Dot(&pOpponent_spec->car_spec->direction, §ion_v) > 0.0f) { AddToOpponentsProjectedRoute(pOpponent_spec, section_no, 1); + } else { + AddToOpponentsProjectedRoute(pOpponent_spec, section_no, 0); } - temp_store[0] = pOpponent_spec->next_sections[pOpponent_spec->nnext_sections - 1]; + temp_store[0].section_no = pOpponent_spec->next_sections[pOpponent_spec->nnext_sections - 1].section_no; + temp_store[0].direction = pOpponent_spec->next_sections[pOpponent_spec->nnext_sections - 1].direction; gSFS_count++; gSFS_cycles_this_time = 0; SearchForSection(temp_store, perm_store, &num_of_perm_store_sections, pOpponent_spec->return_to_start_data.section_no, 1, 0.0f, pOpponent_spec); gSFS_total_cycles += gSFS_cycles_this_time; - if (gSFS_max_cycles < gSFS_cycles_this_time) { + if (gSFS_cycles_this_time > gSFS_max_cycles) { gSFS_max_cycles = gSFS_cycles_this_time; } - if (num_of_perm_store_sections <= 1) { - if (pOpponent_spec->nnext_sections <= 6) { - TopUpRandomRoute(pOpponent_spec, 4 - pOpponent_spec->nnext_sections + 4); - } - } else { - sections_to_copy = 10 - pOpponent_spec->nnext_sections; - if (sections_to_copy >= num_of_perm_store_sections - 1) { - sections_to_copy = num_of_perm_store_sections - 1; - } + if (num_of_perm_store_sections > 1) { + sections_to_copy = MIN(num_of_perm_store_sections - 1, 10 - pOpponent_spec->nnext_sections); memcpy(&pOpponent_spec->next_sections[pOpponent_spec->nnext_sections], &perm_store[1], sizeof(tRoute_section) * sections_to_copy); pOpponent_spec->nnext_sections += sections_to_copy; TopUpRandomRoute(pOpponent_spec, 1); + } else { + if (pOpponent_spec->nnext_sections <= 6) { + TopUpRandomRoute(pOpponent_spec, 4 - pOpponent_spec->nnext_sections + 4); + } } }