From 36a5a7be6f0e1ef05ae720586d23d7ac6996dae3 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 30 Nov 2019 18:25:25 +1000 Subject: [PATCH] Decompile func0f04abdc --- src/game/chr/chraicommands.c | 34 +++++++++------------------- src/game/game_0b28d0.c | 2 +- src/include/game/chr/chr.h | 1 - src/include/game/chr/chraicommands.h | 2 ++ src/include/types.h | 8 ++++++- 5 files changed, 21 insertions(+), 26 deletions(-) diff --git a/src/game/chr/chraicommands.c b/src/game/chr/chraicommands.c index cbec20e75..0ff2ef4c0 100644 --- a/src/game/chr/chraicommands.c +++ b/src/game/chr/chraicommands.c @@ -3131,7 +3131,7 @@ bool aiIfGunUnclaimed(void) g_Vars.aioffset += 5; } } else { - struct weaponobj *weapon = g_Vars.chrdata->gungroundpos->entity; + struct weaponobj *weapon = g_Vars.chrdata->gungroundpos->weapon; if (weapon && weapon->pos) { weapon->flags |= 0x00400000; @@ -3331,7 +3331,7 @@ bool aiDestroyObject(void) struct defaultobj *obj = objFindByTagId(cmd[2]); if (obj && obj->pos && func0f0687b8(obj) == 0) { - struct defaultobj *entity = obj->pos->entity; + struct defaultobj *entity = obj->pos->obj; if (entity->obj == 0xeb) { obj->flags = (obj->flags & 0xfffeffff) | 0x20000; @@ -3460,7 +3460,7 @@ bool aiGiveObjectToChr(void) if (chr->pos->type == POSITIONTYPE_PLAYER) { u32 something; u32 prevplayernum = g_Vars.currentplayernum; - struct defaultobj *obj2 = obj->pos->entity; + struct defaultobj *obj2 = obj->pos->obj; u32 playernum = posGetPlayerNum(chr->pos); setCurrentPlayerNum(playernum); @@ -8503,7 +8503,7 @@ glabel ai0104 //bool ai0104(void) //{ // if (g_Vars.chrdata->proppreset1 >= 0) { -// struct defaultobj *obj = g_Vars.positions[g_Vars.chrdata->proppreset1].entity; +// struct defaultobj *obj = g_Vars.positions[g_Vars.chrdata->proppreset1].obj; // obj->hidden &= ~OBJHIDDENFLAG_00200000; // } // @@ -10381,24 +10381,12 @@ glabel ai0130 /* f05abd8: 00000000 */ sll $zero,$zero,0x0 ); -GLOBAL_ASM( -glabel func0f05abdc -/* f05abdc: 1080000b */ beqz $a0,.L0f05ac0c -/* f05abe0: 00000000 */ sll $zero,$zero,0x0 -/* f05abe4: 8c820004 */ lw $v0,0x4($a0) -/* f05abe8: 10400008 */ beqz $v0,.L0f05ac0c -/* f05abec: 00000000 */ sll $zero,$zero,0x0 -/* f05abf0: 8c4e0020 */ lw $t6,0x20($v0) -/* f05abf4: 11c00005 */ beqz $t6,.L0f05ac0c -/* f05abf8: 00000000 */ sll $zero,$zero,0x0 -/* f05abfc: 90430332 */ lbu $v1,0x332($v0) -/* f05ac00: 18600002 */ blez $v1,.L0f05ac0c -/* f05ac04: 246fffff */ addiu $t7,$v1,-1 -/* f05ac08: a04f0332 */ sb $t7,0x332($v0) -.L0f05ac0c: -/* f05ac0c: 03e00008 */ jr $ra -/* f05ac10: 00000000 */ sll $zero,$zero,0x0 -); +void func0f05abdc(struct position *pos) +{ + if (pos && pos->chr && pos->chr->unk020 && pos->chr->propsoundcount > 0) { + pos->chr->propsoundcount--; + } +} /** * @cmd 01a7 @@ -12155,7 +12143,7 @@ bool aiIfY(void) struct position *target = heliGetTargetPosition(heli); if (target && (target->type == POSITIONTYPE_CHR || target->type == POSITIONTYPE_PLAYER)) { - chr = target->entity; + chr = target->chr; } } } else { diff --git a/src/game/game_0b28d0.c b/src/game/game_0b28d0.c index 1b4d9a595..34837ae08 100644 --- a/src/game/game_0b28d0.c +++ b/src/game/game_0b28d0.c @@ -10220,7 +10220,7 @@ glabel func0f0bb42c void func0f0bb57c(float arg0, float arg1) { - struct chrdata *chr = g_Vars.currentplayer->targetpos->entity; + struct chrdata *chr = g_Vars.currentplayer->targetpos->chr; if (chr) { g_Vars.currentplayer->unk0188 = 0; diff --git a/src/include/game/chr/chr.h b/src/include/game/chr/chr.h index 93f2dc639..6ff79c401 100644 --- a/src/include/game/chr/chr.h +++ b/src/include/game/chr/chr.h @@ -411,7 +411,6 @@ u32 func0f04d000(struct chrdata *chr); u32 func0f04d44c(void); u32 func0f04d4bc(struct chrdata *chr); u32 func0f04e418(void); -u32 func0f05abdc(void); u32 getNumChrs(void); void incrementByte(u8 *dst, u8 amount); s32 padResolve(struct chrdata *chr, s32 pad_id); diff --git a/src/include/game/chr/chraicommands.h b/src/include/game/chr/chraicommands.h index 49262ab9b..e0408bd6b 100644 --- a/src/include/game/chr/chraicommands.h +++ b/src/include/game/chr/chraicommands.h @@ -445,4 +445,6 @@ /*0x01df*/ bool aiIfChrSameFloorDistanceToPadLessThan(void); /*0x01e0*/ bool ai01e0(void); +void func0f05abdc(struct position *pos); + #endif diff --git a/src/include/types.h b/src/include/types.h index a1f4480dc..8644edaac 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -38,7 +38,13 @@ struct position { u8 type; u8 flags; u16 unk02; - void *entity; + + union { + struct chrdata *chr; + struct defaultobj *obj; + struct weaponobj *weapon; + }; + struct coord coord; u32 unk14; u32 unk18; // related to gun recovery