From e87ac32c049c5e90f0a5599203e29a5665da7521 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 26 Dec 2020 15:49:44 +1000 Subject: [PATCH] Rename obj48 to projectile --- src/game/bondbike.c | 10 +- src/game/bondgrab.c | 10 +- src/game/chr/chraicommands.c | 2 +- src/game/game_00c490.c | 56 ++++----- src/game/game_0b63b0.c | 32 +++--- src/game/game_17f930.c | 2 +- src/game/game_1999b0.c | 26 ++--- src/game/propobj.c | 200 ++++++++++++++++----------------- src/game/training.c | 2 +- src/gvars/gvars.c | 4 +- src/include/constants.h | 15 ++- src/include/game/game_1999b0.h | 2 +- src/include/game/propobj.h | 10 +- src/include/gvars/gvars.h | 4 +- src/include/types.h | 8 +- 15 files changed, 194 insertions(+), 189 deletions(-) diff --git a/src/game/bondbike.c b/src/game/bondbike.c index 61808bbd2..c1c3a10a0 100644 --- a/src/game/bondbike.c +++ b/src/game/bondbike.c @@ -72,11 +72,11 @@ void currentPlayerBikeInit(void) g_Vars.currentplayer->speedforwards = 0; g_Vars.currentplayer->speedsideways = 0; - if (hoverbike->base.hidden & OBJHFLAG_00000080) { - struct obj48 *obj48 = hoverbike->base.unk48; - hoverbike->speed[0] = obj48->unk004.x; - hoverbike->speed[1] = obj48->unk004.z; - hoverbike->w = obj48->unk0dc; + if (hoverbike->base.hidden & OBJHFLAG_AIRBORNE) { + struct projectile *projectile = hoverbike->base.projectile; + hoverbike->speed[0] = projectile->unk004.x; + hoverbike->speed[1] = projectile->unk004.z; + hoverbike->w = projectile->unk0dc; } func0f06ac90(g_Vars.currentplayer->hoverbike); diff --git a/src/game/bondgrab.c b/src/game/bondgrab.c index c87c97046..0258daa6b 100644 --- a/src/game/bondgrab.c +++ b/src/game/bondgrab.c @@ -78,11 +78,11 @@ void currentPlayerGrabInit(void) struct hov *hov = NULL; bool setthething; - if (obj->hidden & OBJHFLAG_00000080) { - struct obj48 *obj48 = obj->unk48; - g_Vars.currentplayer->bondshotspeed[0] += obj48->unk004.x * 0.2f; - g_Vars.currentplayer->bondshotspeed[2] += obj48->unk004.z * 0.2f; - func0f06ac40(obj); + if (obj->hidden & OBJHFLAG_AIRBORNE) { + struct projectile *projectile = obj->projectile; + g_Vars.currentplayer->bondshotspeed[0] += projectile->unk004.x * 0.2f; + g_Vars.currentplayer->bondshotspeed[2] += projectile->unk004.z * 0.2f; + objEndFlight(obj); } if (obj->type == OBJTYPE_HOVERPROP) { diff --git a/src/game/chr/chraicommands.c b/src/game/chr/chraicommands.c index 80d2c52c9..8226ba9da 100644 --- a/src/game/chr/chraicommands.c +++ b/src/game/chr/chraicommands.c @@ -9311,7 +9311,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->base.hidden & OBJHFLAG_00000080) == 0 && cmd[2] == 1)) { + if (cmd[2] == 0 || ((weapon->base.hidden & OBJHFLAG_AIRBORNE) == 0 && cmd[2] == 1)) { if (cmd[2] == 0) { chrGoToProp(g_Vars.chrdata, g_Vars.chrdata->gunprop, SPEED_JOG); } diff --git a/src/game/game_00c490.c b/src/game/game_00c490.c index f92372d36..38ee00e30 100644 --- a/src/game/game_00c490.c +++ b/src/game/game_00c490.c @@ -81,8 +81,8 @@ glabel func0f00c490 /* f00c504: 3c0a800a */ lui $t2,%hi(g_Menus+0x2000) /* f00c508: 14820005 */ bne $a0,$v0,.L0f00c520 /* f00c50c: 3c0f800a */ lui $t7,%hi(g_Vars+0x4b4) -/* f00c510: 3c0a800a */ lui $t2,%hi(var8009ce50) -/* f00c514: 254ace50 */ addiu $t2,$t2,%lo(var8009ce50) +/* f00c510: 3c0a800a */ lui $t2,%hi(g_NumProjectiles) +/* f00c514: 254ace50 */ addiu $t2,$t2,%lo(g_NumProjectiles) /* f00c518: 10000004 */ b .L0f00c52c /* f00c51c: ad430000 */ sw $v1,%lo(g_Menus+0x2000)($t2) .L0f00c520: @@ -158,10 +158,10 @@ glabel func0f00c490 /* f00c624: 3c07800a */ lui $a3,%hi(var8009ce44) /* f00c628: 3c08800a */ lui $t0,%hi(var8009ce48) /* f00c62c: 3c09800a */ lui $t1,%hi(var8009ce4c) -/* f00c630: 3c0a800a */ lui $t2,%hi(var8009ce50) +/* f00c630: 3c0a800a */ lui $t2,%hi(g_NumProjectiles) /* f00c634: 3c0b800a */ lui $t3,%hi(var8009ce54) /* f00c638: 256bce54 */ addiu $t3,$t3,%lo(var8009ce54) -/* f00c63c: 254ace50 */ addiu $t2,$t2,%lo(var8009ce50) +/* f00c63c: 254ace50 */ addiu $t2,$t2,%lo(g_NumProjectiles) /* f00c640: 2529ce4c */ addiu $t1,$t1,%lo(var8009ce4c) /* f00c644: 2508ce48 */ addiu $t0,$t0,%lo(var8009ce48) /* f00c648: 14600006 */ bnez $v1,.L0f00c664 @@ -190,10 +190,10 @@ glabel func0f00c490 /* f00c6a0: 3c07800a */ lui $a3,%hi(var8009ce44) /* f00c6a4: 3c08800a */ lui $t0,%hi(var8009ce48) /* f00c6a8: 3c09800a */ lui $t1,%hi(var8009ce4c) -/* f00c6ac: 3c0a800a */ lui $t2,%hi(var8009ce50) +/* f00c6ac: 3c0a800a */ lui $t2,%hi(g_NumProjectiles) /* f00c6b0: 3c0b800a */ lui $t3,%hi(var8009ce54) /* f00c6b4: 256bce54 */ addiu $t3,$t3,%lo(var8009ce54) -/* f00c6b8: 254ace50 */ addiu $t2,$t2,%lo(var8009ce50) +/* f00c6b8: 254ace50 */ addiu $t2,$t2,%lo(g_NumProjectiles) /* f00c6bc: 2529ce4c */ addiu $t1,$t1,%lo(var8009ce4c) /* f00c6c0: 2508ce48 */ addiu $t0,$t0,%lo(var8009ce48) /* f00c6c4: 24e7ce44 */ addiu $a3,$a3,%lo(var8009ce44) @@ -242,10 +242,10 @@ glabel func0f00c490 /* f00c760: 2484ce5c */ addiu $a0,$a0,%lo(var8009ce5c) /* f00c764: 3c08800a */ lui $t0,%hi(var8009ce48) /* f00c768: 3c09800a */ lui $t1,%hi(var8009ce4c) -/* f00c76c: 3c0a800a */ lui $t2,%hi(var8009ce50) +/* f00c76c: 3c0a800a */ lui $t2,%hi(g_NumProjectiles) /* f00c770: 3c0b800a */ lui $t3,%hi(var8009ce54) /* f00c774: 256bce54 */ addiu $t3,$t3,%lo(var8009ce54) -/* f00c778: 254ace50 */ addiu $t2,$t2,%lo(var8009ce50) +/* f00c778: 254ace50 */ addiu $t2,$t2,%lo(g_NumProjectiles) /* f00c77c: 2529ce4c */ addiu $t1,$t1,%lo(var8009ce4c) /* f00c780: 2508ce48 */ addiu $t0,$t0,%lo(var8009ce48) /* f00c784: ac820000 */ sw $v0,0x0($a0) @@ -290,10 +290,10 @@ glabel func0f00c490 /* f00c810: 3c04800a */ lui $a0,%hi(var8009ce60) /* f00c814: 2484ce60 */ addiu $a0,$a0,%lo(var8009ce60) /* f00c818: 3c09800a */ lui $t1,%hi(var8009ce4c) -/* f00c81c: 3c0a800a */ lui $t2,%hi(var8009ce50) +/* f00c81c: 3c0a800a */ lui $t2,%hi(g_NumProjectiles) /* f00c820: 3c0b800a */ lui $t3,%hi(var8009ce54) /* f00c824: 256bce54 */ addiu $t3,$t3,%lo(var8009ce54) -/* f00c828: 254ace50 */ addiu $t2,$t2,%lo(var8009ce50) +/* f00c828: 254ace50 */ addiu $t2,$t2,%lo(g_NumProjectiles) /* f00c82c: 2529ce4c */ addiu $t1,$t1,%lo(var8009ce4c) /* f00c830: ac820000 */ sw $v0,0x0($a0) /* f00c834: 19e0000c */ blez $t7,.L0f00c868 @@ -334,10 +334,10 @@ glabel func0f00c490 /* f00c8b4: 8d380000 */ lw $t8,0x0($t1) /* f00c8b8: 3c04800a */ lui $a0,%hi(var8009ce64) /* f00c8bc: 2484ce64 */ addiu $a0,$a0,%lo(var8009ce64) -/* f00c8c0: 3c0a800a */ lui $t2,%hi(var8009ce50) +/* f00c8c0: 3c0a800a */ lui $t2,%hi(g_NumProjectiles) /* f00c8c4: 3c0b800a */ lui $t3,%hi(var8009ce54) /* f00c8c8: 256bce54 */ addiu $t3,$t3,%lo(var8009ce54) -/* f00c8cc: 254ace50 */ addiu $t2,$t2,%lo(var8009ce50) +/* f00c8cc: 254ace50 */ addiu $t2,$t2,%lo(g_NumProjectiles) /* f00c8d0: ac820000 */ sw $v0,0x0($a0) /* f00c8d4: 1b00000c */ blez $t8,.L0f00c908 /* f00c8d8: 8fa3001c */ lw $v1,0x1c($sp) @@ -356,8 +356,8 @@ glabel func0f00c490 .L0f00c908: /* f00c908: 8d420000 */ lw $v0,0x0($t2) /* f00c90c: 14400004 */ bnez $v0,.L0f00c920 -/* f00c910: 3c05800a */ lui $a1,%hi(var8009ce68) -/* f00c914: 24a5ce68 */ addiu $a1,$a1,%lo(var8009ce68) +/* f00c910: 3c05800a */ lui $a1,%hi(g_Projectiles) +/* f00c914: 24a5ce68 */ addiu $a1,$a1,%lo(g_Projectiles) /* f00c918: 10000022 */ b .L0f00c9a4 /* f00c91c: aca00000 */ sw $zero,0x0($a1) .L0f00c920: @@ -372,11 +372,11 @@ glabel func0f00c490 /* f00c940: 24050004 */ addiu $a1,$zero,0x4 /* f00c944: 0c0048f2 */ jal malloc /* f00c948: afa3001c */ sw $v1,0x1c($sp) -/* f00c94c: 3c0a800a */ lui $t2,%hi(var8009ce50) -/* f00c950: 254ace50 */ addiu $t2,$t2,%lo(var8009ce50) +/* f00c94c: 3c0a800a */ lui $t2,%hi(g_NumProjectiles) +/* f00c950: 254ace50 */ addiu $t2,$t2,%lo(g_NumProjectiles) /* f00c954: 8d590000 */ lw $t9,0x0($t2) -/* f00c958: 3c05800a */ lui $a1,%hi(var8009ce68) -/* f00c95c: 24a5ce68 */ addiu $a1,$a1,%lo(var8009ce68) +/* f00c958: 3c05800a */ lui $a1,%hi(g_Projectiles) +/* f00c95c: 24a5ce68 */ addiu $a1,$a1,%lo(g_Projectiles) /* f00c960: 3c0b800a */ lui $t3,%hi(var8009ce54) /* f00c964: 256bce54 */ addiu $t3,$t3,%lo(var8009ce54) /* f00c968: aca20000 */ sw $v0,0x0($a1) @@ -1472,21 +1472,21 @@ void setupSingleMonitor(struct singlemonitorobj *monitor, s32 cmdindex) } prop = func0f06a550(monitor); - monitor->base.unk48 = func0f0686f0(); + monitor->base.projectile = func0f0686f0(); - if (prop && monitor->base.unk48) { + if (prop && monitor->base.projectile) { monitor->base.hidden |= OBJHFLAG_00000040; modelSetUnk14(monitor->base.model, monitor->base.model->unk14 * scale); monitor->base.model->attachedto = owner->model; - if (monitor->ownerpart == 0) { - monitor->base.model->unk1c = modelGetPart(owner->model->unk08, 0); - } else if (monitor->ownerpart == 1) { - monitor->base.model->unk1c = modelGetPart(owner->model->unk08, 1); - } else if (monitor->ownerpart == 2) { - monitor->base.model->unk1c = modelGetPart(owner->model->unk08, 2); + if (monitor->ownerpart == MODELPART_00) { + monitor->base.model->unk1c = modelGetPart(owner->model->unk08, MODELPART_00); + } else if (monitor->ownerpart == MODELPART_01) { + monitor->base.model->unk1c = modelGetPart(owner->model->unk08, MODELPART_01); + } else if (monitor->ownerpart == MODELPART_02) { + monitor->base.model->unk1c = modelGetPart(owner->model->unk08, MODELPART_02); } else { - monitor->base.model->unk1c = modelGetPart(owner->model->unk08, 3); + monitor->base.model->unk1c = modelGetPart(owner->model->unk08, MODELPART_03); } propReparent(prop, owner->prop); @@ -1499,7 +1499,7 @@ void setupSingleMonitor(struct singlemonitorobj *monitor, s32 cmdindex) spa4.z = -spa4.z; func000166dc(&spa4, &sp24); - func00015be4(&sp64, &sp24, (Mtxf *)&monitor->base.unk48->unk004); + func00015be4(&sp64, &sp24, (Mtxf *)&monitor->base.projectile->unk004); } } else { setupGenericObject(&monitor->base, cmdindex); diff --git a/src/game/game_0b63b0.c b/src/game/game_0b63b0.c index f16e1294c..89c51e723 100644 --- a/src/game/game_0b63b0.c +++ b/src/game/game_0b63b0.c @@ -8056,9 +8056,9 @@ glabel var7f1ad6ac // func00016208(sp696, &sp752); // func00016208(sp696, &sp740); // -// if (rocket->base.hidden & OBJHFLAG_00000080) { +// if (rocket->base.hidden & OBJHFLAG_AIRBORNE) { // // e470 -// struct obj48 *obj48 = rocket->base.unk48; +// struct projectile *projectile = rocket->base.projectile; // u32 mode = optionsGetControlMode(g_Vars.currentplayerstats->mpindex); // s8 contpad1 = optionsGetContpadNum1(g_Vars.currentplayerstats->mpindex); // s8 contpad2 = optionsGetContpadNum2(g_Vars.currentplayerstats->mpindex); @@ -8194,16 +8194,16 @@ glabel var7f1ad6ac // // e8b0 // func0f097738(sp348, sp332, sp316); // func0f096ed4(sp316, sp508); -// func00015b10(sp508, &obj48->unk04); +// func00015b10(sp508, &projectile->unk04); // -// obj48->unkb2 = 0xffff; -// obj48->flags |= OBJ48FLAG_00004000; -// obj48->unk18 = 0; -// obj48->unk14 = 0; -// obj48->unk10 = 0; +// projectile->unkb2 = 0xffff; +// projectile->flags |= PROJECTILEFLAG_00004000; +// projectile->unk18 = 0; +// projectile->unk14 = 0; +// projectile->unk10 = 0; // -// if ((obj48->flags & OBJ48FLAG_00000080) == 0) { -// obj48->unk88 = 0; +// if ((projectile->flags & PROJECTILEFLAG_00000080) == 0) { +// projectile->unk88 = 0; // } // // if (explode) { @@ -8211,9 +8211,9 @@ glabel var7f1ad6ac // } // // prevspeed = sqrtf( -// obj48->unk04.z * obj48->unk04.z + -// obj48->unk04.x * obj48->unk04.x + -// obj48->unk04.y * obj48->unk04.y); +// projectile->unk04.z * projectile->unk04.z + +// projectile->unk04.x * projectile->unk04.x + +// projectile->unk04.y * projectile->unk04.y); // // if (slow == false) { // targetspeed = 12; @@ -8237,9 +8237,9 @@ glabel var7f1ad6ac // newspeed = prevspeed; // } // -// obj48->unk04.x = (obj48->unk04.x * newspeed) / prevspeed; -// obj48->unk04.y = (obj48->unk04.y * newspeed) / prevspeed; -// obj48->unk04.z = (obj48->unk04.z * newspeed) / prevspeed; +// projectile->unk04.x = (projectile->unk04.x * newspeed) / prevspeed; +// projectile->unk04.y = (projectile->unk04.y * newspeed) / prevspeed; +// projectile->unk04.z = (projectile->unk04.z * newspeed) / prevspeed; // // // ea10 // func00015d54(sp696, sp444); diff --git a/src/game/game_17f930.c b/src/game/game_17f930.c index f70d53990..6321b09d4 100644 --- a/src/game/game_17f930.c +++ b/src/game/game_17f930.c @@ -7467,7 +7467,7 @@ glabel func0f187288 /* f1872fc: 15f80033 */ bne $t7,$t8,.L0f1873cc /* f187300: 3c08800b */ lui $t0,%hi(g_ScenarioData) /* f187304: 2508c110 */ addiu $t0,$t0,%lo(g_ScenarioData) -/* f187308: 0fc1ab10 */ jal func0f06ac40 +/* f187308: 0fc1ab10 */ jal objEndFlight /* f18730c: 03289821 */ addu $s3,$t9,$t0 /* f187310: ae370058 */ sw $s7,0x58($s1) /* f187314: a6d00062 */ sh $s0,0x62($s6) diff --git a/src/game/game_1999b0.c b/src/game/game_1999b0.c index 28277af3b..a06afb8bd 100644 --- a/src/game/game_1999b0.c +++ b/src/game/game_1999b0.c @@ -530,7 +530,7 @@ s32 func0f19a60c(s32 weaponnum, s32 funcnum) return iVar4; } -bool func0f19a6d0(struct chrdata *chr, struct coord *frompos, struct coord *topos, s16 *fromrooms, s16 *torooms, struct obj48 *obj48) +bool func0f19a6d0(struct chrdata *chr, struct coord *frompos, struct coord *topos, s16 *fromrooms, s16 *torooms, struct projectile *projectile) { struct waypoint *from = waypointFindClosestToPos(frompos, fromrooms); struct waypoint *to = waypointFindClosestToPos(topos, torooms); @@ -548,12 +548,12 @@ bool func0f19a6d0(struct chrdata *chr, struct coord *frompos, struct coord *topo s32 i = 0; while (waypoints[i]) { - obj48->waypads[i] = waypoints[i]->padnum; + projectile->waypads[i] = waypoints[i]->padnum; i++; } - obj48->unk105 = 0; - obj48->numwaypads = i; + projectile->unk105 = 0; + projectile->numwaypads = i; return true; } @@ -595,7 +595,7 @@ void aibotCreateSlayerRocket(struct chrdata *chr) sp100[0] = cosf(b) * sinf(a); sp100[1] = sinf(b); - sp100[2] = cosf(b) * cosf(a); // @bug? Should one of these be sinf? + sp100[2] = cosf(b) * cosf(a); func000162e8(b, &sp196); func00016374(a, &sp132); @@ -604,23 +604,23 @@ void aibotCreateSlayerRocket(struct chrdata *chr) func0f09ebcc(&rocket->base, &chr->prop->pos, chr->prop->rooms, &sp196, sp100, &sp260, chr->prop, &chr->prop->pos); - if (rocket->base.hidden & OBJHFLAG_00000080) { + if (rocket->base.hidden & OBJHFLAG_AIRBORNE) { struct prop *target = chrGetTargetProp(chr); rocket->unk62 = -1; - rocket->base.unk48->unk010 = 7.5; - rocket->base.unk48->unk014 = b; - rocket->base.unk48->unk018 = a; - rocket->base.unk48->unk0f4 = 0; - rocket->base.unk48->unk0b4 = 0x20000000; + rocket->base.projectile->unk010 = 7.5; + rocket->base.projectile->unk014 = b; + rocket->base.projectile->unk018 = a; + rocket->base.projectile->unk0f4 = 0; + rocket->base.projectile->unk0b4 = 0x20000000; // Fire rocket sound func0f0939f8(NULL, rocket->base.prop, 0x8053, -1, -1, 0, 0, 0, 0, -1, 0, -1, -1, -1, -1); - if (!func0f19a6d0(chr, &chr->prop->pos, &target->pos, chr->prop->rooms, target->rooms, rocket->base.unk48)) { + if (!func0f19a6d0(chr, &chr->prop->pos, &target->pos, chr->prop->rooms, target->rooms, rocket->base.projectile)) { rocket->unk62 = 0; } else { - func0f19a7d0(rocket->base.unk48->waypads[0], &rocket->base.unk48->pos); + func0f19a7d0(rocket->base.projectile->waypads[0], &rocket->base.projectile->pos); chr->aibot->unk044 = rocket->base.prop; } } diff --git a/src/game/propobj.c b/src/game/propobj.c index aa26c3bbc..9fc42414a 100644 --- a/src/game/propobj.c +++ b/src/game/propobj.c @@ -2669,23 +2669,23 @@ glabel func0f068218 /* f0682d8: 27bd0040 */ addiu $sp,$sp,0x40 ); -void obj48Free(struct obj48 *obj48) +void projectileFree(struct projectile *projectile) { - if (obj48) { - obj48->flags |= OBJ48FLAG_FREE; + if (projectile) { + projectile->flags |= PROJECTILEFLAG_FREE; } } GLOBAL_ASM( glabel func0f0682fc -/* f0682fc: 3c03800a */ lui $v1,%hi(var8009ce50) -/* f068300: 8c63ce50 */ lw $v1,%lo(var8009ce50)($v1) +/* f0682fc: 3c03800a */ lui $v1,%hi(g_NumProjectiles) +/* f068300: 8c63ce50 */ lw $v1,%lo(g_NumProjectiles)($v1) /* f068304: 00803025 */ or $a2,$a0,$zero /* f068308: 00002025 */ or $a0,$zero,$zero /* f06830c: 18600014 */ blez $v1,.L0f068360 /* f068310: 00001025 */ or $v0,$zero,$zero -/* f068314: 3c07800a */ lui $a3,%hi(var8009ce68) -/* f068318: 24e7ce68 */ addiu $a3,$a3,%lo(var8009ce68) +/* f068314: 3c07800a */ lui $a3,%hi(g_Projectiles) +/* f068318: 24e7ce68 */ addiu $a3,$a3,%lo(g_Projectiles) /* f06831c: 3c088000 */ lui $t0,0x8000 .L0f068320: /* f068320: 8cee0000 */ lw $t6,0x0($a3) @@ -2699,8 +2699,8 @@ glabel func0f0682fc /* f068340: 54d90005 */ bnel $a2,$t9,.L0f068358 /* f068344: 0043082a */ slt $at,$v0,$v1 /* f068348: aca00088 */ sw $zero,0x88($a1) -/* f06834c: 3c03800a */ lui $v1,%hi(var8009ce50) -/* f068350: 8c63ce50 */ lw $v1,%lo(var8009ce50)($v1) +/* f06834c: 3c03800a */ lui $v1,%hi(g_NumProjectiles) +/* f068350: 8c63ce50 */ lw $v1,%lo(g_NumProjectiles)($v1) /* f068354: 0043082a */ slt $at,$v0,$v1 .L0f068358: /* f068358: 1420fff1 */ bnez $at,.L0f068320 @@ -2710,87 +2710,87 @@ glabel func0f0682fc /* f068364: 00000000 */ nop ); -void obj48Reset(struct obj48 *obj48) +void projectileReset(struct projectile *projectile) { - obj48->flags = 0; - obj48->unk004.x = 0; - obj48->unk004.y = 0; - obj48->unk004.z = 0; - obj48->unk010 = 0; - obj48->unk014 = 0; - obj48->unk018 = 0; - obj48->unk01c = 0; + projectile->flags = 0; + projectile->unk004.x = 0; + projectile->unk004.y = 0; + projectile->unk004.z = 0; + projectile->unk010 = 0; + projectile->unk014 = 0; + projectile->unk018 = 0; + projectile->unk01c = 0; - func000159b0((Mtxf *)&obj48->unk020); + func000159b0((Mtxf *)&projectile->unk020); - obj48->unk060 = 1; - obj48->unk088 = 0; - obj48->unk08c = 0.05f; - obj48->unk090 = 0; - obj48->unk094 = -1; - obj48->unk09c = -1; - obj48->unk0a0 = 0; - obj48->unk0a4 = -1; - obj48->dropreason = 1; - obj48->unk0b4 = 0; - obj48->unk0d0 = 0; - obj48->obj = NULL; - obj48->unk0d8 = 0; - obj48->unk0f4 = 0; - obj48->unk0e8 = 0; - obj48->unk108 = 0; - obj48->unk0b2 = 0xffff; - obj48->unk0b8 = 1; - obj48->unk0bc = 1; - obj48->unk0c0 = 1; - obj48->unk0e4 = 1; - obj48->unk098 = 0; - obj48->unk0dc = 0; - obj48->unk0e0 = 0; - obj48->unk0ec = 0; - obj48->unk0f0 = 0; + projectile->unk060 = 1; + projectile->unk088 = 0; + projectile->unk08c = 0.05f; + projectile->unk090 = 0; + projectile->unk094 = -1; + projectile->unk09c = -1; + projectile->unk0a0 = 0; + projectile->unk0a4 = -1; + projectile->dropreason = 1; + projectile->unk0b4 = 0; + projectile->unk0d0 = 0; + projectile->obj = NULL; + projectile->unk0d8 = 0; + projectile->unk0f4 = 0; + projectile->unk0e8 = 0; + projectile->unk108 = 0; + projectile->unk0b2 = 0xffff; + projectile->unk0b8 = 1; + projectile->unk0bc = 1; + projectile->unk0c0 = 1; + projectile->unk0e4 = 1; + projectile->unk098 = 0; + projectile->unk0dc = 0; + projectile->unk0e0 = 0; + projectile->unk0ec = 0; + projectile->unk0f0 = 0; } -struct obj48 *obj48GetNew(void) +struct projectile *projectileGetNew(void) { s32 bestindex = -1; s32 i; // Happy path - find one that is already free - for (i = 0; i < var8009ce50; i++) { - if (var8009ce68[i].flags & OBJ48FLAG_FREE) { - obj48Reset(&var8009ce68[i]); - return &var8009ce68[i]; + for (i = 0; i < g_NumProjectiles; i++) { + if (g_Projectiles[i].flags & PROJECTILEFLAG_FREE) { + projectileReset(&g_Projectiles[i]); + return &g_Projectiles[i]; } } // Find one with the lowest unk0d8 (some kind of age/timer?) // and some other conditions - for (i = 0; i < var8009ce50; i++) { - if (var8009ce68[i].obj - && var8009ce68[i].unk0d8 > 0 - && (bestindex < 0 || var8009ce68[i].unk0d8 < var8009ce68[bestindex].unk0d8)) { + for (i = 0; i < g_NumProjectiles; i++) { + if (g_Projectiles[i].obj + && g_Projectiles[i].unk0d8 > 0 + && (bestindex < 0 || g_Projectiles[i].unk0d8 < g_Projectiles[bestindex].unk0d8)) { bestindex = i; } } // If there were none, pick one at random - if (bestindex == -1 && var8009ce50) { - bestindex = random() % var8009ce50; + if (bestindex == -1 && g_NumProjectiles) { + bestindex = random() % g_NumProjectiles; } if (bestindex >= 0) { // Reset and return it - if (var8009ce68[bestindex].obj) { - if (var8009ce68[bestindex].obj->prop) { - func0f06ac90(var8009ce68[bestindex].obj->prop); + if (g_Projectiles[bestindex].obj) { + if (g_Projectiles[bestindex].obj->prop) { + func0f06ac90(g_Projectiles[bestindex].obj->prop); } - var8009ce68[bestindex].obj->hidden |= OBJHFLAG_00000004; + g_Projectiles[bestindex].obj->hidden |= OBJHFLAG_00000004; } - obj48Reset(&var8009ce68[bestindex]); - return &var8009ce68[bestindex]; + projectileReset(&g_Projectiles[bestindex]); + return &g_Projectiles[bestindex]; } else { return NULL; } @@ -2801,20 +2801,20 @@ void func0f0685e4(struct prop *prop) struct defaultobj *obj = prop->obj; if (obj->hidden & OBJHFLAG_00000040) { - if (obj->unk48->unk044) { - obj48Reset(obj->unk48->unk044); + if (obj->projectile->unk044) { + projectileReset(obj->projectile->unk044); } else { - obj->unk48->unk044 = obj48GetNew(); + obj->projectile->unk044 = projectileGetNew(); } - } else if ((obj->hidden & OBJHFLAG_00000080) == 0) { - if (obj->unk48) { - obj48Reset(obj->unk48); + } else if ((obj->hidden & OBJHFLAG_AIRBORNE) == 0) { + if (obj->projectile) { + projectileReset(obj->projectile); } else { - obj->unk48 = obj48GetNew(); + obj->projectile = projectileGetNew(); } - if (obj->unk48) { - obj->hidden |= OBJHFLAG_00000080; + if (obj->projectile) { + obj->hidden |= OBJHFLAG_AIRBORNE; } } } @@ -5523,13 +5523,13 @@ glabel var7f1aa208 /* f06ac3c: 00000000 */ nop ); -void func0f06ac40(struct defaultobj *obj) +void objEndFlight(struct defaultobj *obj) { - if (obj->hidden & OBJHFLAG_00000080) { - obj48Free(obj->unk48); - obj->unk48 = NULL; + if (obj->hidden & OBJHFLAG_AIRBORNE) { + projectileFree(obj->projectile); + obj->projectile = NULL; - obj->hidden &= ~OBJHFLAG_00000080; + obj->hidden &= ~OBJHFLAG_AIRBORNE; } } @@ -5553,7 +5553,7 @@ glabel func0f06ac90 /* f06accc: 10c00006 */ beqz $a2,.L0f06ace8 /* f06acd0: 00000000 */ nop /* f06acd4: 00c02025 */ or $a0,$a2,$zero -/* f06acd8: 0fc1a0b7 */ jal obj48Free +/* f06acd8: 0fc1a0b7 */ jal projectileFree /* f06acdc: afa3001c */ sw $v1,0x1c($sp) /* f06ace0: 8fa5001c */ lw $a1,0x1c($sp) /* f06ace4: 8ca40048 */ lw $a0,0x48($a1) @@ -5571,7 +5571,7 @@ glabel func0f06ac90 .L0f06ad0c: /* f06ad0c: 53000004 */ beqzl $t8,.L0f06ad20 /* f06ad10: 8fbf0014 */ lw $ra,0x14($sp) -/* f06ad14: 0fc1ab10 */ jal func0f06ac40 +/* f06ad14: 0fc1ab10 */ jal objEndFlight /* f06ad18: 00a02025 */ or $a0,$a1,$zero .L0f06ad1c: /* f06ad1c: 8fbf0014 */ lw $ra,0x14($sp) @@ -8927,7 +8927,7 @@ glabel var7f1aa298 /* f06dc0c: 8c820048 */ lw $v0,0x48($a0) /* f06dc10: 15c10005 */ bne $t6,$at,.L0f06dc28 /* f06dc14: 27a50148 */ addiu $a1,$sp,0x148 -/* f06dc18: 0fc1ab10 */ jal func0f06ac40 +/* f06dc18: 0fc1ab10 */ jal objEndFlight /* f06dc1c: 00000000 */ nop /* f06dc20: 10000313 */ b .L0f06e870 /* f06dc24: 8fbf0014 */ lw $ra,0x14($sp) @@ -10402,7 +10402,7 @@ glabel func0f06f0a0 /* f06f0d4: 8e180048 */ lw $t8,0x48($s0) /* f06f0d8: 02002025 */ or $a0,$s0,$zero /* f06f0dc: 8f190088 */ lw $t9,0x88($t8) -/* f06f0e0: 0fc1ab10 */ jal func0f06ac40 +/* f06f0e0: 0fc1ab10 */ jal objEndFlight /* f06f0e4: afb90020 */ sw $t9,0x20($sp) /* f06f0e8: 8e030040 */ lw $v1,0x40($s0) /* f06f0ec: 92020003 */ lbu $v0,0x3($s0) @@ -16644,7 +16644,7 @@ glabel var7f1aa438 /* f074a88: 00000000 */ nop /* f074a8c: 45020004 */ bc1fl .L0f074aa0 /* f074a90: 8fad0600 */ lw $t5,0x600($sp) -/* f074a94: 0fc1ab10 */ jal func0f06ac40 +/* f074a94: 0fc1ab10 */ jal objEndFlight /* f074a98: 02202025 */ or $a0,$s1,$zero /* f074a9c: 8fad0600 */ lw $t5,0x600($sp) .L0f074aa0: @@ -19126,7 +19126,7 @@ glabel var7f1aa438 .L0f076ec8: /* f076ec8: 51e0000b */ beqzl $t7,.L0f076ef8 /* f076ecc: 8fae05d8 */ lw $t6,0x5d8($sp) -/* f076ed0: 0fc1ab10 */ jal func0f06ac40 +/* f076ed0: 0fc1ab10 */ jal objEndFlight /* f076ed4: 02202025 */ or $a0,$s1,$zero /* f076ed8: 922c0003 */ lbu $t4,0x3($s1) /* f076edc: 24010008 */ addiu $at,$zero,0x8 @@ -28126,7 +28126,7 @@ s32 objTick(struct prop *prop) if (obj->hidden & OBJHFLAG_00000008) { obj->hidden &= ~OBJHFLAG_00000008; - } else if ((obj->hidden & OBJHFLAG_00000080) && (obj->unk48->flags & 0x00000800) == 0) { + } else if ((obj->hidden & OBJHFLAG_AIRBORNE) && (obj->projectile->flags & PROJECTILEFLAG_00000800) == 0) { prop->flags &= ~PROPFLAG_02; obj->hidden |= OBJHFLAG_00000008; return 3; @@ -28163,11 +28163,11 @@ s32 objTick(struct prop *prop) prop->flags &= ~PROPFLAG_08; } - if (obj->hidden & OBJHFLAG_00000080) { - struct obj48 *obj48 = obj->unk48; + if (obj->hidden & OBJHFLAG_AIRBORNE) { + struct projectile *projectile = obj->projectile; - if (obj48->unk088 && propGetPlayerNum(obj48->unk088) >= 0) { - sp572 = (obj48->unk088 == g_Vars.currentplayer->prop); + if (projectile->unk088 && propGetPlayerNum(projectile->unk088) >= 0) { + sp572 = (projectile->unk088 == g_Vars.currentplayer->prop); } } @@ -28363,7 +28363,7 @@ s32 objTick(struct prop *prop) } if (sp572) { - if (model->anim == NULL && (obj->hidden & OBJHFLAG_00000080)) { + if (model->anim == NULL && (obj->hidden & OBJHFLAG_AIRBORNE)) { sp592 = func0f073c6c(obj, &sp560); if (sp560) { @@ -32211,10 +32211,10 @@ void propobjSetDropped(struct prop *prop, u32 reason) func0f0685e4(prop); - if ((obj->hidden & OBJHFLAG_00000040) && obj->unk48->unk044) { - obj->unk48->unk044->dropreason = reason; - } else if (obj->hidden & OBJHFLAG_00000080) { - obj->unk48->dropreason = reason; + if ((obj->hidden & OBJHFLAG_00000040) && obj->projectile->unk044) { + obj->projectile->unk044->dropreason = reason; + } else if (obj->hidden & OBJHFLAG_AIRBORNE) { + obj->projectile->dropreason = reason; } if (g_Vars.lvmpbotlevel @@ -41095,7 +41095,7 @@ struct weaponobj *weaponFindThrown(s32 weaponnum) while (prop) { struct weaponobj *weapon = func0f08aa70(weaponnum, prop); - if (weapon && (weapon->base.hidden & OBJHFLAG_00000080) == 0) { + if (weapon && (weapon->base.hidden & OBJHFLAG_AIRBORNE) == 0) { return weapon; } @@ -44621,9 +44621,9 @@ void func0f08e224(struct doorobj *door) if (door->doortype == DOORTYPE_8) { func0f0685e4(door->base.prop); - if (door->base.hidden & OBJHFLAG_00000080) { - door->base.unk48->flags |= 1; - func000159b0((Mtxf *)&door->base.unk48->unk020); + if (door->base.hidden & OBJHFLAG_AIRBORNE) { + door->base.projectile->flags |= PROJECTILEFLAG_00000001; + func000159b0((Mtxf *)&door->base.projectile->unk020); } } @@ -47429,17 +47429,17 @@ glabel var7f1ab1a8 GLOBAL_ASM( glabel func0f090d34 -/* f090d34: 3c03800a */ lui $v1,%hi(var8009ce50) -/* f090d38: 8c63ce50 */ lw $v1,%lo(var8009ce50)($v1) +/* f090d34: 3c03800a */ lui $v1,%hi(g_NumProjectiles) +/* f090d38: 8c63ce50 */ lw $v1,%lo(g_NumProjectiles)($v1) /* f090d3c: 00001025 */ or $v0,$zero,$zero -/* f090d40: 3c04800a */ lui $a0,%hi(var8009ce68) +/* f090d40: 3c04800a */ lui $a0,%hi(g_Projectiles) /* f090d44: 1860000a */ blez $v1,.L0f090d70 /* f090d48: 00032900 */ sll $a1,$v1,0x4 /* f090d4c: 00a32821 */ addu $a1,$a1,$v1 /* f090d50: 00052880 */ sll $a1,$a1,0x2 /* f090d54: 00a32823 */ subu $a1,$a1,$v1 /* f090d58: 00052880 */ sll $a1,$a1,0x2 -/* f090d5c: 8c84ce68 */ lw $a0,%lo(var8009ce68)($a0) +/* f090d5c: 8c84ce68 */ lw $a0,%lo(g_Projectiles)($a0) .L0f090d60: /* f090d60: 2442010c */ addiu $v0,$v0,0x10c /* f090d64: 0045082a */ slt $at,$v0,$a1 diff --git a/src/game/training.c b/src/game/training.c index 62d1263a7..c0a62fe23 100644 --- a/src/game/training.c +++ b/src/game/training.c @@ -2337,7 +2337,7 @@ bool frIsAmmoWasted(void) if (prop->weapon->weaponnum == WEAPON_BOLT || prop->weapon->weaponnum == WEAPON_COMBATKNIFE) { - if (prop->obj->hidden & OBJHFLAG_00000080) { + if (prop->obj->hidden & OBJHFLAG_AIRBORNE) { return false; } } else if (prop->weapon->weaponnum == WEAPON_TIMEDMINE diff --git a/src/gvars/gvars.c b/src/gvars/gvars.c index 06aaf3304..faa3f756a 100644 --- a/src/gvars/gvars.c +++ b/src/gvars/gvars.c @@ -14645,13 +14645,13 @@ u32 var8009ce40 = 0; u32 var8009ce44 = 0; u32 var8009ce48 = 0; u32 var8009ce4c = 0; -s32 var8009ce50 = 0; +s32 g_NumProjectiles = 0; u32 var8009ce54 = 0; u32 var8009ce58 = 0; u32 var8009ce5c = 0; u32 var8009ce60 = 0; u32 var8009ce64 = 0; -struct obj48 *var8009ce68 = NULL; +struct projectile *g_Projectiles = NULL; u32 var8009ce6c = 0; u32 var8009ce70 = 0; u32 var8009ce74 = 0; diff --git a/src/include/constants.h b/src/include/constants.h index a8b1cf4ff..b7ebaa762 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -1651,9 +1651,12 @@ #define MODELNODETYPE_HEADSPOT 0x17 #define MODELNODETYPE_DISPLAYLIST 0x18 +#define MODELPART_00 0x00 #define MODELPART_LENS 0x00 #define MODELPART_01 0x01 +#define MODELPART_02 0x02 #define MODELPART_ROBOTMUZZLEFLASHR 0x02 +#define MODELPART_03 0x03 #define MODELPART_ROBOTMUZZLEFLASHL 0x03 #define MODELPART_HUDPIECE 0x04 #define MODELPART_NECKLACE 0x07 @@ -2212,10 +2215,6 @@ #define NUM_TEXTURES 3504 #define NUM_WEAPONS 94 -#define OBJ48FLAG_00000080 0x00000080 -#define OBJ48FLAG_00004000 0x00004000 -#define OBJ48FLAG_FREE 0x80000000 - #define OBJECTIVE_INCOMPLETE 0 #define OBJECTIVE_COMPLETE 1 #define OBJECTIVE_FAILED 2 @@ -2332,7 +2331,7 @@ #define OBJHFLAG_00000008 0x00000008 #define OBJHFLAG_TAGGED 0x00000010 #define OBJHFLAG_00000040 0x00000040 -#define OBJHFLAG_00000080 0x00000080 +#define OBJHFLAG_AIRBORNE 0x00000080 #define OBJHFLAG_00000100 0x00000100 #define OBJHFLAG_00000200 0x00000200 #define OBJHFLAG_HASTEXTOVERRIDE 0x00000400 @@ -2537,6 +2536,12 @@ #define PORTALMODE_SHOW 0 #define PORTALMODE_HIDE 1 +#define PROJECTILEFLAG_00000001 0x00000001 +#define PROJECTILEFLAG_00000080 0x00000080 +#define PROJECTILEFLAG_00000800 0x00000800 +#define PROJECTILEFLAG_00004000 0x00004000 +#define PROJECTILEFLAG_FREE 0x80000000 + #define PROPFLAG_01 0x01 #define PROPFLAG_02 0x02 #define PROPFLAG_TANGIBLE 0x04 diff --git a/src/include/game/game_1999b0.h b/src/include/game/game_1999b0.h index b173e43fd..f07f2e7e9 100644 --- a/src/include/game/game_1999b0.h +++ b/src/include/game/game_1999b0.h @@ -17,7 +17,7 @@ u32 aibotGetProjectileThrowInterval(u32 weapon); u32 ammotypeGetWeapon(u32 ammotype); void func0f19a37c(struct chrdata *chr); s32 func0f19a60c(s32 weaponnum, s32 funcnum); -bool func0f19a6d0(struct chrdata *chr, struct coord *frompos, struct coord *topos, s16 *fromrooms, s16 *torooms, struct obj48 *obj48); +bool func0f19a6d0(struct chrdata *chr, struct coord *frompos, struct coord *topos, s16 *fromrooms, s16 *torooms, struct projectile *projectile); void func0f19a7d0(u16 padnum, struct coord *pos); void aibotCreateSlayerRocket(struct chrdata *chr); diff --git a/src/include/game/propobj.h b/src/include/game/propobj.h index 505b500bb..b6dc87f8c 100644 --- a/src/include/game/propobj.h +++ b/src/include/game/propobj.h @@ -59,14 +59,14 @@ bool modelSetRedBox(struct model *model, f32 *arg1, f32 *arg2, f32 *arg3, f32 *a void func0f06803c(f32 *arg0, f32 *arg1, f32 *arg2, f32 *arg3, f32 *arg4); struct defaultobj *objFindByPadNum(s32 padnum); u32 func0f068218(void); -void obj48Free(struct obj48 *obj48); +void projectileFree(struct projectile *projectile); void func0f0682fc(struct prop *prop); -void obj48Reset(struct obj48 *obj48); -struct obj48 *obj48GetNew(void); +void projectileReset(struct projectile *projectile); +struct projectile *projectileGetNew(void); void func0f0685e4(struct prop *prop); u32 func0f068694(void); u32 func0f0686e0(void); -struct obj48 *func0f0686f0(void); +struct projectile *func0f0686f0(void); u32 func0f068760(void); u32 func0f0687b8(struct defaultobj *obj); u32 func0f0687e4(void); @@ -97,7 +97,7 @@ u32 func0f06a580(void); f32 func0f06a620(struct defaultobj *obj); void func0f06a730(struct defaultobj *obj, struct pad *newpad, Mtxf *matrix, s16 *arg3, struct pad *arg4); u32 func0f06ab60(void); -void func0f06ac40(struct defaultobj *obj); +void objEndFlight(struct defaultobj *obj); void func0f06ac90(struct prop *prop); void func0f06ad2c(void *ptr, bool arg1, bool arg2); void func0f06b34c(void *ptr, s32 arg1); diff --git a/src/include/gvars/gvars.h b/src/include/gvars/gvars.h index 9555fe8ab..1cdacbc02 100644 --- a/src/include/gvars/gvars.h +++ b/src/include/gvars/gvars.h @@ -563,13 +563,13 @@ extern u32 var8009ce40; extern u32 var8009ce44; extern u32 var8009ce48; extern u32 var8009ce4c; -extern s32 var8009ce50; +extern s32 g_NumProjectiles; extern u32 var8009ce54; extern u32 var8009ce58; extern u32 var8009ce5c; extern u32 var8009ce60; extern u32 var8009ce64; -extern struct obj48 *var8009ce68; +extern struct projectile *g_Projectiles; extern u32 var8009ce6c; extern u32 var8009ce78; extern u32 var8009ce88; diff --git a/src/include/types.h b/src/include/types.h index 224b8a082..dde476c19 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -1046,7 +1046,7 @@ struct chrdata { /*0x364*/ u32 unk364; }; -struct obj48 { +struct projectile { /*0x000*/ u32 flags; /*0x004*/ struct coord unk004; // distance moved in last tick /*0x010*/ f32 unk010; @@ -1062,7 +1062,7 @@ struct obj48 { /*0x038*/ u32 unk038; /*0x03c*/ u32 unk03c; /*0x040*/ u32 unk040; - /*0x044*/ struct obj48 *unk044; + /*0x044*/ struct projectile *unk044; /*0x048*/ u32 unk048; /*0x04c*/ u32 unk04c; /*0x050*/ u32 unk050; @@ -1079,7 +1079,7 @@ struct obj48 { /*0x07c*/ u32 unk07c; /*0x080*/ u32 unk080; /*0x084*/ u32 unk084; - /*0x088*/ struct prop *unk088; + /*0x088*/ struct prop *unk088; // player prop /*0x08c*/ f32 unk08c; /*0x090*/ u32 unk090; /*0x094*/ s32 unk094; @@ -1177,7 +1177,7 @@ struct defaultobj { /*0x1c*/ f32 realrot[9]; /*0x40*/ u32 hidden; /*0x44*/ struct geo *geo; - /*0x48*/ struct obj48 *unk48; + /*0x48*/ struct projectile *projectile; /*0x4c*/ s16 damage; /*0x4e*/ s16 maxdamage; /*0x50*/ u8 shadecol[4];