From 8c836ebdd7a297135b0272808b4c39414b10ff49 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sun, 29 Mar 2020 11:44:12 +1000 Subject: [PATCH] Decompile currentPlayerGiveAmmoForWeapon --- src/game/data/inventory.c | 98 ---------------------------------- src/game/game_097ba0.c | 36 +++++-------- src/game/propobj.c | 4 +- src/include/game/game_097ba0.h | 2 +- src/include/types.h | 7 +-- 5 files changed, 17 insertions(+), 130 deletions(-) diff --git a/src/game/data/inventory.c b/src/game/data/inventory.c index ab2b0268c..b245be11f 100644 --- a/src/game/data/inventory.c +++ b/src/game/data/inventory.c @@ -150,8 +150,6 @@ struct weaponfunc_shootsingle invfunc_00011160 = { // 111a0 struct inventory_ammo invammo_default = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_RIFLE, CASING_RIFLE, 30, // clip size @@ -568,8 +566,6 @@ struct weaponfunc_close invfunc_falcon2_pistolwhip = { // 11720 struct inventory_ammo invammo_falcon2 = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_PISTOL, CASING_STANDARD, 8, // clip size @@ -579,8 +575,6 @@ struct inventory_ammo invammo_falcon2 = { // 11734 struct inventory_ammo invammo_falcon2scope = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_PISTOL, CASING_STANDARD, 8, // clip size @@ -792,8 +786,6 @@ struct weaponfunc_shootsingle invfunc_magsec_burst = { // 11a10 struct inventory_ammo invammo_magsec = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_PISTOL, CASING_STANDARD, 9, // clip size @@ -1000,8 +992,6 @@ struct weaponfunc_close invfunc_dy357_pistolwhip = { // 11d48 struct inventory_ammo invammo_dy357 = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_MAGNUM, CASING_STANDARD, 6, // clip size @@ -1160,8 +1150,6 @@ struct weaponfunc_shootsingle invfunc_phoenix_explosiveshells = { // 11f40 struct inventory_ammo invammo_phoenix = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_PISTOL, CASING_NONE, 8, // clip size @@ -1313,8 +1301,6 @@ struct weaponfunc_shootsingle invfunc_mauler_chargeshot = { // 1216c struct inventory_ammo invammo_mauler = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_PISTOL, CASING_NONE, 20, // clip size @@ -1484,8 +1470,6 @@ struct weaponfunc_shootauto invfunc_cmp150_followlockon = { // 123d0 struct inventory_ammo invammo_cmp150 = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_SMG, CASING_STANDARD, 32, // clip size @@ -1623,8 +1607,6 @@ struct weaponfunc_shootauto invfunc_cyclone_magazinedischarge = { // 1257c struct inventory_ammo invammo_cyclone = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_SMG, CASING_NONE, 50, // clip size @@ -1737,8 +1719,6 @@ struct weaponfunc_special invfunc_rcp120_cloak = { // 126e0 struct inventory_ammo invammo_rcp120 = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_SMG, CASING_STANDARD, 120, // clip size @@ -1859,8 +1839,6 @@ struct weaponfunc_shootauto invfunc_callisto_highimpactshells = { // 12854 struct inventory_ammo invammo_callisto = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_SMG, CASING_NONE, 32, // clip size @@ -1970,8 +1948,6 @@ struct weaponfunc_throw invfunc_dragon_selfdestruct = { // 129a4 struct inventory_ammo invammo_dragon = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_RIFLE, CASING_RIFLE, 30, // clip size @@ -2134,8 +2110,6 @@ struct weaponfunc_shootprojectile invfunc_superdragon_grenadelauncher = { // 12bc8 struct inventory_ammo invammo_superdragon = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_RIFLE, CASING_RIFLE, 30, // clip size @@ -2145,8 +2119,6 @@ struct inventory_ammo invammo_superdragon = { // 12bdc struct inventory_ammo invammo_superdragon_grenades = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_DEVASTATOR, CASING_NONE, 6, // clip size @@ -2279,8 +2251,6 @@ struct weaponfunc_shootauto invfunc_ar34_usescope = { // 12d8c struct inventory_ammo invammo_ar34 = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_RIFLE, CASING_RIFLE, 30, // clip size @@ -2429,8 +2399,6 @@ struct weaponfunc_shootauto invfunc_k7avenger_threatdetector = { // 12f64 struct inventory_ammo invammo_k7avenger = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_RIFLE, CASING_RIFLE, 25, // clip size @@ -2575,8 +2543,6 @@ struct weaponfunc_throw invfunc_laptopgun_deploy = { // 13178 struct inventory_ammo invammo_laptopgun = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_SMG, CASING_NONE, 50, // clip size @@ -2698,8 +2664,6 @@ struct weaponfunc_shootsingle invfunc_shotgun_double = { // 132f8 struct inventory_ammo invammo_shotgun = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_SHOTGUN, CASING_SHOTGUN, 9, // clip size @@ -2858,8 +2822,6 @@ struct weaponfunc_close invfunc_reaper_grind = { // 134fc struct inventory_ammo invammo_reaper = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_REAPER, CASING_REAPER, 200, // clip size @@ -3005,8 +2967,6 @@ struct weaponfunc_shootprojectile invfunc_rocketlauncher_homing = { // 136d8 struct inventory_ammo invammo_rocketlauncher = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_ROCKET, CASING_NONE, 1, // clip size @@ -3121,8 +3081,6 @@ struct weaponfunc_shootprojectile invfunc_slayer_flybywire = { // 1384c struct inventory_ammo invammo_slayer = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_ROCKET, CASING_NONE, 1, // clip size @@ -3248,8 +3206,6 @@ struct weaponfunc_shootprojectile invfunc_devastator_wallhugger = { // 139fc struct inventory_ammo invammo_devastator = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_DEVASTATOR, CASING_NONE, 8, // clip size @@ -3335,8 +3291,6 @@ struct weaponfunc_throw invfunc_timedmine_throw = { // 13adc struct inventory_ammo invammo_timedmine = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_TIMED_MINE, CASING_NONE, 1, // clip size @@ -3439,8 +3393,6 @@ struct weaponfunc_special invfunc_remotemine_detonate = { // 13bf8 struct inventory_ammo invammo_remotemine = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_REMOTE_MINE, CASING_NONE, 1, // clip size @@ -3495,8 +3447,6 @@ struct weaponfunc_throw invfunc_proxymine_throw = { // 13c84 struct inventory_ammo invammo_proximitymine = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_PROXY_MINE, CASING_NONE, 1, // clip size @@ -3566,8 +3516,6 @@ struct weaponfunc_throw invfunc_ecmmine_throw = { // 13d44 struct inventory_ammo invammo_ecmmine = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_ECM_MINE, CASING_NONE, 1, // clip size @@ -3679,8 +3627,6 @@ struct weaponfunc_throw invfunc_grenade_pinball = { // 13e94 struct inventory_ammo invammo_grenade = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_GRENADE, CASING_NONE, 1, // clip size @@ -3746,8 +3692,6 @@ struct weaponfunc_throw invfunc_nbomb_proxy = { // 13f40 struct inventory_ammo invammo_nbomb = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_NBOMB, CASING_NONE, 1, // clip size @@ -3864,8 +3808,6 @@ struct weaponfunc_shootsingle invfunc_farsight_targetlocator = { // 14098 struct inventory_ammo invammo_farsight = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_FARSIGHT, CASING_NONE, 8, // clip size @@ -4020,8 +3962,6 @@ struct weaponfunc_shootprojectile invfunc_crossbow_shoot = { // 142a8 struct inventory_ammo invammo_crossbow = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_CROSSBOW, CASING_NONE, 5, // clip size @@ -4157,8 +4097,6 @@ struct weaponfunc_close invfunc_tranquilizer_lethal = { // 14480 struct inventory_ammo invammo_tranquilizer = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_SEDATIVE, CASING_NONE, 8, // clip size @@ -4198,8 +4136,6 @@ struct weapon invitem_tranquilizer = { // 144ec struct inventory_ammo invammo_psychosisgun = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_PSYCHOSIS, CASING_NONE, 8, // clip size @@ -4335,8 +4271,6 @@ struct weaponfunc_special invfunc_sniperrifle_crouch = { // 1468c struct inventory_ammo invammo_sniperrifle = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_RIFLE, CASING_RIFLE, 8, // clip size @@ -4505,8 +4439,6 @@ struct weaponfunc_shootsingle invfunc_pp9i_shoot = { // 14868 struct inventory_ammo invammo_pp9i = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_PISTOL, CASING_STANDARD, 7, // clip size @@ -4571,8 +4503,6 @@ struct weaponfunc_shootsingle invfunc_cc13_shoot = { // 14924 struct inventory_ammo invammo_cc13 = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_PISTOL, CASING_STANDARD, 8, // clip size @@ -4635,8 +4565,6 @@ struct weaponfunc_shootauto invfunc_kl01313_shoot = { // 149dc struct inventory_ammo invammo_kl01313 = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_SMG, CASING_STANDARD, 20, // clip size @@ -4699,8 +4627,6 @@ struct weaponfunc_shootauto invfunc_kf7special_shoot = { // 14a94 struct inventory_ammo invammo_kf7special = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_RIFLE, CASING_RIFLE, 30, // clip size @@ -4763,8 +4689,6 @@ struct weaponfunc_shootauto invfunc_zzt9mm_shoot = { // 14b4c struct inventory_ammo invammo_zzt9mm = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_SMG, CASING_STANDARD, 32, // clip size @@ -4827,8 +4751,6 @@ struct weaponfunc_shootauto invfunc_dmc_shoot = { // 14c04 struct inventory_ammo invammo_dmc = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_SMG, CASING_STANDARD, 30, // clip size @@ -4891,8 +4813,6 @@ struct weaponfunc_shootauto invfunc_ar53_shoot = { // 14cbc struct inventory_ammo invammo_ar53 = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_RIFLE, CASING_RIFLE, 30, // clip size @@ -4955,8 +4875,6 @@ struct weaponfunc_shootauto invfunc_rcp45_shoot = { // 14d74 struct inventory_ammo invammo_rcp45 = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_SMG, CASING_STANDARD, 80, // clip size @@ -5062,8 +4980,6 @@ struct weaponfunc_shootauto invfunc_59_rapidfire = { // 14ea4 struct inventory_ammo invammo_59 = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_SMG, CASING_RIFLE, 27, // clip size @@ -5126,8 +5042,6 @@ struct weaponfunc_shootauto invfunc_5a_rapidfire = { // 14f5c struct inventory_ammo invammo_5a = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_SMG, CASING_RIFLE, 27, // clip size @@ -5271,8 +5185,6 @@ struct weaponfunc_throw invfunc_combatknife_throw = { // 1511c struct inventory_ammo invammo_combatknife = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_KNIFE, CASING_NONE, 1, // clip size @@ -5338,8 +5250,6 @@ struct weaponfunc_throw invfunc_targetamplifier_throw = { // 151c8 struct inventory_ammo invammo_bug = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_BUG, CASING_NONE, 1, // clip size @@ -5526,8 +5436,6 @@ struct weaponfunc_visual invfunc_cloak_primary = { // 153d0 struct inventory_ammo invammo_cloakingdevice = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_CLOAK, CASING_NONE, 10, // clip size @@ -5591,8 +5499,6 @@ struct weaponfunc_special invfunc_combatboost_revert = { // 15474 struct inventory_ammo invammo_combatboost = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_BOOST, CASING_NONE, 4, // clip size @@ -6446,8 +6352,6 @@ struct weaponfunc_shootprojectile invfunc_rocketlauncher34_primary = { // 15e20 struct inventory_ammo invammo_rocketlauncher34 = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_ROCKET, CASING_NONE, 1, // clip size @@ -6511,8 +6415,6 @@ struct weaponfunc_shootsingle invfunc_tester_primary = { // 15ed4 struct inventory_ammo invammo_tester = { - 0x0000, // unk00 - 0x00, // unk02 AMMOTYPE_PISTOL, CASING_STANDARD, 8, // clip size diff --git a/src/game/game_097ba0.c b/src/game/game_097ba0.c index ce8ff9611..209765f7e 100644 --- a/src/game/game_097ba0.c +++ b/src/game/game_097ba0.c @@ -21801,30 +21801,18 @@ glabel func0f0a9a74 /* f0a9ac0: 00000000 */ sll $zero,$zero,0x0 ); -GLOBAL_ASM( -glabel func0f0a9ac4 -/* f0a9ac4: 27bdffe8 */ addiu $sp,$sp,-24 -/* f0a9ac8: afbf0014 */ sw $ra,0x14($sp) -/* f0a9acc: afa5001c */ sw $a1,0x1c($sp) -/* f0a9ad0: 0fc2c3f4 */ jal weaponFindById -/* f0a9ad4: afa60020 */ sw $a2,0x20($sp) -/* f0a9ad8: 10400009 */ beqz $v0,.L0f0a9b00 -/* f0a9adc: 8fae001c */ lw $t6,0x1c($sp) -/* f0a9ae0: 000e7880 */ sll $t7,$t6,0x2 -/* f0a9ae4: 004fc021 */ addu $t8,$v0,$t7 -/* f0a9ae8: 8f03001c */ lw $v1,0x1c($t8) -/* f0a9aec: 8fa50020 */ lw $a1,0x20($sp) -/* f0a9af0: 50600004 */ beqzl $v1,.L0f0a9b04 -/* f0a9af4: 8fbf0014 */ lw $ra,0x14($sp) -/* f0a9af8: 0fc2a58a */ jal currentPlayerGiveAmmo -/* f0a9afc: 8c640000 */ lw $a0,0x0($v1) -.L0f0a9b00: -/* f0a9b00: 8fbf0014 */ lw $ra,0x14($sp) -.L0f0a9b04: -/* f0a9b04: 27bd0018 */ addiu $sp,$sp,0x18 -/* f0a9b08: 03e00008 */ jr $ra -/* f0a9b0c: 00000000 */ sll $zero,$zero,0x0 -); +void currentPlayerGiveAmmoForWeapon(u32 weaponnum, u32 func, u32 quantity) +{ + struct weapon *weapon = weaponFindById(weaponnum); + + if (weapon) { + struct inventory_ammo *ammo = weapon->ammos[func]; + + if (ammo) { + currentPlayerGiveAmmo(ammo->type, quantity); + } + } +} GLOBAL_ASM( glabel func0f0a9b10 diff --git a/src/game/propobj.c b/src/game/propobj.c index 14a958bb2..70b3832cb 100644 --- a/src/game/propobj.c +++ b/src/game/propobj.c @@ -38015,7 +38015,7 @@ bool propobjInteract(struct prop *prop) func0f087d10(WEAPON_LAPTOPGUN); if (laptop->unka9 > 0 && laptop->unka9 != 255) { - func0f0a9ac4(WEAPON_LAPTOPGUN, 0, func0f0a9a74(WEAPON_LAPTOPGUN, 0) + laptop->unka9); + currentPlayerGiveAmmoForWeapon(WEAPON_LAPTOPGUN, 0, func0f0a9a74(WEAPON_LAPTOPGUN, 0) + laptop->unka9); } } } else { @@ -42756,7 +42756,7 @@ glabel var7f1aae98 /* f08b554: 00cc3023 */ subu $a2,$a2,$t4 .L0f08b558: /* f08b558: 2404000e */ addiu $a0,$zero,0xe -/* f08b55c: 0fc2a6b1 */ jal func0f0a9ac4 +/* f08b55c: 0fc2a6b1 */ jal currentPlayerGiveAmmoForWeapon /* f08b560: 00002825 */ or $a1,$zero,$zero /* f08b564: 0fc4a24b */ jal setCurrentPlayerNum /* f08b568: 8fa40030 */ lw $a0,0x30($sp) diff --git a/src/include/game/game_097ba0.h b/src/include/game/game_097ba0.h index c362d3918..bf9fb0cac 100644 --- a/src/include/game/game_097ba0.h +++ b/src/include/game/game_097ba0.h @@ -159,7 +159,7 @@ bool ammotypeAllowsUnlimitedAmmo(u32 ammotype); u32 func0f0a9980(void); s32 weaponGetAmmoType(s32 weaponnum, u32 func); s32 func0f0a9a74(s32 weaponnum, s32 arg1); -void func0f0a9ac4(s32 weaponnum, s32 arg1, s32 arg2); +void currentPlayerGiveAmmoForWeapon(u32 weaponnum, u32 func, u32 quantity); u32 func0f0a9b10(void); u32 func0f0a9b68(void); u32 func0f0a9d2c(void); diff --git a/src/include/types.h b/src/include/types.h index 82fa6cb15..9c701de72 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -2980,9 +2980,7 @@ struct weaponfunc_visual { }; struct inventory_ammo { - u16 unk00; - u8 unk02; - u8 type; + u32 type; u32 casingeject; u16 clipsize; u32 *reload_animation; @@ -2997,8 +2995,7 @@ struct weapon { /*0x0c*/ u32 *pritosec_animation; /*0x10*/ u32 *sectopri_animation; /*0x14*/ void *functions[2]; - /*0x1c*/ struct inventory_ammo *pri_ammo; - /*0x20*/ struct inventory_ammo *sec_ammo; + /*0x1c*/ struct inventory_ammo *ammos[2]; /*0x24*/ struct inventory_typee *eptr; /*0x28*/ f32 sway; /*0x2c*/ f32 leftright;