From 2b78f47de5e95d7ef46f54dea5e51e46bad59a91 Mon Sep 17 00:00:00 2001 From: Dethrace Labs <78985374+dethrace-labs@users.noreply.github.com> Date: Tue, 23 Sep 2025 09:21:23 +1200 Subject: [PATCH] CalcGetNearPlayerRoute effectively matching --- src/DETHRACE/CMakeLists.txt | 1 + src/DETHRACE/common/opponent.c | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/DETHRACE/CMakeLists.txt b/src/DETHRACE/CMakeLists.txt index 3ce4c4c2..db886e27 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) diff --git a/src/DETHRACE/common/opponent.c b/src/DETHRACE/common/opponent.c index b2496695..081178d6 100644 --- a/src/DETHRACE/common/opponent.c +++ b/src/DETHRACE/common/opponent.c @@ -763,7 +763,8 @@ void CalcGetNearPlayerRoute(tOpponent_spec* pOpponent_spec, tCar_spec* pPlayer) TopUpRandomRoute(pOpponent_spec, 1); } while (pOpponent_spec->nnext_sections < 6 && !fuck_it) { - 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; dr_dprintf("%s: CalcGetNearPlayerRoute() - In loop; our section #%d, player's section #%d", pOpponent_spec->car_spec->driver_name, temp_store[0].section_no, players_section); gSFS_count++; gSFS_cycles_this_time = 0; @@ -772,18 +773,18 @@ void CalcGetNearPlayerRoute(tOpponent_spec* pOpponent_spec, tCar_spec* pPlayer) if (gSFS_max_cycles < gSFS_cycles_this_time) { gSFS_max_cycles = gSFS_cycles_this_time; } - dr_dprintf(">>>SearchForSection() - max %d, avg %.1f", gSFS_max_cycles, gSFS_total_cycles / (float)gSFS_count); - if (num_of_perm_store_sections <= 1) { + dr_dprintf(">>>SearchForSection() - max %d, avg %.1f", gSFS_max_cycles, (float)gSFS_total_cycles / gSFS_count); + if (num_of_perm_store_sections > 1) { + sections_to_copy = MIN(COUNT_OF(pOpponent_spec->next_sections) - pOpponent_spec->nnext_sections, num_of_perm_store_sections - 1); + 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 { dr_dprintf("%s: CalcGetNearPlayerRoute() - SearchForSection() produced bugger all", pOpponent_spec->car_spec->driver_name); fuck_it = 1; if (pOpponent_spec->nnext_sections <= 4) { TopUpRandomRoute(pOpponent_spec, 4 - pOpponent_spec->nnext_sections + 4); } - } else { - sections_to_copy = MIN(COUNT_OF(pOpponent_spec->next_sections) - pOpponent_spec->nnext_sections, num_of_perm_store_sections - 1); - 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); } } }