From 524668e0f0487db1ac7b7411ecbd0bf19058a775 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Fri, 7 Feb 2020 18:31:22 +1000 Subject: [PATCH] Attempt to decompile func0f111ad4 --- src/game/chr/chr.c | 2 +- src/game/chr/chraicommands.c | 6 +++--- src/game/game_111600.c | 36 ++++++++++++++++++++++++++++++++++ src/include/game/game_111600.h | 2 +- src/include/types.h | 22 +-------------------- 5 files changed, 42 insertions(+), 26 deletions(-) diff --git a/src/game/chr/chr.c b/src/game/chr/chr.c index 5e4937ec8..05bd102a1 100644 --- a/src/game/chr/chr.c +++ b/src/game/chr/chr.c @@ -33168,7 +33168,7 @@ s32 chrConsiderGrenadeThrow(struct chrdata *chr, u32 entitytype, u32 entityid) if (prop) { weapon = prop->weapon; - weapon->hidden |= OBJHFLAG_00000800; + weapon->base.hidden |= OBJHFLAG_00000800; chrThrowGrenade(chr, rightprop == NULL ? 0 : 1, true); chr->act_throwgrenade.entitytype = entitytype; chr->act_throwgrenade.entityid = entityid; diff --git a/src/game/chr/chraicommands.c b/src/game/chr/chraicommands.c index d78da6429..99ce5b2bf 100644 --- a/src/game/chr/chraicommands.c +++ b/src/game/chr/chraicommands.c @@ -2965,8 +2965,8 @@ bool aiIfGunUnclaimed(void) } else { struct weaponobj *weapon = g_Vars.chrdata->gunprop->weapon; - if (weapon && weapon->prop) { - weapon->flags |= OBJFLAG_00400000; + if (weapon && weapon->base.prop) { + weapon->base.flags |= OBJFLAG_00400000; g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[4]); } else { g_Vars.aioffset += 5; @@ -11798,7 +11798,7 @@ bool aiDoGunCommand(void) u8 *cmd = g_Vars.ailist + g_Vars.aioffset; struct weaponobj *weapon = g_Vars.chrdata->gunprop->weapon; - if (cmd[2] == 0 || ((weapon->hidden & OBJHFLAG_00000080) == 0 && cmd[2] == 1)) { + if (cmd[2] == 0 || ((weapon->base.hidden & OBJHFLAG_00000080) == 0 && cmd[2] == 1)) { if (cmd[2] == 0) { chrGoToProp(g_Vars.chrdata, g_Vars.chrdata->gunprop, SPEED_JOG); } diff --git a/src/game/game_111600.c b/src/game/game_111600.c index e7f4d70f3..6c240434c 100644 --- a/src/game/game_111600.c +++ b/src/game/game_111600.c @@ -298,6 +298,42 @@ glabel func0f111ad4 /* f111b84: 00000000 */ sll $zero,$zero,0x0 ); +// regalloc +//bool func0f111ad4(s32 weaponnum) +//{ +// struct invitem *item = g_Vars.currentplayer->weapons; +// +// while (item) { +// if (item->type == INVITEMTYPE_1) { +// if (weaponnum == item->type1.weapon1) { +// return true; +// } +// } else if (item->type == INVITEMTYPE_PROP) { +// struct prop *prop = item->type_prop.prop; +// +// if (prop && prop->type == PROPTYPE_WEAPON) { +// struct defaultobj *obj = prop->obj; +// +// if (obj && obj->type == OBJTYPE_WEAPON) { +// struct weaponobj *weapon = (struct weaponobj *)obj; +// +// if (weapon->weapon_id == weaponnum) { +// return true; +// } +// } +// } +// } +// +// item = item->next; +// +// if (item == g_Vars.currentplayer->weapons) { +// break; +// } +// } +// +// return false; +//} + GLOBAL_ASM( glabel func0f111b88 /* f111b88: 27bdffe8 */ addiu $sp,$sp,-24 diff --git a/src/include/game/game_111600.h b/src/include/game/game_111600.h index d6176e0d8..05afe58c9 100644 --- a/src/include/game/game_111600.h +++ b/src/include/game/game_111600.h @@ -13,7 +13,7 @@ struct invitem *currentPlayerGetWeaponInvItem(s32 weaponnum); bool currentPlayerHasWeapon(s32 weaponnum); struct invitem *func0f111a4c(s32 weapon1, s32 weapon2); bool func0f111ab0(s32 weapon1, s32 weapon2); -u32 func0f111ad4(void); +bool func0f111ad4(s32 weaponnum); u32 func0f111b88(void); bool currentStageForbidsSlayer(void); bool currentPlayerCanHaveAllGunsWeapon(s32 weaponnum); diff --git a/src/include/types.h b/src/include/types.h index 35b37751c..ff78a70b4 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -757,27 +757,7 @@ struct image { }; struct weaponobj { // objtype 0x08 - /*0x00*/ u16 extrascale; - /*0x02*/ u8 hidden2; - /*0x03*/ u8 type; - /*0x04*/ u16 obj; - /*0x06*/ u16 pad; - /*0x08*/ u32 flags; - /*0x0c*/ u32 flags2; - /*0x10*/ u32 flags3; - /*0x14*/ struct prop *prop; - /*0x18*/ u32 unk18; - /*0x1c*/ f32 realrot[9]; - /*0x40*/ u32 hidden; - /*0x44*/ u32 unk44; - /*0x48*/ u32 unk48; - /*0x4c*/ s16 damage; - /*0x4e*/ u16 maxdamage; - /*0x50*/ u32 shadecol; - /*0x54*/ u32 nextcol; - /*0x58*/ u16 floorcol; - /*0x5a*/ u8 numtiles; - /*0x5b*/ u8 unk5b; + struct defaultobj base; /*0x5c*/ u8 weapon_id; /*0x5d*/ s8 unk5d; /*0x5e*/ s8 unk5e;