Merge pull request #484 from dethrace-labs/opponent_matching

Opponent.c matching
This commit is contained in:
Dethrace Engineering Department 2025-10-10 20:13:37 +13:00 committed by GitHub
commit bc600370e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 1454 additions and 1381 deletions

View File

@ -61,6 +61,8 @@ endif()
target_sources(dethrace_obj PRIVATE
common/skidmark.c
common/opponent.c
common/brucetrk.c
common/brucetrk.h
common/car.c
@ -127,7 +129,7 @@ target_sources(dethrace_obj PRIVATE
common/oil.h
common/oppocar.c
common/oppocar.h
common/opponent.c
common/opponent.h
common/oppoproc.c
common/oppoproc.h
@ -190,14 +192,15 @@ 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)
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/car.c PROPERTIES COMPILE_FLAGS "/GB")
set_source_files_properties(common/opponent.c PROPERTIES COMPILE_FLAGS "/FAs /G5")
reccmp_add_target(dethrace ID CARM95)
reccmp_configure()
else()

View File

@ -1375,17 +1375,17 @@ void ReadNonCarMechanicsData(FILE* pF, tNon_car_spec* non_car) {
c = &non_car->collision_info;
c->driver = 0;
c->index = GetAnInt(pF);
ReadVector3(pF, non_car->free_cmpos.v[0], non_car->free_cmpos.v[1], non_car->free_cmpos.v[2]);
ReadVector3(pF, non_car->attached_cmpos.v[0], non_car->attached_cmpos.v[1], non_car->attached_cmpos.v[2]);
ReadVector3(pF, c->bounds[1].min.v[0], c->bounds[1].min.v[1], c->bounds[1].min.v[2]);
ReadVector3(pF, c->bounds[1].max.v[0], c->bounds[1].max.v[1], c->bounds[1].max.v[2]);
ReadThreeFloats(pF, non_car->free_cmpos.v[0], non_car->free_cmpos.v[1], non_car->free_cmpos.v[2]);
ReadThreeFloats(pF, non_car->attached_cmpos.v[0], non_car->attached_cmpos.v[1], non_car->attached_cmpos.v[2]);
ReadThreeFloats(pF, c->bounds[1].min.v[0], c->bounds[1].min.v[1], c->bounds[1].min.v[2]);
ReadThreeFloats(pF, c->bounds[1].max.v[0], c->bounds[1].max.v[1], c->bounds[1].max.v[2]);
c->extra_point_num = GetAnInt(pF);
if (c->extra_point_num > 6) {
sprintf(s, "%d", c->index);
FatalError(kFatalError_TooManyExtraPointsForCar_S, s);
}
for (i = 0; c->extra_point_num > i; ++i) {
ReadVector3(pF, c->extra_points[i].v[0], c->extra_points[i].v[1], c->extra_points[i].v[2]);
ReadThreeFloats(pF, c->extra_points[i].v[0], c->extra_points[i].v[1], c->extra_points[i].v[2]);
}
ReadPairOfFloats(pF, non_car->free_mass, non_car->attached_mass);
@ -1423,14 +1423,14 @@ void ReadNonCarMechanicsData(FILE* pF, tNon_car_spec* non_car) {
non_car->I_over_M.v[1] = ts1 / 12.0f;
ts1 = BR_SQR2(het, len);
non_car->I_over_M.v[0] = ts1 / 12.0f;
DRVector3Scale(&non_car->free_cmpos, &non_car->free_cmpos, WORLD_SCALE);
DRVector3Scale(&non_car->attached_cmpos, &non_car->attached_cmpos, WORLD_SCALE);
DRVector3Scale(&non_car->I_over_M, &non_car->I_over_M, 47.61000061035156f);
DRVector3Scale(&c->bounds[1].min, &c->bounds[1].min, WORLD_SCALE);
DRVector3Scale(&c->bounds[1].max, &c->bounds[1].max, WORLD_SCALE);
BrVector3Scale(&non_car->free_cmpos, &non_car->free_cmpos, WORLD_SCALE);
BrVector3Scale(&non_car->attached_cmpos, &non_car->attached_cmpos, WORLD_SCALE);
BrVector3Scale(&non_car->I_over_M, &non_car->I_over_M, 47.61000061035156f);
BrVector3Scale(&c->bounds[1].min, &c->bounds[1].min, WORLD_SCALE);
BrVector3Scale(&c->bounds[1].max, &c->bounds[1].max, WORLD_SCALE);
for (i = 0; c->extra_point_num > i; ++i) {
DRVector3Scale(&c->extra_points[i], &c->extra_points[i], WORLD_SCALE);
BrVector3Scale(&c->extra_points[i], &c->extra_points[i], WORLD_SCALE);
}
memcpy(&c->max_bounds[0], &c->bounds[0], sizeof(c->max_bounds[0]));
memcpy(&c->max_bounds[1], &c->bounds[1], sizeof(c->max_bounds[0]));

File diff suppressed because it is too large Load Diff

View File

@ -33,10 +33,10 @@ void AdjustSkid(int pSkid_num, br_matrix34* pMatrix, int pMaterial_index) {
// IDA: br_material* __usercall MaterialFromIndex@<EAX>(int pIndex@<EAX>)
// FUNCTION: CARM95 0x00401088
br_material* MaterialFromIndex(int pIndex) {
if (pIndex > -2) {
return gCurrent_race.material_modifiers[pIndex].skid_mark_material;
} else {
if (pIndex <= -2) {
return gMaterial[-2 - pIndex];
} else {
return gCurrent_race.material_modifiers[pIndex].skid_mark_material;
}
}
@ -306,7 +306,7 @@ int FarFromLine2D(br_vector3* pPt, br_vector3* pL1, br_vector3* pL2) {
to_pt.v[0] = BR_SUB(pPt->v[0], pL2->v[0]);
to_pt.v[1] = BR_SUB(pPt->v[2], pL2->v[2]);
cross = -(line.v[0]) * to_pt.v[1] + to_pt.v[0] * line.v[1];
cross = (-line.v[0]) * to_pt.v[1] + to_pt.v[0] * line.v[1];
line_len = BrVector2Length(&line);
if (fabs(cross) > line_len * 0.05f) {
return 1;

View File

@ -589,14 +589,14 @@ typedef struct tJoystick {
tS32 dec;
} tJoystick;
typedef struct tPursuee_trail {
br_vector3 trail_nodes[25];
br_vector3 base_heading;
tU32 time_of_next_recording;
tU32 end_of_deviation;
tU8 number_of_nodes;
tU8 has_deviated_recently;
tU8 nodes_shifted_this_frame;
typedef struct tPursuee_trail { // size: 0x144
br_vector3 trail_nodes[25]; // @0x0
br_vector3 base_heading; // @0x12c
tU32 time_of_next_recording; // @0x138
tU32 end_of_deviation; // @0x13c
tU8 number_of_nodes; // @0x140
tU8 has_deviated_recently; // @0x141
tU8 nodes_shifted_this_frame; // @0x142
} tPursuee_trail;
typedef struct tCar_spec_struct { // size: 0x1a9c
@ -1659,71 +1659,71 @@ typedef struct tOpponent {
tText_chunk* text_chunks;
} tOpponent;
typedef struct tProgram_state {
tS32 credits;
tS32 credits_earned;
tS32 credits_lost;
tU32 view_change_start;
tU32 pratcam_move_start;
int peds_killed;
int sausage_eater_mode;
int rank;
int loaded;
int last_slot;
int skill_level;
int parts_shop_visited;
int racing;
int cut_scene;
int saving;
int loading;
int dont_save_or_load;
int dont_load;
int mirror_on;
int prat_cam_on;
int cockpit_on;
int cockpit_image_index;
int current_render_left;
int current_render_top;
int current_render_right;
int current_render_bottom;
int frame_rate_headup;
int revs;
int music_volume;
int effects_volume;
int current_race_index;
int redo_race_index;
int credits_per_rank;
int game_completed;
int number_of_cars;
int current_car_index;
tWhich_view which_view;
tWhich_view new_view;
tWhich_view pending_view;
tWhich_view old_view;
tRace_sel_view_type view_type;
tProg_status prog_status;
tFrank_anne frank_or_anniness;
tAuto_parts_reply auto_parts_reply;
tCar_spec current_car;
char player_name[2][14];
char track_file_name[14];
char car_name[14];
int cars_available[60];
br_vector3 initial_position;
br_scalar initial_yaw;
tTrack_spec track_spec;
tDepth_effect default_depth_effect;
tDepth_effect current_depth_effect;
int special_volume_count;
tSpecial_volume* special_volumes;
br_material* standard_screen;
br_material* standard_screen_dark;
br_material* standard_screen_fog;
int special_screens_count;
tSpecial_screen* special_screens;
tIntelligent_vehicles AI_vehicles;
tNon_car_spec* non_cars;
int num_non_car_spaces;
typedef struct tProgram_state { // size: 0x356c
tS32 credits; // @0x0
tS32 credits_earned; // @0x4
tS32 credits_lost; // @0x8
tU32 view_change_start; // @0xc
tU32 pratcam_move_start; // @0x10
int peds_killed; // @0x14
int sausage_eater_mode; // @0x18
int rank; // @0x1c
int loaded; // @0x20
int last_slot; // @0x24
int skill_level; // @0x28
int parts_shop_visited; // @0x2c
int racing; // @0x30
int cut_scene; // @0x34
int saving; // @0x38
int loading; // @0x3c
int dont_save_or_load; // @0x40
int dont_load; // @0x44
int mirror_on; // @0x48
int prat_cam_on; // @0x4c
int cockpit_on; // @0x50
int cockpit_image_index; // @0x54
int current_render_left; // @0x58
int current_render_top; // @0x5c
int current_render_right; // @0x60
int current_render_bottom; // @0x64
int frame_rate_headup; // @0x68
int revs; // @0x6c
int music_volume; // @0x70
int effects_volume; // @0x74
int current_race_index; // @0x78
int redo_race_index; // @0x7c
int credits_per_rank; // @0x80
int game_completed; // @0x84
int number_of_cars; // @0x88
int current_car_index; // @0x8c
tWhich_view which_view; // @0x90
tWhich_view new_view; // @0x94
tWhich_view pending_view; // @0x98
tWhich_view old_view; // @0x9c
tRace_sel_view_type view_type; // @0xa0
tProg_status prog_status; // @0xa4
tFrank_anne frank_or_anniness; // @0xa8
tAuto_parts_reply auto_parts_reply; // @0xac
tCar_spec current_car; // @0xb0
char player_name[2][14]; // @0x1b4c
char track_file_name[14]; // @0x1b68
char car_name[14]; // @0x1b76
int cars_available[60]; // @0x1b84
br_vector3 initial_position; // @0x1c74
br_scalar initial_yaw; // @0x1c80
tTrack_spec track_spec; // @0x1c84
tDepth_effect default_depth_effect; // @0x1cb0
tDepth_effect current_depth_effect; // @0x1cc0
int special_volume_count; // @0x1cd0
tSpecial_volume* special_volumes; // @0x1cd4
br_material* standard_screen; // @0x1cd8
br_material* standard_screen_dark; // @0x1cdc
br_material* standard_screen_fog; // @0x1ce0
int special_screens_count; // @0x1ce4
tSpecial_screen* special_screens; // @0x1ce8
tIntelligent_vehicles AI_vehicles; // @0x1cec
tNon_car_spec* non_cars; // @0x3564
int num_non_car_spaces; // @0x3568
} tProgram_state;
typedef struct tDR_font {

View File

@ -55,23 +55,14 @@
(V2) = (T); \
} while (0)
#define ReadVector3(pF, a, b, c) \
do { \
float x[3]; \
GetThreeFloats(pF, &x[2], &x[1], &x[0]); \
a = x[2]; \
b = x[1]; \
c = x[0]; \
\
} while (0)
#define ReadVector32(pF, a, b, c) \
do { \
float x[3]; \
GetThreeFloats(pF, &x[2], &x[1], &x[0]); \
b = x[2]; \
c = x[1]; \
a = x[0]; \
#define ReadThreeFloats(pF, a, b, c) \
do { \
float x_0, x_1, x_2; \
GetThreeFloats(pF, &x_0, &x_1, &x_2); \
a = x_0; \
b = x_1; \
c = x_2; \
\
} while (0)
#define ReadPairOfFloats(pF, a, b) \
@ -82,11 +73,4 @@
b = x[0]; \
} while (0)
#define DRVector3Scale(v1, v2, s) \
do { \
(v1)->v[0] = BR_MUL((v2)->v[0], s); \
(v1)->v[1] = BR_MUL((v2)->v[1], s); \
(v1)->v[2] = BR_MUL((v2)->v[2], s); \
} while (0)
#endif

View File

@ -214,7 +214,7 @@
// __loctotime_t
// LIBRARY: CARM95 0x004EA9E0
// __chkstk
// $$$00001(1)
// GLOBAL: CARM95 0x0052D39C
// __mb_cur_max
@ -224,3 +224,12 @@
// GLOBAL: CARM95 0x0052D190
// _pctype
// GLOBAL: CARM95 0x004EAB82
// __CIpow
// GLOBAL: CARM95 0x004EA8DA
// __CIatan2
// GLOBAL: CARM95 0x004EA8C2
// __CIasin