From 94544a4d88dcc5139230207c36ae5b3926a64c9b Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sun, 14 Feb 2021 11:20:33 +1000 Subject: [PATCH] Introduce shorthand struct --- src/game/activemenu/activemenu.c | 6 ++--- src/game/activemenu/tick.c | 4 +-- src/game/chr/chr.c | 8 +++--- src/game/chr/chraction.c | 16 ++++++------ src/game/chr/chraicommands.c | 12 ++++----- src/game/core.c | 2 +- src/game/game_097ba0.c | 14 +++++------ src/game/game_0b0fd0.c | 42 ++++++++++++++++---------------- src/game/game_190260.c | 2 +- src/game/game_1999b0.c | 6 ++--- src/game/mpstats.c | 4 +-- src/game/prop.c | 12 ++++----- src/game/sight.c | 8 +++--- src/include/game/chr/chraction.h | 10 ++++---- src/include/game/game_097ba0.h | 6 ++--- src/include/game/game_0b0fd0.h | 26 ++++++++++---------- src/include/game/mpstats.h | 4 +-- src/include/game/prop.h | 2 +- src/include/types.h | 17 +++++++------ 19 files changed, 101 insertions(+), 100 deletions(-) diff --git a/src/game/activemenu/activemenu.c b/src/game/activemenu/activemenu.c index db1d87424..a1088dde5 100644 --- a/src/game/activemenu/activemenu.c +++ b/src/game/activemenu/activemenu.c @@ -641,7 +641,7 @@ void amApply(s32 slot) if (g_FrIsValidWeapon) { s32 weaponnum = frGetWeaponBySlot(frGetSlot()); - if (g_Vars.currentplayer->hands[HAND_RIGHT].weaponnum == weaponnum) { + if (g_Vars.currentplayer->hands[HAND_RIGHT].base.weaponnum == weaponnum) { pass = false; } } @@ -762,8 +762,8 @@ void amGetSlotDetails(s32 slot, u32 *flags, char *label) if (slot == 4) { strcpy(label, langGet(L_MISC(171))); // "Function" } else if (slot == 1 || slot == 7) { - prifunc = weaponGetFunction(&g_Vars.currentplayer->hands[HAND_RIGHT].weaponnum, FUNC_PRIMARY); - secfunc = weaponGetFunction(&g_Vars.currentplayer->hands[HAND_RIGHT].weaponnum, FUNC_SECONDARY); + prifunc = weaponGetFunction(&g_Vars.currentplayer->hands[HAND_RIGHT].base.weaponnum, FUNC_PRIMARY); + secfunc = weaponGetFunction(&g_Vars.currentplayer->hands[HAND_RIGHT].base.weaponnum, FUNC_SECONDARY); if (slot == 1) { if (!secfunc diff --git a/src/game/activemenu/tick.c b/src/game/activemenu/tick.c index 179bddd81..677ee9b15 100644 --- a/src/game/activemenu/tick.c +++ b/src/game/activemenu/tick.c @@ -290,8 +290,8 @@ void amTick(void) // If weapon has no functions, skip past function screen if (g_AmMenus[g_AmIndex].screenindex == 1) { - struct weaponfunc *pri = weaponGetFunction(&g_Vars.currentplayer->hands[0].weaponnum, FUNC_PRIMARY); - struct weaponfunc *sec = weaponGetFunction(&g_Vars.currentplayer->hands[0].weaponnum, FUNC_SECONDARY); + struct weaponfunc *pri = weaponGetFunction(&g_Vars.currentplayer->hands[0].base.weaponnum, FUNC_PRIMARY); + struct weaponfunc *sec = weaponGetFunction(&g_Vars.currentplayer->hands[0].base.weaponnum, FUNC_SECONDARY); if (!pri && !sec) { amChangeScreen(gotonextscreen); diff --git a/src/game/chr/chr.c b/src/game/chr/chr.c index e4134003c..9f7788abb 100644 --- a/src/game/chr/chr.c +++ b/src/game/chr/chr.c @@ -4176,8 +4176,8 @@ void chrTickPoisoned(struct chrdata *chr) if (chr->poisoncounter > 0) { struct coord coord = {0, 0, 0}; - u8 thing[] = { - 0x1a, 0x00, 0x00, 0x03, + struct shorthand hand = { + WEAPON_COMBATKNIFE, 0, 0, 3, }; if (chr->actiontype == ACT_DEAD || chr->actiontype == ACT_DIE) { @@ -4211,7 +4211,7 @@ void chrTickPoisoned(struct chrdata *chr) if (chr->poisoncounter <= 0) { if (!g_Vars.normmplayerisrunning) { - chrPoison(chr, 100, &coord, thing, chr->poisonprop); + chrPoison(chr, 100, &coord, &hand, chr->poisonprop); chrDoFlinchcntThing(chr, M_PI); } @@ -4222,7 +4222,7 @@ void chrTickPoisoned(struct chrdata *chr) if (g_Vars.normmplayerisrunning) { if (chr->poisoncounter / 720 != (chr->poisoncounter + g_Vars.lvupdate240) / 720) { - chrPoison(chr, 1.3f, &coord, thing, chr->poisonprop); + chrPoison(chr, 1.3f, &coord, &hand, chr->poisonprop); } } } diff --git a/src/game/chr/chraction.c b/src/game/chr/chraction.c index 38f1003a2..5984ad952 100644 --- a/src/game/chr/chraction.c +++ b/src/game/chr/chraction.c @@ -5476,19 +5476,19 @@ glabel func0f034080 /* f034120: 00000000 */ nop ); -void chrPoison(struct chrdata *chr, f32 damage, struct coord *vector, u8 *arg3, struct prop *prop) +void chrPoison(struct chrdata *chr, f32 damage, struct coord *vector, struct shorthand *hand, struct prop *prop) { - func0f034524(chr, damage, vector, arg3, prop, 200, 0, 0, 0, 0, -1, 0, 0, 0); + func0f034524(chr, damage, vector, hand, prop, 200, 0, 0, 0, 0, -1, 0, 0, 0); } -void func0f03417c(struct chrdata *chr, f32 damage, struct coord *vector, u8 *arg3, struct prop *prop) +void func0f03417c(struct chrdata *chr, f32 damage, struct coord *vector, struct shorthand *hand, struct prop *prop) { - func0f034524(chr, damage, vector, arg3, prop, 200, 1, chr->prop, 0, 0, -1, 0, 0, 0); + func0f034524(chr, damage, vector, hand, prop, 200, 1, chr->prop, 0, 0, -1, 0, 0, 0); } -void func0f0341dc(struct chrdata *chr, f32 damage, struct coord *vector, struct hand *hand, struct prop *prop, u32 arg5, struct prop *prop2, s32 arg7, s32 arg8, s32 arg9, u32 arg10) +void func0f0341dc(struct chrdata *chr, f32 damage, struct coord *vector, struct shorthand *hand, struct prop *prop, u32 arg5, struct prop *prop2, s32 arg7, s32 arg8, s32 arg9, u32 arg10) { - func0f034524(chr, damage, vector, (u8 *)hand, prop, arg5, 1, prop2, arg7, arg8, arg9, arg10, 0, 0); + func0f034524(chr, damage, vector, hand, prop, arg5, 1, prop2, arg7, arg8, arg9, arg10, 0, 0); } GLOBAL_ASM( @@ -5555,7 +5555,7 @@ glabel func0f034248 /* f03432c: 00000000 */ nop ); -void func0f034330(struct chrdata *chr, f32 damage, struct coord *vector, u8 *arg3, struct prop *prop, s32 arg5) +void func0f034330(struct chrdata *chr, f32 damage, struct coord *vector, struct shorthand *hand, struct prop *prop, s32 arg5) { s32 sp76 = 0; s32 sp72 = 0; @@ -5565,7 +5565,7 @@ void func0f034330(struct chrdata *chr, f32 damage, struct coord *vector, u8 *arg func0f03ff2c(chr, &chr->prop->pos, vector, &sp76, &arg5, &sp72, &sp68); } - func0f034524(chr, damage, vector, arg3, prop, arg5, 1, chr->prop, sp76, sp72, sp68, 0, 0, 0); + func0f034524(chr, damage, vector, hand, prop, arg5, 1, chr->prop, sp76, sp72, sp68, 0, 0, 0); } GLOBAL_ASM( diff --git a/src/game/chr/chraicommands.c b/src/game/chr/chraicommands.c index ef1013f55..f3dcff6a2 100644 --- a/src/game/chr/chraicommands.c +++ b/src/game/chr/chraicommands.c @@ -813,8 +813,8 @@ bool ai0019(void) struct coord pos = {0, 0, 0}; if (chr && chr->prop) { - f32 damage = handGetDamage((struct hand *)&cmd[4]); - func0f034330(chr, damage, &pos, &cmd[4], NULL, (s8)cmd[3]); + f32 damage = handGetDamage((struct shorthand *)&cmd[4]); + func0f034330(chr, damage, &pos, (struct shorthand *)&cmd[4], NULL, (s8)cmd[3]); } g_Vars.aioffset += 8; @@ -847,8 +847,8 @@ bool ai001a(void) vector.z = chr2->prop->pos.z - chr1->prop->pos.z; guNormalize(&vector.x, &vector.y, &vector.z); weapon = prop->weapon; - damage = handGetDamage((struct hand *)&weapon->weaponnum); - func0f034330(chr2, damage, &vector, &weapon->weaponnum, chr1->prop, (s8)cmd[4]); + damage = handGetDamage((struct shorthand *)&weapon->weaponnum); + func0f034330(chr2, damage, &vector, (struct shorthand *)&weapon->weaponnum, chr1->prop, (s8)cmd[4]); } } @@ -9061,8 +9061,8 @@ bool aiPoisonChr(void) if (chr && chr->prop) { if (cmd[4] == 2) { - u8 sp40[] = {WEAPON_COMBATKNIFE, 0, 0, 3}; - chrPoison(chr, (s32)cmd[3] * 0.03125f, &coord, sp40, NULL); + struct shorthand hand = {WEAPON_COMBATKNIFE, 0, 0, 3}; + chrPoison(chr, (s32)cmd[3] * 0.03125f, &coord, &hand, NULL); } else if (cmd[4] == 0) { chrPoison(chr, (s32)cmd[3] * 0.03125f, &coord, NULL, NULL); } else { diff --git a/src/game/core.c b/src/game/core.c index cacbcb07c..594569d3b 100644 --- a/src/game/core.c +++ b/src/game/core.c @@ -1140,7 +1140,7 @@ Gfx *coreRender(Gfx *gdl) g_Vars.currentplayer->lookingatprop.prop = NULL; } - if (handHasFunctionFlags(g_Vars.currentplayer->hands, FUNCFLAG_00080000)) { + if (handHasFunctionFlags(&g_Vars.currentplayer->hands[0].base, FUNCFLAG_00080000)) { coreFindThreats(); } else if (weaponHasFlag(handGetWeaponNum(HAND_RIGHT), WEAPONFLAG_AIMTRACK)) { s32 j; diff --git a/src/game/game_097ba0.c b/src/game/game_097ba0.c index a9b9e9c4e..8ae07536f 100644 --- a/src/game/game_097ba0.c +++ b/src/game/game_097ba0.c @@ -1234,7 +1234,7 @@ glabel var7f1ac1b0 /* f098880: 27bd0158 */ addiu $sp,$sp,0x158 ); -bool func0f098884(struct remoteminething *arg0, struct hand *hand) +bool func0f098884(struct remoteminething *arg0, struct shorthand *hand) { s32 result = false; @@ -1261,7 +1261,7 @@ void func0f0988e0(struct remoteminething *arg0, bool arg1, struct hand *hand) u32 rand = random() % 100; while (loopthing->unk00) { - if (func0f098884(loopthing, hand) && !done) { + if (func0f098884(loopthing, &hand->base) && !done) { if (loopthing->unk00 == 6) { done = true; func0f0988e0(loopthing->next, arg1, hand); @@ -13188,7 +13188,7 @@ bool weaponIsMissionCritical(s32 weaponnum) void currentPlayerLoseGunInNbombStorm(struct prop *prop) { struct player *player = g_Vars.currentplayer; - s32 weaponnum = player->hands[0].weaponnum; + s32 weaponnum = player->hands[0].base.weaponnum; struct chrdata *chr; s32 modelnum; s32 i; @@ -13224,13 +13224,13 @@ void currentPlayerLoseGunInNbombStorm(struct prop *prop) // Or drop it at player's feet with the pin pulled maybe... if (weaponnum == WEAPON_GRENADE || weaponnum == WEAPON_NBOMB) { for (i = 0; i < 2; i++) { - struct weaponfunc *func = handGetWeaponFunction(&player->hands[i]); + struct weaponfunc *func = handGetWeaponFunction(&player->hands[i].base); if ((func->type & 0xff) == INVENTORYFUNCTYPE_THROW && player->hands[i].unk0c3c == 4 && player->hands[i].unk0c40 == 0) { drop = false; - handCreateThrownProjectile(i + 2, &player->hands[i]); + handCreateThrownProjectile(i + 2, &player->hands[i].base); } } } @@ -13571,7 +13571,7 @@ void playerDetonateRemoteMines(s32 playernum) s32 prevplayernum = g_Vars.currentplayernum; setCurrentPlayerNum(playernum); - if (g_Vars.currentplayer->hands[HAND_LEFT].weaponnum == WEAPON_REMOTEMINE) { + if (g_Vars.currentplayer->hands[HAND_LEFT].base.weaponnum == WEAPON_REMOTEMINE) { func0f0988e0(var80070200, 1, &g_Vars.currentplayer->hands[HAND_LEFT]); } @@ -20631,7 +20631,7 @@ void currentPlayerTickInventory(bool triggeron) struct hand *lhand = &g_Vars.currentplayer->hands[HAND_LEFT]; struct hand *rhand = &g_Vars.currentplayer->hands[HAND_RIGHT]; - weapon = weaponFindById(rhand->weaponnum); + weapon = weaponFindById(rhand->base.weaponnum); for (i = 0; i != 2; i++) { if (weapon && weapon->ammos[i] && diff --git a/src/game/game_0b0fd0.c b/src/game/game_0b0fd0.c index 918e3e79a..6796f665f 100644 --- a/src/game/game_0b0fd0.c +++ b/src/game/game_0b0fd0.c @@ -46,7 +46,7 @@ struct weaponfunc *weaponGetFunctionById(u32 weaponnum, u32 which) return NULL; } -struct weaponfunc *handGetWeaponFunction2(struct hand *hand) +struct weaponfunc *handGetWeaponFunction2(struct shorthand *hand) { struct weapon *weapon = weaponFindById(hand->weaponnum); @@ -57,7 +57,7 @@ struct weaponfunc *handGetWeaponFunction2(struct hand *hand) return NULL; } -struct weaponfunc *handGetWeaponFunction(struct hand *hand) +struct weaponfunc *handGetWeaponFunction(struct shorthand *hand) { struct weapon *weapon = g_Weapons[hand->weaponnum]; @@ -81,10 +81,10 @@ struct weaponfunc *weaponGetFunction(u8 *arg0, s32 which) struct weaponfunc *currentPlayerGetWeaponFunction(u32 hand) { - struct weapon *weapon = weaponFindById(g_Vars.currentplayer->hands[hand].weaponnum); + struct weapon *weapon = weaponFindById(g_Vars.currentplayer->hands[hand].base.weaponnum); if (weapon) { - return weapon->functions[g_Vars.currentplayer->hands[hand].weaponfunc]; + return weapon->functions[g_Vars.currentplayer->hands[hand].base.weaponfunc]; } return NULL; @@ -108,7 +108,7 @@ u32 weaponGetNumFunctions(u32 weaponnum) return 2; } -struct inventory_typee *func0f0b11bc(struct hand *hand) +struct inventory_typee *func0f0b11bc(struct shorthand *hand) { struct weapon *weapon = weaponFindById(hand->weaponnum); @@ -494,7 +494,7 @@ glabel handPopulateFromCurrentPlayer ); // Mismatch: regalloc -//void handPopulateFromCurrentPlayer(s32 handnum, struct hand *hand) +//void handPopulateFromCurrentPlayer(s32 handnum, struct shorthand *hand) //{ // hand->weaponnum = g_Vars.currentplayer->weaponnum; // hand->weaponfunc = g_Vars.currentplayer->hands[handnum].weaponfunc; @@ -510,7 +510,7 @@ glabel handPopulateFromCurrentPlayer // } //} -struct inventory_ammo *handGetAmmoDefinition(struct hand *hand) +struct inventory_ammo *handGetAmmoDefinition(struct shorthand *hand) { struct weaponfunc *func = handGetWeaponFunction(hand); struct weapon *weapon = weaponFindById(hand->weaponnum); @@ -522,7 +522,7 @@ struct inventory_ammo *handGetAmmoDefinition(struct hand *hand) return NULL; } -u8 handGetSingleUnk3c(struct hand *hand) +u8 handGetSingleUnk3c(struct shorthand *hand) { struct weaponfunc *func = handGetWeaponFunction(hand); @@ -534,7 +534,7 @@ u8 handGetSingleUnk3c(struct hand *hand) return 0; } -u32 handGetCasingEject(struct hand *hand) +u32 handGetCasingEject(struct shorthand *hand) { u32 result = 0; struct inventory_ammo *ammo = handGetAmmoDefinition(hand); @@ -546,7 +546,7 @@ u32 handGetCasingEject(struct hand *hand) return result; } -f32 handGetSingleUnk34(struct hand *hand) +f32 handGetSingleUnk34(struct shorthand *hand) { struct weaponfunc *func = handGetWeaponFunction(hand); f32 result = 0; @@ -559,7 +559,7 @@ f32 handGetSingleUnk34(struct hand *hand) return result; } -f32 handGetDamage(struct hand *hand) +f32 handGetDamage(struct shorthand *hand) { struct weaponfunc *func = handGetWeaponFunction(hand); f32 damage = 0; @@ -596,7 +596,7 @@ f32 handGetDamage(struct hand *hand) return damage; } -u8 handGetSingleUnk38(struct hand *hand) +u8 handGetSingleUnk38(struct shorthand *hand) { struct weaponfunc *func = handGetWeaponFunction(hand); @@ -608,7 +608,7 @@ u8 handGetSingleUnk38(struct hand *hand) return 0; } -u16 handGetSingleShootSound(struct hand *hand) +u16 handGetSingleShootSound(struct shorthand *hand) { struct weaponfunc *func = handGetWeaponFunction(hand); @@ -620,7 +620,7 @@ u16 handGetSingleShootSound(struct hand *hand) return 0; } -bool handHasFunctionFlags(struct hand *hand, u32 flags) +bool handHasFunctionFlags(struct shorthand *hand, u32 flags) { struct weaponfunc *func = handGetWeaponFunction(hand); @@ -650,8 +650,8 @@ s8 weaponGetMaxFireRatePerTick(u32 weaponnum, u32 funcindex) u32 currentPlayerGetSight(void) { struct weaponfunc *func = weaponGetFunctionById( - g_Vars.currentplayer->hands[HAND_RIGHT].weaponnum, - g_Vars.currentplayer->hands[HAND_RIGHT].weaponfunc); + g_Vars.currentplayer->hands[HAND_RIGHT].base.weaponnum, + g_Vars.currentplayer->hands[HAND_RIGHT].base.weaponfunc); if (func && (func->type & 0xff) == INVENTORYFUNCTYPE_CLOSE) { return SIGHT_NONE; @@ -661,7 +661,7 @@ u32 currentPlayerGetSight(void) return SIGHT_CLASSIC; } - switch (g_Vars.currentplayer->hands[HAND_RIGHT].weaponnum) { + switch (g_Vars.currentplayer->hands[HAND_RIGHT].base.weaponnum) { case WEAPON_HORIZONSCANNER: return SIGHT_NONE; case WEAPON_NONE: @@ -751,7 +751,7 @@ glabel func0f0b201c /* f0b2084: 00000000 */ nop ); -u32 *handGetEquipAnim(struct hand *hand) +u32 *handGetEquipAnim(struct shorthand *hand) { struct weapon *weapon = g_Weapons[hand->weaponnum]; @@ -762,7 +762,7 @@ u32 *handGetEquipAnim(struct hand *hand) return NULL; } -u32 *handGetUnequipAnim(struct hand *hand) +u32 *handGetUnequipAnim(struct shorthand *hand) { struct weapon *weapon = g_Weapons[hand->weaponnum]; @@ -773,7 +773,7 @@ u32 *handGetUnequipAnim(struct hand *hand) return NULL; } -u32 *handGetPriToSecAnim(struct hand *hand) +u32 *handGetPriToSecAnim(struct shorthand *hand) { struct weapon *weapon = g_Weapons[hand->weaponnum]; @@ -784,7 +784,7 @@ u32 *handGetPriToSecAnim(struct hand *hand) return NULL; } -u32 *handGetSecToPriAnim(struct hand *hand) +u32 *handGetSecToPriAnim(struct shorthand *hand) { struct weapon *weapon = g_Weapons[hand->weaponnum]; diff --git a/src/game/game_190260.c b/src/game/game_190260.c index 5e0bcf400..f65fcba92 100644 --- a/src/game/game_190260.c +++ b/src/game/game_190260.c @@ -1337,7 +1337,7 @@ u32 func0f1915b4(struct chrdata *chr) return chr->aibot->weaponnum; } - return g_Vars.players[propGetPlayerNum(chr->prop)]->hands[HAND_RIGHT].weaponnum; + return g_Vars.players[propGetPlayerNum(chr->prop)]->hands[HAND_RIGHT].base.weaponnum; } u8 func0f191600(struct chrdata *chr) diff --git a/src/game/game_1999b0.c b/src/game/game_1999b0.c index 723e8a15a..935d05572 100644 --- a/src/game/game_1999b0.c +++ b/src/game/game_1999b0.c @@ -237,7 +237,7 @@ bool aibotDoFarsightThing(struct chrdata *chr, u32 arg1, struct coord *arg2, str s32 sp164 = -1; s32 sp160 = 200; u8 sp156[] = {WEAPON_FARSIGHTXR20, 0, 0, 0}; - f32 damage = handGetDamage((struct hand *)sp156); + f32 damage = handGetDamage((struct shorthand *)sp156); s32 fallback = 30; s32 value = fallback; @@ -265,14 +265,14 @@ bool aibotDoFarsightThing(struct chrdata *chr, u32 arg1, struct coord *arg2, str if (oppchr != chr && value > rand && func0f06b39c(arg3, arg2, &oppprop->pos, func0f0278a4(oppchr))) { - func0f0a7d98((struct hand *)sp156, oppprop, -1); + func0f0a7d98((struct shorthand *)sp156, oppprop, -1); if (oppchr->model && chrGetShield(oppchr) > 0) { func0f03ff2c(oppchr, &oppprop->pos, arg2, &sp172, &sp160, &sp168, &sp164); } chrEmitSparks(oppchr, oppprop, sp160, &oppprop->pos, arg2, chr); - func0f0341dc(oppchr, damage, arg2, (struct hand *)sp156, chr->prop, 200, oppprop, sp172, sp168, sp164, 0); + func0f0341dc(oppchr, damage, arg2, (struct shorthand *)sp156, chr->prop, 200, oppprop, sp172, sp168, sp164, 0); } } diff --git a/src/game/mpstats.c b/src/game/mpstats.c index c36423ced..d9fda80d5 100644 --- a/src/game/mpstats.c +++ b/src/game/mpstats.c @@ -22,14 +22,14 @@ #include "gvars/gvars.h" #include "types.h" -void mpstatsIncrementPlayerShotCount(struct hand *hand, s32 region) +void mpstatsIncrementPlayerShotCount(struct shorthand *hand, s32 region) { if (!weaponHasFlag(hand->weaponnum, WEAPONFLAG_00100000)) { g_Vars.currentplayerstats->shotcount[region]++; } } -void mpstatsIncrementPlayerShotCount2(struct hand *hand, s32 region) +void mpstatsIncrementPlayerShotCount2(struct shorthand *hand, s32 region) { if (region == 0) { if (!weaponHasFlag(hand->weaponnum, WEAPONFLAG_00100000)) { diff --git a/src/game/prop.c b/src/game/prop.c index 22933e1c3..043151ff8 100644 --- a/src/game/prop.c +++ b/src/game/prop.c @@ -2223,7 +2223,7 @@ glabel func0f061fa8 /* f06226c: 00000000 */ nop ); -void handInflictCloseRangeDamage(s32 handnum, struct hand *hand, bool arg2) +void handInflictCloseRangeDamage(s32 handnum, struct shorthand *hand, bool arg2) { s32 someval; struct prop **ptr; @@ -2406,7 +2406,7 @@ void handTickAttack(s32 handnum) g_Vars.currentplayer->hands[handnum].unk0d0f_03 = false; - handPopulateFromCurrentPlayer(handnum, (struct hand *)&tmpweaponnum); + handPopulateFromCurrentPlayer(handnum, (struct shorthand *)&tmpweaponnum); frIncrementNumShots(); switch (type) { @@ -2415,7 +2415,7 @@ void handTickAttack(s32 handnum) // right hand is not (ie. prevent firing both guns on the same tick) if (handnum == HAND_RIGHT || !handIsAttackingOnThisTick(HAND_RIGHT)) { chrUncloakTemporarily(g_Vars.currentplayer->prop->chr); - mpstatsIncrementPlayerShotCount2((struct hand *)&tmpweaponnum, 0); + mpstatsIncrementPlayerShotCount2((struct shorthand *)&tmpweaponnum, 0); if (weaponnum == WEAPON_SHOTGUN) { handCreateBulletRaycast(handnum, true, true, 1, true); @@ -2433,10 +2433,10 @@ void handTickAttack(s32 handnum) break; case HANDATTACKTYPE_CLOSERANGE: chrUncloakTemporarily(g_Vars.currentplayer->prop->chr); - handInflictCloseRangeDamage(handnum, (struct hand *)&tmpweaponnum, false); + handInflictCloseRangeDamage(handnum, (struct shorthand *)&tmpweaponnum, false); break; case HANDATTACKTYPE_CLOSERANGENOUNCLOAK: - handInflictCloseRangeDamage(handnum, (struct hand *)&tmpweaponnum, true); + handInflictCloseRangeDamage(handnum, (struct shorthand *)&tmpweaponnum, true); break; case HANDATTACKTYPE_DETONATE: playerActivateRemoteMineDetonator(g_Vars.currentplayernum); @@ -2461,7 +2461,7 @@ void handTickAttack(s32 handnum) } break; case HANDATTACKTYPE_THROWPROJECTILE: - handCreateThrownProjectile(handnum, (struct hand *)&tmpweaponnum); + handCreateThrownProjectile(handnum, (struct shorthand *)&tmpweaponnum); break; case HANDATTACKTYPE_RCP120CLOAK: cloaked = (g_Vars.currentplayer->devicesactive & DEVICE_CLOAKRCP120) != 0; diff --git a/src/game/sight.c b/src/game/sight.c index c162d9992..9e39d564e 100644 --- a/src/game/sight.c +++ b/src/game/sight.c @@ -174,9 +174,9 @@ void sightTick(bool sighton) u8 newtarget; s32 i; s32 index; - struct inventory_typee *thing = func0f0b11bc(&g_Vars.currentplayer->hands[0]); - struct weaponfunc *func = weaponGetFunctionById(g_Vars.currentplayer->hands[0].weaponnum, - g_Vars.currentplayer->hands[0].weaponfunc); + struct inventory_typee *thing = func0f0b11bc(&g_Vars.currentplayer->hands[0].base); + struct weaponfunc *func = weaponGetFunctionById(g_Vars.currentplayer->hands[0].base.weaponnum, + g_Vars.currentplayer->hands[0].base.weaponfunc); g_Vars.currentplayer->sighttimer240 += g_Vars.lvupdate240; @@ -198,7 +198,7 @@ void sightTick(bool sighton) newtarget = thing->unk18 >> 28; - if (handHasFunctionFlags(&g_Vars.currentplayer->hands[0], FUNCFLAG_00080000)) { + if (handHasFunctionFlags(&g_Vars.currentplayer->hands[0].base, FUNCFLAG_00080000)) { newtarget = 5; } diff --git a/src/include/game/chr/chraction.h b/src/include/game/chr/chraction.h index 4b726181c..1173e9088 100644 --- a/src/include/game/chr/chraction.h +++ b/src/include/game/chr/chraction.h @@ -48,13 +48,13 @@ u32 func0f033728(void); u32 func0f0338e0(void); void chrSetShield(struct chrdata *chr, f32 shield); u32 func0f034080(void); -void chrPoison(struct chrdata *chr, f32 damage, struct coord *vector, u8 *arg3, struct prop *prop); -void func0f03417c(struct chrdata *chr, f32 damage, struct coord *vector, u8 *arg3, struct prop *prop); -void func0f0341dc(struct chrdata *chr, f32 damage, struct coord *vector, struct hand *hand, struct prop *prop, u32 arg5, struct prop *prop2, s32 arg7, s32 arg8, s32 arg9, u32 arg10); -void func0f034330(struct chrdata *chr, f32 damage, struct coord *vector, u8 *arg3, struct prop *prop, s32 arg5); +void chrPoison(struct chrdata *chr, f32 damage, struct coord *vector, struct shorthand *hand, struct prop *prop); +void func0f03417c(struct chrdata *chr, f32 damage, struct coord *vector, struct shorthand *hand, struct prop *prop); +void func0f0341dc(struct chrdata *chr, f32 damage, struct coord *vector, struct shorthand *hand, struct prop *prop, u32 arg5, struct prop *prop2, s32 arg7, s32 arg8, s32 arg9, u32 arg10); +void func0f034330(struct chrdata *chr, f32 damage, struct coord *vector, struct shorthand *hand, struct prop *prop, s32 arg5); u32 func0f034410(void); u32 func0f034480(void); -void func0f034524(struct chrdata *chr, f32 damage, struct coord *vector, u8 *arg3, struct prop *prop, u32 arg5, u32 arg6, struct prop *prop2, u32 arg8, u32 arg9, u32 arg10, s32 arg11, u32 arg12, u32 arg13); +void func0f034524(struct chrdata *chr, f32 damage, struct coord *vector, struct shorthand *hand, struct prop *prop, u32 arg5, u32 arg6, struct prop *prop2, u32 arg8, u32 arg9, u32 arg10, s32 arg11, u32 arg12, u32 arg13); u32 func0f03645c(void); bool func0f03654c(struct chrdata *chr, struct coord *pos, s16 *rooms, struct coord *pos2, s16 *rooms2, struct coord *vector, f32 arg6, u32 types); bool propchrHasClearLineToPos(struct prop *prop, struct coord *dstpos, struct coord *vector); diff --git a/src/include/game/game_097ba0.h b/src/include/game/game_097ba0.h index c8d3ac875..3502118f1 100644 --- a/src/include/game/game_097ba0.h +++ b/src/include/game/game_097ba0.h @@ -12,7 +12,7 @@ u32 func0f097f28(void); u32 func0f098030(void); u32 func0f09815c(void); u32 func0f0981e8(void); -bool func0f098884(struct remoteminething *arg0, struct hand *hand); +bool func0f098884(struct remoteminething *arg0, struct shorthand *hand); void func0f0988e0(struct remoteminething *arg0, bool arg1, struct hand *hand); u32 func0f098a44(void); u32 func0f098bfc(void); @@ -71,7 +71,7 @@ u32 func0f09ebbc(void); void func0f09ebcc(struct defaultobj *obj, struct coord *coord, s16 *rooms, Mtxf *matrix1, f32 *arg4, Mtxf *matrix2, struct prop *prop, struct coord *pos); u32 func0f09ed2c(void); void func0f09ee18(struct chrdata *chr, u8 *arg1, struct coord *pos, s16 *rooms, Mtxf *arg4, struct coord *arg5); -void handCreateThrownProjectile(s32 handnum, struct hand *hand); +void handCreateThrownProjectile(s32 handnum, struct shorthand *hand); u32 func0f09f848(void); u32 func0f09f974(void); u32 func0f09fa20(void); @@ -136,7 +136,7 @@ u32 func0f0a6c30(void); u32 func0f0a70f8(void); void func0f0a7138(Gfx **gdl); u32 func0f0a7d5c(void); -void func0f0a7d98(struct hand *hand, struct prop *prop, s32 arg2); +void func0f0a7d98(struct shorthand *hand, struct prop *prop, s32 arg2); void func0f0a8404(struct coord *pos, s16 *rooms, s32 arg2); u32 func0f0a84c8(void); void handSetFiring(s32 hand, bool firing); diff --git a/src/include/game/game_0b0fd0.h b/src/include/game/game_0b0fd0.h index 7927499e6..5d456b163 100644 --- a/src/include/game/game_0b0fd0.h +++ b/src/include/game/game_0b0fd0.h @@ -5,11 +5,11 @@ struct weapon *weaponFindById(s32 itemid); struct weaponfunc *weaponGetFunctionById(u32 weaponnum, u32 which); -struct weaponfunc *handGetWeaponFunction2(struct hand *hand); -struct weaponfunc *handGetWeaponFunction(struct hand *hand); +struct weaponfunc *handGetWeaponFunction2(struct shorthand *hand); +struct weaponfunc *handGetWeaponFunction(struct shorthand *hand); struct weaponfunc *weaponGetFunction(u8 *arg0, s32 which); struct weaponfunc *currentPlayerGetWeaponFunction(u32 hand); -struct inventory_typee *func0f0b11bc(struct hand *hand); +struct inventory_typee *func0f0b11bc(struct shorthand *hand); struct inventory_ammo *weaponGetAmmoByFunction(u32 weaponnum, u32 funcnum); f32 handGetXOffset(u32 arg0); f32 func0f0b131c(u32 hand); @@ -23,18 +23,18 @@ s32 currentPlayerGetDeviceState(s32 weaponnum); void currentPlayerSetDeviceActive(s32 weaponum, bool active); u16 weaponGetModelNum(s32 weaponnum); u16 weaponGetModelNum2(s32 weaponnum); -void handPopulateFromCurrentPlayer(s32 handnum, struct hand *hand); -struct inventory_ammo *handGetAmmoDefinition(struct hand *hand); -u8 handGetSingleUnk3c(struct hand *hand); -f32 handGetSingleUnk34(struct hand *hand); -f32 handGetDamage(struct hand *hand); -u8 handGetSingleUnk38(struct hand *hand); -u16 handGetSingleShootSound(struct hand *hand); -bool handHasFunctionFlags(struct hand *hand, u32 flags); +void handPopulateFromCurrentPlayer(s32 handnum, struct shorthand *hand); +struct inventory_ammo *handGetAmmoDefinition(struct shorthand *hand); +u8 handGetSingleUnk3c(struct shorthand *hand); +f32 handGetSingleUnk34(struct shorthand *hand); +f32 handGetDamage(struct shorthand *hand); +u8 handGetSingleUnk38(struct shorthand *hand); +u16 handGetSingleShootSound(struct shorthand *hand); +bool handHasFunctionFlags(struct shorthand *hand, u32 flags); s8 weaponGetMaxFireRatePerTick(u32 weaponnum, u32 funcindex); u32 currentPlayerGetSight(void); u32 func0f0b201c(void); -u32 *handGetPriToSecAnim(struct hand *hand); -u32 *handGetSecToPriAnim(struct hand *hand); +u32 *handGetPriToSecAnim(struct shorthand *hand); +u32 *handGetSecToPriAnim(struct shorthand *hand); #endif diff --git a/src/include/game/mpstats.h b/src/include/game/mpstats.h index b6f7628db..ab7d6125f 100644 --- a/src/include/game/mpstats.h +++ b/src/include/game/mpstats.h @@ -3,8 +3,8 @@ #include #include "types.h" -void mpstatsIncrementPlayerShotCount(struct hand *hand, s32 region); -void mpstatsIncrementPlayerShotCount2(struct hand *hand, s32 region); +void mpstatsIncrementPlayerShotCount(struct shorthand *hand, s32 region); +void mpstatsIncrementPlayerShotCount2(struct shorthand *hand, s32 region); void mpstats0f0b0520(void); s32 mpstatsGetPlayerShotCountByRegion(u32 type); void mpstatsIncrementTotalKillCount(void); diff --git a/src/include/game/prop.h b/src/include/game/prop.h index 8bc6559ab..4133e4772 100644 --- a/src/include/game/prop.h +++ b/src/include/game/prop.h @@ -23,7 +23,7 @@ void func0f060db8(s32 handnum, bool arg1, struct coord *arg2, struct coord *arg3 struct prop *func0f061d54(s32 handnum, u32 arg1, u32 arg2); void handCreateBulletRaycast(s32 handnum, bool arg1, bool arg2, s32 arg3, bool arg4); u32 func0f061fa8(void); -void handInflictCloseRangeDamage(s32 handnum, struct hand *hand, bool arg2); +void handInflictCloseRangeDamage(s32 handnum, struct shorthand *hand, bool arg2); void handTickAttack(s32 handnum); void handsTickAttack(void); void func0f062b64(struct prop *prop, s32 arg1); diff --git a/src/include/types.h b/src/include/types.h index a14b6fd76..c47c2c8bf 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -1731,16 +1731,17 @@ struct bullettail { /*0x28*/ f32 dist; }; +// The first 4 bytes of the hand struct +struct shorthand { + u8 weaponnum; + u8 unk0639; + u8 unk063a; + u8 weaponfunc; // 0 or 1 +}; + // Weapon data per hand -// @TODO: The first 4 bytes are suspected to be a separate struct because there -// are places where 4 bytes are allocated on the stack then passed to functions -// which currently expect hand pointers. However this also means changing the -// weaponobj struct so it also uses this struct. struct hand { - /*0x0638*/ u8 weaponnum; - /*0x0639*/ u8 unk0639; - /*0x063a*/ u8 unk063a; - /*0x063b*/ u8 weaponfunc; // 0 or 1 + struct shorthand base; /*0x063c*/ s8 unk063c; /*0x063d*/ s8 torchon; /*0x063e*/ u8 unk063e;