From 8e9b5087fa838a6752662e59f67fbf1122384e23 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sun, 18 Aug 2024 22:30:49 +1000 Subject: [PATCH] Identify unnamed prop functions --- src/game/chr.c | 34 +++++++++--------- src/game/chraction.c | 2 +- src/game/objectives.c | 8 ++--- src/game/prop.c | 74 +++++++++++++++++++------------------- src/game/propobj.c | 20 +++++------ src/include/game/chr.h | 2 +- src/include/game/prop.h | 5 ++- src/include/game/propobj.h | 6 ++-- 8 files changed, 75 insertions(+), 76 deletions(-) diff --git a/src/game/chr.c b/src/game/chr.c index 1683a5f81..b0f92c8e8 100644 --- a/src/game/chr.c +++ b/src/game/chr.c @@ -5005,7 +5005,7 @@ f32 chr_get_ground(struct prop *prop) return chr->ground; } -bool chr_calculate_auto_aim(struct prop *prop, struct coord *arg1, f32 *arg2, f32 *arg3) +bool chr_calculate_autoaim(struct prop *prop, struct coord *screenpos, f32 *xrange, f32 *yrange) { struct chrdata *chr = prop->chr; @@ -5026,36 +5026,36 @@ bool chr_calculate_auto_aim(struct prop *prop, struct coord *arg1, f32 *arg2, f3 if (model->definition->skel == &g_SkelChr) { mtx1 = &model->matrices[0]; mtx2 = &model->matrices[1]; - arg1->z = mtx2->m[3][2] + (mtx1->m[3][2] - mtx2->m[3][2]) * 0.5f; + screenpos->z = mtx2->m[3][2] + (mtx1->m[3][2] - mtx2->m[3][2]) * 0.5f; } else if (model->definition->skel == &g_SkelSkedar) { mtx2 = &model->matrices[0]; - arg1->z = mtx2->m[3][2]; + screenpos->z = mtx2->m[3][2]; } else if (model->definition->skel == &g_SkelDrCaroll) { mtx2 = &model->matrices[0]; - arg1->z = mtx2->m[3][2]; + screenpos->z = mtx2->m[3][2]; } else { - arg1->z = model->matrices[0].m[3][2]; + screenpos->z = model->matrices[0].m[3][2]; } - if (arg1->z < 0) { + if (screenpos->z < 0) { if (model->definition->skel == &g_SkelChr) { - arg1->x = mtx2->m[3][0] + (mtx1->m[3][0] - mtx2->m[3][0]) * 0.5f; - arg1->y = mtx2->m[3][1] + (mtx1->m[3][1] - mtx2->m[3][1]) * 0.5f; + screenpos->x = mtx2->m[3][0] + (mtx1->m[3][0] - mtx2->m[3][0]) * 0.5f; + screenpos->y = mtx2->m[3][1] + (mtx1->m[3][1] - mtx2->m[3][1]) * 0.5f; } else if (model->definition->skel == &g_SkelSkedar) { - arg1->x = mtx2->m[3][0]; - arg1->y = mtx2->m[3][1]; + screenpos->x = mtx2->m[3][0]; + screenpos->y = mtx2->m[3][1]; } else if (model->definition->skel == &g_SkelDrCaroll) { - arg1->x = mtx2->m[3][0]; - arg1->y = mtx2->m[3][1]; + screenpos->x = mtx2->m[3][0]; + screenpos->y = mtx2->m[3][1]; } else { - arg1->x = model->matrices[0].m[3][0]; - arg1->y = model->matrices[0].m[3][1]; + screenpos->x = model->matrices[0].m[3][0]; + screenpos->y = model->matrices[0].m[3][1]; } - arg3[0] = arg3[1] = 0; - arg2[0] = arg2[1] = 0; + yrange[0] = yrange[1] = 0; + xrange[0] = xrange[1] = 0; - func0f067d88(model, &arg2[1], &arg2[0], &arg3[1], &arg3[0]); + model_get_screen_coords3(model, &xrange[1], &xrange[0], &yrange[1], &yrange[0]); return true; } diff --git a/src/game/chraction.c b/src/game/chraction.c index 7b77eb1bc..b83f8b905 100644 --- a/src/game/chraction.c +++ b/src/game/chraction.c @@ -7706,7 +7706,7 @@ void chr_punch_inflict_damage(struct chrdata *chr, s32 damage, s32 range, u8 rev } } - weapon_play_whoosh_sound(gset.weaponnum, chr->prop); + weapon_play_melee_miss_sound(gset.weaponnum, chr->prop); } struct punchanim { diff --git a/src/game/objectives.c b/src/game/objectives.c index 48f3d729a..581c18e39 100644 --- a/src/game/objectives.c +++ b/src/game/objectives.c @@ -495,8 +495,8 @@ void objective_check_holograph(f32 maxdist) && obj->prop->z >= 0 && obj_is_healthy(obj)) { struct coord sp9c; - f32 sp94[2]; - f32 sp8c[2]; + f32 xrange[2]; + f32 yrange[2]; f32 dist = -1; if (maxdist != 0.0f) { @@ -506,10 +506,10 @@ void objective_check_holograph(f32 maxdist) maxdist = maxdist * maxdist; } - if (dist < maxdist && func0f0899dc(obj->prop, &sp9c, sp94, sp8c)) { + if (dist < maxdist && func0f0899dc(obj->prop, &sp9c, xrange, yrange)) { f32 sp78[2]; f32 sp70[2]; - func0f06803c(&sp9c, sp94, sp8c, sp78, sp70); + func0f06803c(&sp9c, xrange, yrange, sp78, sp70); if (sp78[0] > cam_get_screen_left() && sp78[0] < cam_get_screen_left() + cam_get_screen_width() diff --git a/src/game/prop.c b/src/game/prop.c index 709c42399..f5d8caaeb 100644 --- a/src/game/prop.c +++ b/src/game/prop.c @@ -447,7 +447,7 @@ Gfx *props_render(Gfx *gdl, RoomNum renderroomnum, s32 renderpass, RoomNum *room return gdl; } -void weapon_play_whoosh_sound(s32 weaponnum, struct prop *prop) +void weapon_play_melee_miss_sound(s32 weaponnum, struct prop *prop) { s32 soundnum = -1; f32 speed = 1; @@ -498,7 +498,7 @@ void weapon_play_whoosh_sound(s32 weaponnum, struct prop *prop) * This is similar to the above but the sound numbers seem wrong... * Perhaps the function was from GE and not updated for PD. */ -void func0f060bac(s32 weaponnum, struct prop *prop) +void weapon_play_melee_hit_sound(s32 weaponnum, struct prop *prop) { s32 soundnum = -1; f32 speed = 1; @@ -923,7 +923,7 @@ struct prop *shot_calculate_hits(s32 handnum, bool isshooting, struct coord *gun } if (hitaprop || hitbg) { - func0f060bac(shotdata.gset.weaponnum, g_Vars.currentplayer->prop); + weapon_play_melee_hit_sound(shotdata.gset.weaponnum, g_Vars.currentplayer->prop); if (shotdata.gset.weaponnum != WEAPON_UNARMED && shotdata.gset.weaponnum != WEAPON_TRANQUILIZER) { if (hitaprop) { @@ -933,7 +933,7 @@ struct prop *shot_calculate_hits(s32 handnum, bool isshooting, struct coord *gun } } } else { - weapon_play_whoosh_sound(shotdata.gset.weaponnum, g_Vars.currentplayer->prop); + weapon_play_melee_miss_sound(shotdata.gset.weaponnum, g_Vars.currentplayer->prop); } } else { // The caller is querying which prop is being aimed at rather than taking a shot. @@ -2375,7 +2375,7 @@ void props_test_for_pickup(void) } } -f32 func0f06438c(struct prop *prop, struct coord *arg1, f32 *arg2, f32 *arg3, f32 *arg4, bool throughobjects, bool cangangsta, s32 arg7) +f32 prop_calculate_autoaim_score(struct prop *prop, struct coord *screenpos, f32 *xrange, f32 *yrange, f32 *aimpos, bool throughobjects, bool cangangsta, bool forcefullscreen) { f32 spa0[2]; struct coord sp94; @@ -2391,17 +2391,17 @@ f32 func0f06438c(struct prop *prop, struct coord *arg1, f32 *arg2, f32 *arg3, f3 f32 right; f32 result = -2; struct weaponfunc *func = current_player_get_weapon_function(HAND_RIGHT); - bool sp50 = arg7; + bool usefullscreen = forcefullscreen; bool sp4c; f32 sp48; struct prop *playerprop; s32 ok; if (func && bgun0f0a27c8()) { - sp50 = true; + usefullscreen = true; } - if (sp50) { + if (usefullscreen) { top = cam_get_screen_top(); bottom = cam_get_screen_top() + cam_get_screen_height(); left = cam_get_screen_left(); @@ -2413,26 +2413,26 @@ f32 func0f06438c(struct prop *prop, struct coord *arg1, f32 *arg2, f32 *arg3, f3 right = cam_get_screen_left() + cam_get_screen_width() * 0.75f; } - if (arg1->z > -2.5f) { + if (screenpos->z > -2.5f) { return -1; } - cam0f0b4d04(arg1, spa0); - sp94.x = arg2[0]; - sp94.y = arg1->y; - sp94.z = arg1->z; + cam0f0b4d04(screenpos, spa0); + sp94.x = xrange[0]; + sp94.y = screenpos->y; + sp94.z = screenpos->z; cam0f0b4d04(&sp94, sp8c); - sp94.x = arg2[1]; - sp94.y = arg1->y; - sp94.z = arg1->z; + sp94.x = xrange[1]; + sp94.y = screenpos->y; + sp94.z = screenpos->z; cam0f0b4d04(&sp94, sp84); - sp94.x = arg1->x; - sp94.y = arg3[1]; - sp94.z = arg1->z; + sp94.x = screenpos->x; + sp94.y = yrange[1]; + sp94.z = screenpos->z; cam0f0b4d04(&sp94, sp7c); - sp94.x = arg1->x; - sp94.y = arg3[0]; - sp94.z = arg1->z; + sp94.x = screenpos->x; + sp94.y = yrange[0]; + sp94.z = screenpos->z; cam0f0b4d04(&sp94, sp74); if (sp74[1] >= top && bottom >= sp7c[1]) { @@ -2482,7 +2482,7 @@ f32 func0f06438c(struct prop *prop, struct coord *arg1, f32 *arg2, f32 *arg3, f3 value = bottom; } - arg4[1] = value; + aimpos[1] = value; if (bmove_is_auto_aim_x_enabled_for_current_weapon() || cangangsta) { f32 value = spa0[0]; @@ -2493,7 +2493,7 @@ f32 func0f06438c(struct prop *prop, struct coord *arg1, f32 *arg2, f32 *arg3, f3 value = right; } - arg4[0] = value; + aimpos[0] = value; } if (cam_get_screen_left() + 0.5f * cam_get_screen_width() >= sp8c[0] @@ -2686,13 +2686,13 @@ void autoaim_tick(void) || bmove_is_auto_aim_x_enabled_for_current_weapon() || cangangsta) && !ismelee) { // Standard auto aim - f32 bestthing = -1; + f32 bestscore = -1; struct prop *prop; - struct coord sp94; - f32 sp8c[2]; - f32 sp84[2]; + struct coord screenpos; + f32 xrange[2]; + f32 yrange[2]; struct chrdata *chr; - f32 sp78[2]; + f32 thisaimpos[2]; struct prop **ptr = g_Vars.endonscreenprops - 1; // Iterate onscreen props near to far @@ -2709,16 +2709,16 @@ void autoaim_tick(void) || chr_get_held_prop(chr, HAND_LEFT) || (chr->chrflags & CHRCFLAG_FORCEAUTOAIM) || chr->gunprop) - && chr_calculate_auto_aim(prop, &sp94, sp8c, sp84)) { - f32 thing = func0f06438c(prop, &sp94, sp8c, sp84, sp78, false, cangangsta, 0); + && chr_calculate_autoaim(prop, &screenpos, xrange, yrange)) { + f32 score = prop_calculate_autoaim_score(prop, &screenpos, xrange, yrange, thisaimpos, false, cangangsta, 0); - if (thing > bestthing) { - bestthing = thing; - aimpos[0] = sp78[0]; - aimpos[1] = sp78[1]; + if (score > bestscore) { + bestscore = score; + aimpos[0] = thisaimpos[0]; + aimpos[1] = thisaimpos[1]; bestprop = prop; - if (thing >= 1) { + if (score >= 1) { break; } } @@ -3308,7 +3308,7 @@ void props_defrag_room_props(void) } } -void func0f0661fc(void) +void prop_debug_roomblocks(void) { // empty } diff --git a/src/game/propobj.c b/src/game/propobj.c index cd27f3475..ebc25190a 100644 --- a/src/game/propobj.c +++ b/src/game/propobj.c @@ -784,7 +784,7 @@ bool func0f0679ac(struct model *model, f32 *max, f32 *min, f32 arg3[2], f32 arg4 return !first; } -void func0f067bc4(struct model *model, f32 *max, f32 *min, s32 axis) +void model_get_screen_coords_by_axis(struct model *model, f32 *max, f32 *min, s32 axis) { struct modelnode *node = model->definition->rootnode; bool first = true; @@ -837,10 +837,10 @@ void func0f067bc4(struct model *model, f32 *max, f32 *min, s32 axis) } } -void func0f067d88(struct model *model, f32 *arg1, f32 *arg2, f32 *arg3, f32 *arg4) +void model_get_screen_coords3(struct model *model, f32 *xmax, f32 *xmin, f32 *ymax, f32 *ymin) { - func0f067bc4(model, arg1, arg2, 0); - func0f067bc4(model, arg3, arg4, 1); + model_get_screen_coords_by_axis(model, xmax, xmin, 0); + model_get_screen_coords_by_axis(model, ymax, ymin, 1); } bool model_get_screen_coords2(struct model *model, f32 *x2, f32 *x1, f32 *y2, f32 *y1) @@ -17642,7 +17642,7 @@ s32 obj_test_for_pickup(struct prop *prop) return TICKOP_NONE; } -bool func0f0899dc(struct prop *prop, struct coord *arg1, f32 *arg2, f32 *arg3) +bool func0f0899dc(struct prop *prop, struct coord *arg1, f32 *xrange, f32 *yrange) { if (prop->flags & PROPFLAG_ONTHISSCREENTHISTICK) { struct defaultobj *obj = prop->obj; @@ -17654,13 +17654,13 @@ bool func0f0899dc(struct prop *prop, struct coord *arg1, f32 *arg2, f32 *arg3) arg1->x = matrix->m[3][0]; arg1->y = matrix->m[3][1]; - arg3[0] = 0; - arg3[1] = 0; + yrange[0] = 0; + yrange[1] = 0; - arg2[0] = 0; - arg2[1] = 0; + xrange[0] = 0; + xrange[1] = 0; - func0f067d88(obj->model, &arg2[1], &arg2[0], &arg3[1], &arg3[0]); + model_get_screen_coords3(obj->model, &xrange[1], &xrange[0], &yrange[1], &yrange[0]); return true; } diff --git a/src/include/game/chr.h b/src/include/game/chr.h index efbf582b7..fceeeb431 100644 --- a/src/include/game/chr.h +++ b/src/include/game/chr.h @@ -50,7 +50,7 @@ void chr_test_hit(struct prop *prop, struct shotdata *shotdata, bool isshooting, void chr_hit(struct shotdata *shotdata, struct hit *hit); void chranimdebug_everyone(bool enable); void chrs_check_for_noise(f32 noiseradius); -bool chr_calculate_auto_aim(struct prop *prop, struct coord *arg1, f32 *arg2, f32 *arg3); +bool chr_calculate_autoaim(struct prop *prop, struct coord *screenpos, f32 *xrange, f32 *yrange); s32 shieldhit_node_to_cmnum(struct prop *arg0, struct modelnode *node, struct model *model, struct prop *arg3); bool shieldhit_cmnum_to_node(s32 arg0, struct prop *prop, struct prop **propptr, struct modelnode **nodeptr, struct model **modelptr); void shieldhit_create(struct prop *rootprop, f32 shield, struct prop *hitprop, struct modelnode *node, struct model *model, s32 side, s16 *arg6); diff --git a/src/include/game/prop.h b/src/include/game/prop.h index b193092d9..3fee161f6 100644 --- a/src/include/game/prop.h +++ b/src/include/game/prop.h @@ -22,8 +22,8 @@ void prop_reparent(struct prop *mover, struct prop *adopter); void prop_detach(struct prop *prop); Gfx *prop_render(Gfx *gdl, struct prop *prop, bool xlupass); Gfx *props_render(Gfx *gdl, RoomNum renderroomnum, s32 renderpass, RoomNum *roomnumsbyprop); -void weapon_play_whoosh_sound(s32 weaponnum, struct prop *prop); -void func0f060bac(s32 weaponnum, struct prop *prop); +void weapon_play_melee_miss_sound(s32 weaponnum, struct prop *prop); +void weapon_play_melee_hit_sound(s32 weaponnum, struct prop *prop); struct prop *shot_calculate_hits(s32 handnum, bool isshooting, struct coord *gunpos2d, struct coord *gundir2d, struct coord *gunpos3d, struct coord *gundir3d, u32 arg6, f32 distance, bool arg8); struct prop *prop_find_aiming_at(s32 handnum, bool isshooting, u32 context); void shot_create(s32 handnum, bool arg1, bool dorandom, s32 numshots, bool arg4); @@ -41,7 +41,6 @@ void props_tick_player(bool islastplayer); void props_tick_pad_effects(void); void prop_set_perim_enabled(struct prop *prop, bool enable); void props_test_for_pickup(void); -f32 func0f06438c(struct prop *prop, struct coord *arg1, f32 *arg2, f32 *arg3, f32 *arg4, bool throughobjects, bool cangangsta, s32 arg7); void farsight_choose_target(void); void autoaim_tick(void); u32 prop_door_get_cd_types(struct prop *prop); diff --git a/src/include/game/propobj.h b/src/include/game/propobj.h index 384fc33ab..48352657d 100644 --- a/src/include/game/propobj.h +++ b/src/include/game/propobj.h @@ -57,8 +57,8 @@ bool func0f0677ac(struct coord *coord, struct coord *arg1, struct coord *pos, st bool func0f0678f8(struct coord *coord, struct coord *arg1, s32 padnum); bool func0f06797c(struct coord *coord, f32 arg1, s32 padnum); bool func0f0679ac(struct model *model, f32 *max, f32 *min, f32 arg3[2], f32 arg4[2]); -void func0f067bc4(struct model *model, f32 *max, f32 *min, s32 axis); -void func0f067d88(struct model *model, f32 *arg1, f32 *arg2, f32 *arg3, f32 *arg4); +void model_get_screen_coords_by_axis(struct model *model, f32 *max, f32 *min, s32 axis); +void model_get_screen_coords3(struct model *model, f32 *xmax, f32 *xmin, f32 *ymax, f32 *ymin); bool model_get_screen_coords2(struct model *model, f32 *x2, f32 *x1, f32 *y2, f32 *y1); bool model_get_screen_coords(struct model *model, f32 *x2, f32 *x1, f32 *y2, f32 *y1); void func0f06803c(struct coord *arg0, f32 *arg1, f32 *arg2, f32 *arg3, f32 *arg4); @@ -258,7 +258,7 @@ void weapon_get_pickup_text(char *buffer, s32 weaponnum, bool dual); void current_player_queue_pickup_weapon_hudmsg(u32 weaponnum, bool dual); s32 prop_pickup_by_player(struct prop *prop, bool showhudmsg); s32 obj_test_for_pickup(struct prop *prop); -bool func0f0899dc(struct prop *prop, struct coord *arg1, f32 *arg2, f32 *arg3); +bool func0f0899dc(struct prop *prop, struct coord *arg1, f32 *xrange, f32 *yrange); void model_free_vertices(s32 vtxstoretype, struct model *model); struct prop *hat_apply_to_chr(struct hatobj *hat, struct chrdata *chr, struct modeldef *modeldef, struct prop *prop, struct model *model); void hat_load_and_apply_to_chr(struct hatobj *hat, struct chrdata *chr);