From d6cccc48ae915fa5b4582d5ef5b15c3ee9ba6a03 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Thu, 9 Sep 2021 22:51:40 +1000 Subject: [PATCH] Decompile weaponHasAmmoFlag and discover AMMOFLAG constants --- src/game/activemenu/activemenu.c | 2 +- src/game/bondgun.c | 67 ++++++++++++++++---------------- src/game/chr/chr.c | 2 +- src/game/game_0b0fd0.c | 46 ++++++++-------------- src/game/inventory/items.c | 26 ++++++------- src/game/propobj.c | 32 +++++++-------- src/game/training/training.c | 22 +++++------ src/include/constants.h | 5 +++ src/include/game/bondgun.h | 4 +- src/include/game/game_0b0fd0.h | 2 +- 10 files changed, 101 insertions(+), 107 deletions(-) diff --git a/src/game/activemenu/activemenu.c b/src/game/activemenu/activemenu.c index 6b3220d84..748b7bb9a 100644 --- a/src/game/activemenu/activemenu.c +++ b/src/game/activemenu/activemenu.c @@ -744,7 +744,7 @@ void amGetSlotDetails(s32 slot, u32 *flags, char *label) } else { if (invGetWeaponNumByIndex(g_AmMenus[g_AmIndex].invindexes[slot]) == WEAPON_CLOAKINGDEVICE) { // Special case: "Cloak %d" - qty = bgunGetAmmoCountWithCheck(AMMOTYPE_CLOAK); + qty = bgunGetReservedAmmoCount(AMMOTYPE_CLOAK); secs = qty / PALDOWN(60); modulo = (qty - (secs * PALDOWN(60))) * 100 / PALDOWN(60); sprintf(label, langGet(L_OPTIONS_491), secs + (modulo > 0 ? 1 : 0)); // "cloak %d" diff --git a/src/game/bondgun.c b/src/game/bondgun.c index 1b53d7027..805a6e85e 100644 --- a/src/game/bondgun.c +++ b/src/game/bondgun.c @@ -421,7 +421,7 @@ bool bgun0f097df0(struct inventory_typef *arg0, struct hand *hand) return result; } -void bgun0f097e74(s16 partnum, s32 arg1, struct hand *hand, struct modelfiledata *arg3) +void bgunSetPartVisible(s16 partnum, bool visible, struct hand *hand, struct modelfiledata *filedata) { struct modelnode *node; @@ -432,16 +432,16 @@ void bgun0f097e74(s16 partnum, s32 arg1, struct hand *hand, struct modelfiledata if (node) { struct modelrodata_toggle *rodata = &node->rodata->toggle; u32 *ptr = &hand->handsavedata[rodata->rwdataindex]; - *ptr = arg1; + *ptr = visible; } } } else { - node = modelGetPart(arg3, partnum); + node = modelGetPart(filedata, partnum); if (node) { struct modelrodata_toggle *rodata = &node->rodata->toggle; u32 *ptr = &hand->unk0a6c[rodata->rwdataindex]; - *ptr = arg1; + *ptr = visible; } } } @@ -458,19 +458,19 @@ void bgun0f097f28(struct hand *hand, struct modelfiledata *filedata, struct inve while (!done) { if (bgun0f097df0(thing, hand)) { if (thing->unk04 == 0) { - bgun0f097e74(thing->partnum, 1, hand, filedata); + bgunSetPartVisible(thing->partnum, true, hand, filedata); } if (thing->unk04 == 1) { - bgun0f097e74(thing->partnum, 0, hand, filedata); + bgunSetPartVisible(thing->partnum, false, hand, filedata); } if (thing->unk04 == 3) { - bgun0f097e74(thing->partnum, 1, hand, filedata); + bgunSetPartVisible(thing->partnum, true, hand, filedata); } } else { if (thing->unk04 == 3) { - bgun0f097e74(thing->partnum, 0, hand, filedata); + bgunSetPartVisible(thing->partnum, false, hand, filedata); } } @@ -482,22 +482,22 @@ void bgun0f097f28(struct hand *hand, struct modelfiledata *filedata, struct inve } } -void bgun0f098030(struct hand *hand, struct modelfiledata *arg1) +void bgun0f098030(struct hand *hand, struct modelfiledata *filedata) { struct weapon *weapon = weaponFindById(hand->gset.weaponnum); s32 i; s32 j; - bgun0f097f28(hand, arg1, weapon->fptr); - bgun0f097e74(MODELPART_0042, 0, hand, arg1); + bgun0f097f28(hand, filedata, weapon->fptr); + bgunSetPartVisible(MODELPART_0042, false, hand, filedata); for (i = 0; i < 2; i++) { - if (weapon->ammos[i] && (weapon->ammos[i]->flags & WEAPONFLAG_ONEHANDED)) { + if (weapon->ammos[i] && (weapon->ammos[i]->flags & AMMOFLAG_QTYAFFECTSPARTVIS)) { for (j = 0; j < hand->clipsizes[i]; j++) { if (j >= hand->loadedammo[i]) { - bgun0f097e74(j + 100, 0, hand, arg1); + bgunSetPartVisible(j + 100, false, hand, filedata); } else { - bgun0f097e74(j + 100, 1, hand, arg1); + bgunSetPartVisible(j + 100, true, hand, filedata); } } } @@ -939,7 +939,7 @@ glabel var7f1ad3acpf /* f0986d4: afa3005c */ sw $v1,0x5c($sp) /* f0986d8: afa2007c */ sw $v0,0x7c($sp) /* f0986dc: 02403025 */ move $a2,$s2 -/* f0986e0: 0fc25f65 */ jal bgun0f097e74 +/* f0986e0: 0fc25f65 */ jal bgunSetPartVisible /* f0986e4: 8fa70164 */ lw $a3,0x164($sp) /* f0986e8: 8fa2007c */ lw $v0,0x7c($sp) /* f0986ec: 8fa3005c */ lw $v1,0x5c($sp) @@ -1437,7 +1437,7 @@ glabel var7f1ac1b0 /* f0986ac: afa30054 */ sw $v1,0x54($sp) /* f0986b0: afa20074 */ sw $v0,0x74($sp) /* f0986b4: 02603025 */ or $a2,$s3,$zero -/* f0986b8: 0fc25f9d */ jal bgun0f097e74 +/* f0986b8: 0fc25f9d */ jal bgunSetPartVisible /* f0986bc: 8fa7015c */ lw $a3,0x15c($sp) /* f0986c0: 8fa20074 */ lw $v0,0x74($sp) /* f0986c4: 8fa30054 */ lw $v1,0x54($sp) @@ -1911,7 +1911,7 @@ glabel var7f1ac1b0 /* f096718: afa30048 */ sw $v1,0x48($sp) /* f09671c: afa2006c */ sw $v0,0x6c($sp) /* f096720: 02603025 */ or $a2,$s3,$zero -/* f096724: 0fc257b8 */ jal bgun0f097e74 +/* f096724: 0fc257b8 */ jal bgunSetPartVisible /* f096728: 8fa70154 */ lw $a3,0x154($sp) /* f09672c: 8fa2006c */ lw $v0,0x6c($sp) /* f096730: 8fa30048 */ lw $v1,0x48($sp) @@ -2260,7 +2260,7 @@ void bgun0f098df8(s32 weaponfunc, struct handweaponinfo *info, struct hand *hand hand->loadedammo[ammoindex] += amount; g_Vars.currentplayer->ammoheldarr[info->gunctrl->ammotypes[ammoindex]] -= amount; - if (info->definition->ammos[ammoindex]->flags & 0x01) { + if (info->definition->ammos[ammoindex]->flags & AMMOFLAG_NORESERVE) { g_Vars.currentplayer->ammoheldarr[info->gunctrl->ammotypes[ammoindex]] = 0; } @@ -5482,7 +5482,7 @@ glabel var7f1ac31c // // hand->unk0d0e_07 = true; // -// if (info->definition->ammos[func->ammoindex]->flags & 4) { +// if (info->definition->ammos[func->ammoindex]->flags & AMMOFLAG_INCREMENTALRELOAD) { // hand->unk0cc8_03 = true; // } // @@ -5501,7 +5501,7 @@ glabel var7f1ac31c // // e9c // if (hand); // } else { -// if (info->definition->ammos[func->ammoindex]->flags & 4) { +// if (info->definition->ammos[func->ammoindex]->flags & AMMOFLAG_INCREMENTALRELOAD) { // if (bgun0f098a44(hand, 1)) { // if ((hand->stateflags & HANDSTATEFLAG_00000010) == 0) { // s32 value; @@ -21153,12 +21153,12 @@ glabel var7f1ac9e0 .L0f0a541c: /* f0a541c: 00002825 */ or $a1,$zero,$zero /* f0a5420: 8fa60078 */ lw $a2,0x78($sp) -/* f0a5424: 0fc25f9d */ jal bgun0f097e74 +/* f0a5424: 0fc25f9d */ jal bgunSetPartVisible /* f0a5428: 8fa70088 */ lw $a3,0x88($sp) /* f0a542c: 24040047 */ addiu $a0,$zero,0x47 /* f0a5430: 24050001 */ addiu $a1,$zero,0x1 /* f0a5434: 8fa60078 */ lw $a2,0x78($sp) -/* f0a5438: 0fc25f9d */ jal bgun0f097e74 +/* f0a5438: 0fc25f9d */ jal bgunSetPartVisible /* f0a543c: 8fa70088 */ lw $a3,0x88($sp) /* f0a5440: 3c03800a */ lui $v1,%hi(g_Vars) /* f0a5444: 24639fc0 */ addiu $v1,$v1,%lo(g_Vars) @@ -28887,9 +28887,9 @@ void bgunSetAmmoQuantity(s32 ammotype, s32 quantity) funcnum = FUNC_SECONDARY; } - if (funcnum != -1 && func0f0b184c(weaponnum, funcnum, 1)) { - // This part seems a bit odd. It's adding the ammo rather than setting - // it, and it clears the held amount. Maybe this code isn't reachable. + if (funcnum != -1 && weaponHasAmmoFlag(weaponnum, funcnum, AMMOFLAG_NORESERVE)) { + // For cloak and combat boost, ammo cannot be held outside of the weapon. + // So just add it to the loaded clip. player->hands[0].loadedammo[funcnum] += quantity; if (player->hands[0].loadedammo[funcnum] > player->hands[0].clipsizes[funcnum]) { @@ -28902,7 +28902,8 @@ void bgunSetAmmoQuantity(s32 ammotype, s32 quantity) magamount = 0; - if (funcnum != -1 && func0f0b184c(weaponnum, funcnum, 2)) { + // For throwable items, the capacity applies to reserve + loaded + if (funcnum != -1 && weaponHasAmmoFlag(weaponnum, funcnum, AMMOFLAG_EQUIPPEDISRESERVE)) { magamount = player->hands[0].loadedammo[funcnum] + player->hands[1].loadedammo[funcnum]; } @@ -28913,7 +28914,7 @@ void bgunSetAmmoQuantity(s32 ammotype, s32 quantity) } } -s32 bgunGetAmmoCountWithCheck(s32 ammotype) +s32 bgunGetReservedAmmoCount(s32 ammotype) { s32 i; s32 j; @@ -28923,7 +28924,7 @@ s32 bgunGetAmmoCountWithCheck(s32 ammotype) for (i = 0; i < 2; i++) { if (player->hands[i].inuse) { for (j = 0; j < 2; j++) { - if (player->gunctrl.ammotypes[j] == ammotype && func0f0b184c(player->hands[i].gset.weaponnum, j, 0x00000001)) { + if (player->gunctrl.ammotypes[j] == ammotype && weaponHasAmmoFlag(player->hands[i].gset.weaponnum, j, AMMOFLAG_NORESERVE)) { total = total + player->hands[i].loadedammo[j]; } } @@ -29028,7 +29029,7 @@ s32 bgunGetAmmoQtyForWeapon(u32 weaponnum, u32 func) struct inventory_ammo *ammo = weapon->ammos[func]; if (ammo) { - return bgunGetAmmoCountWithCheck(ammo->type); + return bgunGetReservedAmmoCount(ammo->type); } } @@ -34808,7 +34809,7 @@ const char var7f1ac19c[] = "%02d:%02d\n"; // xpos -= 14; // } // -// if (lefthand->clipsizes[ammoindex] > 0 && (weapon->ammos[ammoindex]->flags & 2) == 0) { +// if (lefthand->clipsizes[ammoindex] > 0 && (weapon->ammos[ammoindex]->flags & AMMOFLAG_EQUIPPEDISRESERVE) == 0) { // gdl = bgunRenderHudGauge(gdl, // xpos, bottom - reserveheight - clipheight - 3, xpos + barwidth, bottom - reserveheight - 3, // &lefthand->abmag, lefthand->loadedammo[ammoindex], lefthand->clipsizes[ammoindex], @@ -34845,7 +34846,7 @@ const char var7f1ac19c[] = "%02d:%02d\n"; // // if (hand->clipsizes[ammoindex] > 0 // && weapon->ammos[ammoindex] != NULL -// && (weapon->ammos[ammoindex]->flags & 2) == 0) { +// && (weapon->ammos[ammoindex]->flags & AMMOFLAG_EQUIPPEDISRESERVE) == 0) { // gdl = bgunRenderHudGauge(gdl, xpos, bottom - reserveheight - clipheight - 3, xpos + barwidth, // bottom - reserveheight - 3, &hand->abmag, hand->loadedammo[ammoindex], hand->clipsizes[ammoindex], // 0x00300080, 0x00ff0040, false); @@ -34856,10 +34857,10 @@ const char var7f1ac19c[] = "%02d:%02d\n"; // // Reserve // // 7ac // if (g_AmmoTypes[ammotype].capacity > 0 -// && (weapon->ammos[ammoindex]->flags & 1) == 0) { +// && (weapon->ammos[ammoindex]->flags & AMMOFLAG_NORESERVE) == 0) { // ammototal = ammoheld; // -// if (weapon->ammos[ammoindex]->flags & 2) { +// if (weapon->ammos[ammoindex]->flags & AMMOFLAG_EQUIPPEDISRESERVE) { // if (hand->clipsizes[ammoindex] > 0) { // ammototal += hand->loadedammo[ammoindex]; // } diff --git a/src/game/chr/chr.c b/src/game/chr/chr.c index d13f08e3e..067441dbd 100644 --- a/src/game/chr/chr.c +++ b/src/game/chr/chr.c @@ -6749,7 +6749,7 @@ void chrUpdateCloak(struct chrdata *chr) if (g_Vars.currentplayer->devicesactive & DEVICE_CLOAKDEVICE) { // Cloak is active - but may or may not be in effect due to recent shooting - s32 qty = bgunGetAmmoCountWithCheck(AMMOTYPE_CLOAK); + s32 qty = bgunGetReservedAmmoCount(AMMOTYPE_CLOAK); if (qty > 0) { if (chr->hidden & CHRHFLAG_CLOAKED) { diff --git a/src/game/game_0b0fd0.c b/src/game/game_0b0fd0.c index 545ac7992..10119bc0f 100644 --- a/src/game/game_0b0fd0.c +++ b/src/game/game_0b0fd0.c @@ -289,35 +289,23 @@ bool weaponHasClassFlag(s32 weaponnum, u32 flag) return (weapon->eptr->flags & flag) != 0; } -GLOBAL_ASM( -glabel func0f0b184c -/* f0b184c: 27bdffe8 */ addiu $sp,$sp,-24 -/* f0b1850: afbf0014 */ sw $ra,0x14($sp) -/* f0b1854: afa5001c */ sw $a1,0x1c($sp) -/* f0b1858: 0fc2c3f4 */ jal weaponFindById -/* f0b185c: afa60020 */ sw $a2,0x20($sp) -/* f0b1860: 14400003 */ bnez $v0,.L0f0b1870 -/* f0b1864: 8fbf0014 */ lw $ra,0x14($sp) -/* f0b1868: 1000000e */ b .L0f0b18a4 -/* f0b186c: 00001025 */ or $v0,$zero,$zero -.L0f0b1870: -/* f0b1870: 8fae001c */ lw $t6,0x1c($sp) -/* f0b1874: 8fa80020 */ lw $t0,0x20($sp) -/* f0b1878: 000e7880 */ sll $t7,$t6,0x2 -/* f0b187c: 004fc021 */ addu $t8,$v0,$t7 -/* f0b1880: 8f03001c */ lw $v1,0x1c($t8) -/* f0b1884: 00001025 */ or $v0,$zero,$zero -/* f0b1888: 10600006 */ beqz $v1,.L0f0b18a4 -/* f0b188c: 00000000 */ nop -/* f0b1890: 90790010 */ lbu $t9,0x10($v1) -/* f0b1894: 03281024 */ and $v0,$t9,$t0 -/* f0b1898: 0002482b */ sltu $t1,$zero,$v0 -/* f0b189c: 10000001 */ b .L0f0b18a4 -/* f0b18a0: 01201025 */ or $v0,$t1,$zero -.L0f0b18a4: -/* f0b18a4: 03e00008 */ jr $ra -/* f0b18a8: 27bd0018 */ addiu $sp,$sp,0x18 -); +bool weaponHasAmmoFlag(s32 weaponnum, s32 funcnum, u32 flag) +{ + struct weapon *weapon = weaponFindById(weaponnum); + struct inventory_ammo *ammo; + + if (weapon == NULL) { + return false; + } + + ammo = weapon->ammos[funcnum]; + + if (ammo) { + return (ammo->flags & flag) != 0; + } + + return false; +} void func0f0b18ac(s32 arg0) { diff --git a/src/game/inventory/items.c b/src/game/inventory/items.c index 68ad1055b..6f7cc502b 100644 --- a/src/game/inventory/items.c +++ b/src/game/inventory/items.c @@ -2456,7 +2456,7 @@ struct inventory_ammo invammo_shotgun = { CASING_SHOTGUN, 9, // clip size invanim_shotgun_reload, // reload animation - 0x04, // flags + AMMOFLAG_INCREMENTALRELOAD, // flags }; struct weapon invitem_shotgun = { @@ -2951,7 +2951,7 @@ struct inventory_ammo invammo_devastator = { CASING_NONE, 8, // clip size invanim_devastator_reload, // reload animation - 0x08, // flags + AMMOFLAG_QTYAFFECTSPARTVIS, // flags }; struct modelpartvisibility invpartvisibility_devastator[] = { @@ -3030,7 +3030,7 @@ struct inventory_ammo invammo_timedmine = { CASING_NONE, 1, // clip size invanim_mine_equiporreload, // reload animation - 0x02, // flags + AMMOFLAG_EQUIPPEDISRESERVE, // flags }; struct weapon invitem_timedmine = { @@ -3115,7 +3115,7 @@ struct inventory_ammo invammo_remotemine = { CASING_NONE, 1, // clip size invanim_remotemine_equiporreload, // reload animation - 0x02, // flags + AMMOFLAG_EQUIPPEDISRESERVE, // flags }; struct modelpartvisibility invpartvisibility_remotemine[] = { @@ -3167,7 +3167,7 @@ struct inventory_ammo invammo_proximitymine = { CASING_NONE, 1, // clip size invanim_mine_equiporreload, // reload animation - 0x02, // flags + AMMOFLAG_EQUIPPEDISRESERVE, // flags }; struct weapon invitem_proximitymine = { @@ -3230,7 +3230,7 @@ struct inventory_ammo invammo_ecmmine = { CASING_NONE, 1, // clip size invanim_ecmmine_equiporreload, // reload animation - 0x02, // flags + AMMOFLAG_EQUIPPEDISRESERVE, // flags }; struct weapon invitem_ecmmine = { @@ -3337,7 +3337,7 @@ struct inventory_ammo invammo_grenade = { CASING_NONE, 1, // clip size invanim_grenade_equiporreload, // reload animation - 0x0a, // flags + AMMOFLAG_EQUIPPEDISRESERVE | AMMOFLAG_QTYAFFECTSPARTVIS, // flags }; struct weapon invitem_grenade = { @@ -3398,7 +3398,7 @@ struct inventory_ammo invammo_nbomb = { CASING_NONE, 1, // clip size invanim_grenade_equiporreload, // reload animation - 0x0a, // flags + AMMOFLAG_EQUIPPEDISRESERVE | AMMOFLAG_QTYAFFECTSPARTVIS, // flags }; struct weapon invitem_nbomb = { @@ -3647,7 +3647,7 @@ struct inventory_ammo invammo_crossbow = { CASING_NONE, 5, // clip size invanim_crossbow_reload, // reload animation - 0x04, // flags + AMMOFLAG_INCREMENTALRELOAD, // flags }; struct modelpartvisibility invpartvisibility_crossbow[] = { @@ -4805,7 +4805,7 @@ struct inventory_ammo invammo_combatknife = { CASING_NONE, 1, // clip size invanim_combatknife_reload, // reload animation - 0x0a, // flags + AMMOFLAG_EQUIPPEDISRESERVE | AMMOFLAG_QTYAFFECTSPARTVIS, // flags }; struct weapon invitem_combatknife = { @@ -4866,7 +4866,7 @@ struct inventory_ammo invammo_bug = { CASING_NONE, 1, // clip size NULL, // reload animation - 0x02, // flags + AMMOFLAG_EQUIPPEDISRESERVE, // flags }; struct weapon invitem_commsrider = { @@ -5042,7 +5042,7 @@ struct inventory_ammo invammo_cloakingdevice = { CASING_NONE, 10, // clip size NULL, // reload animation - 0x01, // flags + AMMOFLAG_NORESERVE, // flags }; struct weapon invitem_cloakingdevice = { @@ -5101,7 +5101,7 @@ struct inventory_ammo invammo_combatboost = { CASING_NONE, 4, // clip size NULL, // reload animation - 0x01, // flags + AMMOFLAG_NORESERVE, // flags }; struct weapon invitem_combatboost = { diff --git a/src/game/propobj.c b/src/game/propobj.c index 51b46b697..9c27b5d3b 100644 --- a/src/game/propobj.c +++ b/src/game/propobj.c @@ -60492,7 +60492,7 @@ glabel func0f088028 /* f08803c: afa60030 */ sw $a2,0x30($sp) /* f088040: 18a00051 */ blez $a1,.L0f088188 /* f088044: afa70034 */ sw $a3,0x34($sp) -/* f088048: 0fc2a5dc */ jal bgunGetAmmoCountWithCheck +/* f088048: 0fc2a5dc */ jal bgunGetReservedAmmoCount /* f08804c: 00000000 */ nop /* f088050: afa20020 */ sw $v0,0x20($sp) /* f088054: 0fc2a63d */ jal bgunGetCapacityByAmmotype @@ -60501,7 +60501,7 @@ glabel func0f088028 /* f088060: 01e2082a */ slt $at,$t7,$v0 /* f088064: 5020000e */ beqzl $at,.L0f0880a0 /* f088068: 8fa80030 */ lw $t0,0x30($sp) -/* f08806c: 0fc2a5dc */ jal bgunGetAmmoCountWithCheck +/* f08806c: 0fc2a5dc */ jal bgunGetReservedAmmoCount /* f088070: 02002025 */ or $a0,$s0,$zero /* f088074: 8fb8002c */ lw $t8,0x2c($sp) /* f088078: 02002025 */ or $a0,$s0,$zero @@ -61292,10 +61292,10 @@ glabel var7f1aae70 /* f088cb4: 8fa40074 */ lw $a0,0x74($sp) /* f088cb8: 18400019 */ blez $v0,.L0f088d20 /* f088cbc: afa20058 */ sw $v0,0x58($sp) -/* f088cc0: 0fc2a5dc */ jal bgunGetAmmoCountWithCheck +/* f088cc0: 0fc2a5dc */ jal bgunGetReservedAmmoCount /* f088cc4: 8fa4006c */ lw $a0,0x6c($sp) /* f088cc8: 8fa4006c */ lw $a0,0x6c($sp) -/* f088ccc: 0fc2a5dc */ jal bgunGetAmmoCountWithCheck +/* f088ccc: 0fc2a5dc */ jal bgunGetReservedAmmoCount /* f088cd0: afa20054 */ sw $v0,0x54($sp) /* f088cd4: 8fa4006c */ lw $a0,0x6c($sp) /* f088cd8: 0fc2a63d */ jal bgunGetCapacityByAmmotype @@ -61326,7 +61326,7 @@ glabel var7f1aae70 /* f088d34: 0fc22095 */ jal weaponGetPickupAmmoQty /* f088d38: 01802025 */ or $a0,$t4,$zero /* f088d3c: afa20050 */ sw $v0,0x50($sp) -/* f088d40: 0fc2a5dc */ jal bgunGetAmmoCountWithCheck +/* f088d40: 0fc2a5dc */ jal bgunGetReservedAmmoCount /* f088d44: 2404000b */ addiu $a0,$zero,0xb /* f088d48: 2404000b */ addiu $a0,$zero,0xb /* f088d4c: 0fc2a63d */ jal bgunGetCapacityByAmmotype @@ -61335,7 +61335,7 @@ glabel var7f1aae70 /* f088d58: 00c2082a */ slt $at,$a2,$v0 /* f088d5c: 5020000f */ beqzl $at,.L0f088d9c /* f088d60: 8fb80074 */ lw $t8,0x74($sp) -/* f088d64: 0fc2a5dc */ jal bgunGetAmmoCountWithCheck +/* f088d64: 0fc2a5dc */ jal bgunGetReservedAmmoCount /* f088d68: 2404000b */ addiu $a0,$zero,0xb /* f088d6c: 2404000b */ addiu $a0,$zero,0xb /* f088d70: 0fc2a58a */ jal bgunSetAmmoQuantity @@ -61939,10 +61939,10 @@ glabel var7f1aae70 /* f088cb4: 8fa40074 */ lw $a0,0x74($sp) /* f088cb8: 18400019 */ blez $v0,.L0f088d20 /* f088cbc: afa20058 */ sw $v0,0x58($sp) -/* f088cc0: 0fc2a5dc */ jal bgunGetAmmoCountWithCheck +/* f088cc0: 0fc2a5dc */ jal bgunGetReservedAmmoCount /* f088cc4: 8fa4006c */ lw $a0,0x6c($sp) /* f088cc8: 8fa4006c */ lw $a0,0x6c($sp) -/* f088ccc: 0fc2a5dc */ jal bgunGetAmmoCountWithCheck +/* f088ccc: 0fc2a5dc */ jal bgunGetReservedAmmoCount /* f088cd0: afa20054 */ sw $v0,0x54($sp) /* f088cd4: 8fa4006c */ lw $a0,0x6c($sp) /* f088cd8: 0fc2a63d */ jal bgunGetCapacityByAmmotype @@ -61973,7 +61973,7 @@ glabel var7f1aae70 /* f088d34: 0fc22095 */ jal weaponGetPickupAmmoQty /* f088d38: 01802025 */ or $a0,$t4,$zero /* f088d3c: afa20050 */ sw $v0,0x50($sp) -/* f088d40: 0fc2a5dc */ jal bgunGetAmmoCountWithCheck +/* f088d40: 0fc2a5dc */ jal bgunGetReservedAmmoCount /* f088d44: 2404000b */ addiu $a0,$zero,0xb /* f088d48: 2404000b */ addiu $a0,$zero,0xb /* f088d4c: 0fc2a63d */ jal bgunGetCapacityByAmmotype @@ -61982,7 +61982,7 @@ glabel var7f1aae70 /* f088d58: 00c2082a */ slt $at,$a2,$v0 /* f088d5c: 5020000f */ beqzl $at,.L0f088d9c /* f088d60: 8fb80074 */ lw $t8,0x74($sp) -/* f088d64: 0fc2a5dc */ jal bgunGetAmmoCountWithCheck +/* f088d64: 0fc2a5dc */ jal bgunGetReservedAmmoCount /* f088d68: 2404000b */ addiu $a0,$zero,0xb /* f088d6c: 2404000b */ addiu $a0,$zero,0xb /* f088d70: 0fc2a58a */ jal bgunSetAmmoQuantity @@ -62347,9 +62347,9 @@ glabel var7f1aae70 // s32 pickupqty = weaponGetPickupAmmoQty(weapon); // // if (pickupqty > 0) { -// s32 heldqty = bgunGetAmmoCountWithCheck(ammotype); +// s32 heldqty = bgunGetReservedAmmoCount(ammotype); // -// if (bgunGetAmmoCountWithCheck(ammotype) < bgunGetCapacityByAmmotype(ammotype)) { +// if (bgunGetReservedAmmoCount(ammotype) < bgunGetCapacityByAmmotype(ammotype)) { // bgunSetAmmoQuantity(ammotype, heldqty + pickupqty); // // if (sp112 == false && showhudmsg) { @@ -62363,8 +62363,8 @@ glabel var7f1aae70 // if (weapon->weaponnum == WEAPON_SUPERDRAGON) { // s32 pickupqty = weaponGetPickupAmmoQty(weapon); // -// if (bgunGetAmmoCountWithCheck(AMMOTYPE_DEVASTATOR) < bgunGetCapacityByAmmotype(AMMOTYPE_DEVASTATOR)) { -// s32 heldqty = bgunGetAmmoCountWithCheck(AMMOTYPE_DEVASTATOR); +// if (bgunGetReservedAmmoCount(AMMOTYPE_DEVASTATOR) < bgunGetCapacityByAmmotype(AMMOTYPE_DEVASTATOR)) { +// s32 heldqty = bgunGetReservedAmmoCount(AMMOTYPE_DEVASTATOR); // // bgunSetAmmoQuantity(AMMOTYPE_DEVASTATOR, heldqty + 5); // @@ -62612,7 +62612,7 @@ s32 objTestForPickup(struct prop *prop) } else if (obj->type == OBJTYPE_AMMOCRATE) { struct ammocrateobj *crate = (struct ammocrateobj *) prop->obj; - if (bgunGetAmmoCountWithCheck(crate->ammotype) >= bgunGetCapacityByAmmotype(crate->ammotype)) { + if (bgunGetReservedAmmoCount(crate->ammotype) >= bgunGetCapacityByAmmotype(crate->ammotype)) { if ((crate->ammotype != AMMOTYPE_GRENADE || invHasSingleWeaponExcAllGuns(WEAPON_GRENADE)) && (crate->ammotype != AMMOTYPE_CLOAK || invHasSingleWeaponExcAllGuns(WEAPON_CLOAKINGDEVICE)) && (crate->ammotype != AMMOTYPE_BOOST || invHasSingleWeaponExcAllGuns(WEAPON_COMBATBOOST)) @@ -62637,7 +62637,7 @@ s32 objTestForPickup(struct prop *prop) s32 ammotype = i + 1; if (crate->slots[i].quantity > 0) { - if (bgunGetAmmoCountWithCheck(ammotype) < bgunGetCapacityByAmmotype(ammotype)) { + if (bgunGetReservedAmmoCount(ammotype) < bgunGetCapacityByAmmotype(ammotype)) { ignore = false; break; } diff --git a/src/game/training/training.c b/src/game/training/training.c index 49041ed4f..564f64610 100644 --- a/src/game/training/training.c +++ b/src/game/training/training.c @@ -2909,8 +2909,8 @@ bool frIsAmmoWasted(void) // Check if player has ammo ammoloaded[0] = hand0->loadedammo[0] + hand1->loadedammo[0]; ammoloaded[1] = hand0->loadedammo[1] + hand1->loadedammo[1]; - ammototal[0] = bgunGetAmmoCountWithCheck(priammotype) + ammoloaded[0]; - ammototal[1] = bgunGetAmmoCountWithCheck(secammotype) + ammoloaded[1]; + ammototal[0] = bgunGetReservedAmmoCount(priammotype) + ammoloaded[0]; + ammototal[1] = bgunGetReservedAmmoCount(secammotype) + ammoloaded[1]; if (ammototal[0] <= 0 && ammototal[1] <= 0) { // Don't do any further checks if this is the first frame where we've @@ -2987,7 +2987,7 @@ bool frIsAmmoWasted(void) ammotype = bgunGetAmmoTypeForWeapon(weaponnum, 0); hand = &g_Vars.currentplayer->hands[HAND_RIGHT]; - if (bgunGetAmmoCountWithCheck(ammotype) + hand->loadedammo[0] == 0) { + if (bgunGetReservedAmmoCount(ammotype) + hand->loadedammo[0] == 0) { g_FrData.proxyendtimer = PALDOWN(300); } @@ -3323,7 +3323,7 @@ glabel var7f1b94e4 /* f1a0e9c: 2401ffff */ li $at,-1 /* f1a0ea0: 18400011 */ blez $v0,.PF0f1a0ee8 /* f1a0ea4: 00000000 */ nop -/* f1a0ea8: 0fc2a6ef */ jal bgunGetAmmoCountWithCheck +/* f1a0ea8: 0fc2a6ef */ jal bgunGetReservedAmmoCount /* f1a0eac: 02202025 */ move $a0,$s1 /* f1a0eb0: 92a3045a */ lbu $v1,0x45a($s5) /* f1a0eb4: 86ae0476 */ lh $t6,0x476($s5) @@ -3357,7 +3357,7 @@ glabel var7f1b94e4 /* f1a0f14: 2401ffff */ li $at,-1 /* f1a0f18: 18600011 */ blez $v1,.PF0f1a0f60 /* f1a0f1c: 00000000 */ nop -/* f1a0f20: 0fc2a6ef */ jal bgunGetAmmoCountWithCheck +/* f1a0f20: 0fc2a6ef */ jal bgunGetReservedAmmoCount /* f1a0f24: 2404000b */ li $a0,0xb /* f1a0f28: 92a3045a */ lbu $v1,0x45a($s5) /* f1a0f2c: 86b90478 */ lh $t9,0x478($s5) @@ -4423,7 +4423,7 @@ glabel var7f1b94e4 /* f19fd88: 2401ffff */ addiu $at,$zero,-1 /* f19fd8c: 18400011 */ blez $v0,.L0f19fdd4 /* f19fd90: 00000000 */ nop -/* f19fd94: 0fc2a5dc */ jal bgunGetAmmoCountWithCheck +/* f19fd94: 0fc2a5dc */ jal bgunGetReservedAmmoCount /* f19fd98: 02202025 */ or $a0,$s1,$zero /* f19fd9c: 92a3045a */ lbu $v1,0x45a($s5) /* f19fda0: 86ae0476 */ lh $t6,0x476($s5) @@ -4457,7 +4457,7 @@ glabel var7f1b94e4 /* f19fe00: 2401ffff */ addiu $at,$zero,-1 /* f19fe04: 18600011 */ blez $v1,.L0f19fe4c /* f19fe08: 00000000 */ nop -/* f19fe0c: 0fc2a5dc */ jal bgunGetAmmoCountWithCheck +/* f19fe0c: 0fc2a5dc */ jal bgunGetReservedAmmoCount /* f19fe10: 2404000b */ addiu $a0,$zero,0xb /* f19fe14: 92a3045a */ lbu $v1,0x45a($s5) /* f19fe18: 86b90478 */ lh $t9,0x478($s5) @@ -5536,7 +5536,7 @@ glabel var7f1b94e4 /* f199d90: 2401ffff */ addiu $at,$zero,-1 /* f199d94: 18400011 */ blez $v0,.NB0f199ddc /* f199d98: 00000000 */ sll $zero,$zero,0x0 -/* f199d9c: 0fc29d44 */ jal bgunGetAmmoCountWithCheck +/* f199d9c: 0fc29d44 */ jal bgunGetReservedAmmoCount /* f199da0: 02202025 */ or $a0,$s1,$zero /* f199da4: 92a3045a */ lbu $v1,0x45a($s5) /* f199da8: 86af0476 */ lh $t7,0x476($s5) @@ -5570,7 +5570,7 @@ glabel var7f1b94e4 /* f199e08: 2401ffff */ addiu $at,$zero,-1 /* f199e0c: 18600011 */ blez $v1,.NB0f199e54 /* f199e10: 00000000 */ sll $zero,$zero,0x0 -/* f199e14: 0fc29d44 */ jal bgunGetAmmoCountWithCheck +/* f199e14: 0fc29d44 */ jal bgunGetReservedAmmoCount /* f199e18: 2404000b */ addiu $a0,$zero,0xb /* f199e1c: 92a3045a */ lbu $v1,0x45a($s5) /* f199e20: 86a90478 */ lh $t1,0x478($s5) @@ -6492,7 +6492,7 @@ glabel var7f1b94e4 // // // d8c // if (g_FrData.ammoextra > 0) { -// tmp = bgunGetAmmoCountWithCheck(ammotype); +// tmp = bgunGetReservedAmmoCount(ammotype); // g_FrData.ammoextra -= g_FrData.numshotssincetopup; // // if (g_FrData.ammoextra < 0) { @@ -6511,7 +6511,7 @@ glabel var7f1b94e4 // // // e04 // if (g_FrData.sdgrenadeextra > 0) { -// tmp = bgunGetAmmoCountWithCheck(AMMOTYPE_DEVASTATOR); +// tmp = bgunGetReservedAmmoCount(AMMOTYPE_DEVASTATOR); // g_FrData.sdgrenadeextra -= g_FrData.numshotssincetopup; // // if (g_FrData.sdgrenadeextra < 0) { diff --git a/src/include/constants.h b/src/include/constants.h index 2310f1ec3..9a9c41fc6 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -157,6 +157,11 @@ #define AIMCONTROL_HOLD 0 #define AIMCONTROL_TOGGLE 1 +#define AMMOFLAG_NORESERVE 1 // Ammo cannot be held outside of weapon (cloak and combat boost) +#define AMMOFLAG_EQUIPPEDISRESERVE 2 // For throwables: equipped ammo and reserve is kind of the same thing +#define AMMOFLAG_INCREMENTALRELOAD 4 // Shotgun and crossbow +#define AMMOFLAG_QTYAFFECTSPARTVIS 8 // Quantity of ammo in the clip affects model part visibility on the weapon (Devastator) + #define AMMOTYPE_PISTOL 0x01 #define AMMOTYPE_SMG 0x02 #define AMMOTYPE_CROSSBOW 0x03 diff --git a/src/include/game/bondgun.h b/src/include/game/bondgun.h index d207617a9..ce290bd04 100644 --- a/src/include/game/bondgun.h +++ b/src/include/game/bondgun.h @@ -8,7 +8,7 @@ void bgun0f097ba0(s32 handnum, s32 weaponnum); s32 bgunGetUnequippedReloadIndex(s32 weaponnum); void bgunTickUnequippedReload(void); bool bgun0f097df0(struct inventory_typef *arg0, struct hand *hand); -void bgun0f097e74(s16 partnum, s32 arg1, struct hand *hand, struct modelfiledata *arg3); +void bgunSetPartVisible(s16 partnum, bool visible, struct hand *hand, struct modelfiledata *filedata); void bgun0f097f28(struct hand *hand, struct modelfiledata *arg1, struct inventory_typef *arg2); void bgun0f098030(struct hand *hand, struct modelfiledata *arg1); f32 bgun0f09815c(struct hand *hand); @@ -153,7 +153,7 @@ void bgun0f0a9494(u32 operation); void bgun0f0a94d0(u32 operation, struct coord *pos, struct coord *rot); void bgunSetGunAmmoVisible(u32 reason, bool enable); void bgunSetAmmoQuantity(s32 ammotype, s32 quantity); -s32 bgunGetAmmoCountWithCheck(s32 type); +s32 bgunGetReservedAmmoCount(s32 type); s32 bgunGetAmmoCount(s32 ammotype); s32 bgunGetCapacityByAmmotype(u32 ammotype); bool bgunAmmotypeAllowsUnlimitedAmmo(u32 ammotype); diff --git a/src/include/game/game_0b0fd0.h b/src/include/game/game_0b0fd0.h index 063147cc6..90e6c9fab 100644 --- a/src/include/game/game_0b0fd0.h +++ b/src/include/game/game_0b0fd0.h @@ -19,7 +19,7 @@ void currentPlayerZoomOut(f32 fovpersec); void currentPlayerZoomIn(f32 fovpersec); bool weaponHasFlag(s32 itemid, u32 flag); bool weaponHasClassFlag(s32 weaponnum, u32 flag); -bool func0f0b184c(s32 weaponnum, s32 funcnum, s32 arg2); +bool weaponHasAmmoFlag(s32 weaponnum, s32 funcnum, u32 flag); s32 currentPlayerGetDeviceState(s32 weaponnum); void currentPlayerSetDeviceActive(s32 weaponum, bool active); u16 weaponGetModelNum(s32 weaponnum);