mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-02 22:14:33 +00:00
Fix misc 10 (#1208)
* Cleanup around `Item_DropCollectible` * Cleanup around `Math3D_Vec3fDistSq`, `Math3D_Dist2DSq` * Material/Model naming for one dlist pair * Minor comments fixup * Explicit `!= NULL` check * Signed decimal for an array of coordinates * Fixup comments some more
This commit is contained in:
parent
8ad90df27f
commit
72847660eb
24 changed files with 50 additions and 47 deletions
|
@ -165,7 +165,8 @@ void BgHakaTubo_DropCollectible(BgHakaTubo* this, GlobalContext* globalCtx) {
|
|||
func_80078884(NA_SE_SY_CORRECT_CHIME);
|
||||
// Drop rupees
|
||||
for (i = 0; i < 9; i++) {
|
||||
collectible = Item_DropCollectible(globalCtx, &spawnPos, i % 3);
|
||||
collectible = Item_DropCollectible(
|
||||
globalCtx, &spawnPos, (i % (ITEM00_RUPEE_RED - ITEM00_RUPEE_GREEN + 1)) + ITEM00_RUPEE_GREEN);
|
||||
if (collectible != NULL) {
|
||||
collectible->actor.velocity.y = 15.0f;
|
||||
collectible->actor.world.rot.y = this->dyna.actor.shape.rot.y + (i * 0x1C71);
|
||||
|
|
|
@ -251,7 +251,7 @@ void func_808B8F08(BgSpot18Obj* this, GlobalContext* globalCtx) {
|
|||
func_808B8DDC(this, globalCtx);
|
||||
|
||||
if (Math3D_Dist2DSq(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.z, this->dyna.actor.home.pos.x,
|
||||
this->dyna.actor.home.pos.z) >= 6400.0f) {
|
||||
this->dyna.actor.home.pos.z) >= SQ(80.0f)) {
|
||||
func_808B9030(this);
|
||||
this->dyna.actor.world.pos.x = (Math_SinS(this->dyna.actor.world.rot.y) * 80.0f) + this->dyna.actor.home.pos.x;
|
||||
this->dyna.actor.world.pos.z = (Math_CosS(this->dyna.actor.world.rot.y) * 80.0f) + this->dyna.actor.home.pos.z;
|
||||
|
|
|
@ -2738,7 +2738,7 @@ void BossSst_DrawHand(Actor* thisx, GlobalContext* globalCtx) {
|
|||
trail2 = &this->handTrails[(idx + 2) % 7];
|
||||
|
||||
for (i = 0; i < end; i++) {
|
||||
if (Math3D_Vec3fDistSq(&trail2->world.pos, &trail->world.pos) > 900.0f) {
|
||||
if (Math3D_Vec3fDistSq(&trail2->world.pos, &trail->world.pos) > SQ(30.0f)) {
|
||||
Matrix_SetTranslateRotateYXZ(trail->world.pos.x, trail->world.pos.y, trail->world.pos.z,
|
||||
&trail->world.rot);
|
||||
Matrix_Scale(0.02f, 0.02f, 0.02f, MTXMODE_APPLY);
|
||||
|
|
|
@ -289,7 +289,7 @@ void func_809C9700(EnBox* this, GlobalContext* globalCtx) {
|
|||
func_8002F5F0(&this->dyna.actor, globalCtx);
|
||||
}
|
||||
|
||||
if (Math3D_Vec3fDistSq(&this->dyna.actor.world.pos, &player->actor.world.pos) > 22500.0f) {
|
||||
if (Math3D_Vec3fDistSq(&this->dyna.actor.world.pos, &player->actor.world.pos) > SQ(150.0f)) {
|
||||
this->unk_1FB = ENBOX_STATE_0;
|
||||
} else {
|
||||
if (this->unk_1FB == ENBOX_STATE_0) {
|
||||
|
|
|
@ -198,7 +198,7 @@ void EnEncount1_SpawnTektites(EnEncount1* this, GlobalContext* globalCtx) {
|
|||
}
|
||||
spawnPos.y = floorY;
|
||||
if (Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_TITE, spawnPos.x,
|
||||
spawnPos.y, spawnPos.z, 0, 0, 0, TEKTITE_RED) != NULL) { // Red tektite
|
||||
spawnPos.y, spawnPos.z, 0, 0, 0, TEKTITE_RED) != NULL) {
|
||||
this->curNumSpawn++;
|
||||
this->totalNumSpawn++;
|
||||
} else {
|
||||
|
|
|
@ -123,23 +123,23 @@ void func_80A7BF58(EnInsect* this) {
|
|||
*/
|
||||
s32 EnInsect_FoundNearbySoil(EnInsect* this, GlobalContext* globalCtx) {
|
||||
Actor* currentActor;
|
||||
f32 currentDistance;
|
||||
f32 bestDistance;
|
||||
f32 currentDistanceSq;
|
||||
f32 bestDistanceSq;
|
||||
s32 ret;
|
||||
|
||||
ret = 0;
|
||||
currentActor = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].head;
|
||||
bestDistance = 6400.0f;
|
||||
bestDistanceSq = 6400.0f;
|
||||
this->soilActor = NULL;
|
||||
|
||||
while (currentActor != NULL) {
|
||||
if (currentActor->id == ACTOR_OBJ_MAKEKINSUTA) {
|
||||
currentDistance = Math3D_Dist2DSq(this->actor.world.pos.x, this->actor.world.pos.z,
|
||||
currentActor->world.pos.x, currentActor->world.pos.z);
|
||||
currentDistanceSq = Math3D_Dist2DSq(this->actor.world.pos.x, this->actor.world.pos.z,
|
||||
currentActor->world.pos.x, currentActor->world.pos.z);
|
||||
|
||||
if (currentDistance < bestDistance && currentActor->room == this->actor.room) {
|
||||
if (currentDistanceSq < bestDistanceSq && currentActor->room == this->actor.room) {
|
||||
ret = 1;
|
||||
bestDistance = currentDistance;
|
||||
bestDistanceSq = currentDistanceSq;
|
||||
this->soilActor = (ObjMakekinsuta*)currentActor;
|
||||
}
|
||||
}
|
||||
|
@ -429,7 +429,7 @@ void func_80A7CC3C(EnInsect* this, GlobalContext* globalCtx) {
|
|||
|
||||
if (this->unk_31A <= 0) {
|
||||
if ((this->unk_314 & 0x10) && this->soilActor != NULL &&
|
||||
Math3D_Vec3fDistSq(&this->soilActor->actor.world.pos, &this->actor.world.pos) < 64.0f) {
|
||||
Math3D_Vec3fDistSq(&this->soilActor->actor.world.pos, &this->actor.world.pos) < SQ(8.0f)) {
|
||||
this->soilActor->unk_152 = 1;
|
||||
}
|
||||
Actor_Kill(&this->actor);
|
||||
|
|
|
@ -441,7 +441,7 @@ void EnNy_SetupDie(EnNy* this, GlobalContext* globalCtx) {
|
|||
if (this->unk_1D0 == 0) {
|
||||
Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xA0);
|
||||
} else {
|
||||
Item_DropCollectible(globalCtx, &this->actor.world.pos, 8);
|
||||
Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_ARROWS_SMALL);
|
||||
}
|
||||
Audio_PlayActorSound2(&this->actor, NA_SE_EN_NYU_DEAD);
|
||||
this->actionFunc = EnNy_Die;
|
||||
|
|
|
@ -453,7 +453,7 @@ void EnSb_Update(Actor* thisx, GlobalContext* globalCtx) {
|
|||
if (!this->hitByWindArrow) {
|
||||
Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x80);
|
||||
} else {
|
||||
Item_DropCollectible(globalCtx, &this->actor.world.pos, 8);
|
||||
Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_ARROWS_SMALL);
|
||||
}
|
||||
Actor_Kill(&this->actor);
|
||||
}
|
||||
|
|
|
@ -72,10 +72,10 @@ void EnTuboTrap_Destroy(Actor* thisx, GlobalContext* globalCtx) {
|
|||
|
||||
void EnTuboTrap_DropCollectible(EnTuboTrap* this, GlobalContext* globalCtx) {
|
||||
s16 params = this->actor.params;
|
||||
s16 param3FF = (params >> 6) & 0x3FF;
|
||||
s16 dropType = (params >> 6) & 0x3FF;
|
||||
|
||||
if (param3FF >= 0 && param3FF < 0x1A) {
|
||||
Item_DropCollectible(globalCtx, &this->actor.world.pos, param3FF | ((params & 0x3F) << 8));
|
||||
if (dropType >= 0 && dropType < ITEM00_MAX) {
|
||||
Item_DropCollectible(globalCtx, &this->actor.world.pos, dropType | ((params & 0x3F) << 8));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ void func_80B5357C(EnZl3* this, GlobalContext* globalCtx) {
|
|||
sp20.x = thisPos->x + ((Rand_ZeroOne() - 0.5f) * 10.0f);
|
||||
sp20.y = thisPos->y;
|
||||
sp20.z = thisPos->z + ((Rand_ZeroOne() - 0.5f) * 10.0f);
|
||||
Item_DropCollectible(globalCtx, &sp20, 3);
|
||||
Item_DropCollectible(globalCtx, &sp20, ITEM00_HEART);
|
||||
}
|
||||
|
||||
void func_80B53614(EnZl3* this, GlobalContext* globalCtx) {
|
||||
|
|
|
@ -290,7 +290,7 @@ s32 ObjBean_CheckForHorseTrample(ObjBean* this, GlobalContext* globalCtx) {
|
|||
|
||||
while (currentActor != NULL) {
|
||||
if ((currentActor->id == ACTOR_EN_HORSE) &&
|
||||
(Math3D_Vec3fDistSq(¤tActor->world.pos, &this->dyna.actor.world.pos) < 10000.0f)) {
|
||||
(Math3D_Vec3fDistSq(¤tActor->world.pos, &this->dyna.actor.world.pos) < SQ(100.0f))) {
|
||||
return true;
|
||||
}
|
||||
currentActor = currentActor->next;
|
||||
|
|
|
@ -130,8 +130,8 @@ void ObjComb_Break(ObjComb* this, GlobalContext* globalCtx) {
|
|||
void ObjComb_ChooseItemDrop(ObjComb* this, GlobalContext* globalCtx) {
|
||||
s16 params = this->actor.params & 0x1F;
|
||||
|
||||
if ((params > 0) || (params < 0x1A)) {
|
||||
if (params == 6) {
|
||||
if ((params > 0) || (params < ITEM00_MAX)) { // conditional always true. May have been intended to be &&
|
||||
if (params == ITEM00_HEART_PIECE) {
|
||||
if (Flags_GetCollectible(globalCtx, (this->actor.params >> 8) & 0x3F)) {
|
||||
params = -1;
|
||||
} else {
|
||||
|
|
|
@ -67,7 +67,7 @@ void ObjKibako_SpawnCollectible(ObjKibako* this, GlobalContext* globalCtx) {
|
|||
s16 collectible;
|
||||
|
||||
collectible = this->actor.params & 0x1F;
|
||||
if ((collectible >= 0) && (collectible <= 0x19)) {
|
||||
if ((collectible >= 0) && (collectible < ITEM00_MAX)) {
|
||||
Item_DropCollectible(globalCtx, &this->actor.world.pos,
|
||||
collectible | (((this->actor.params >> 8) & 0x3F) << 8));
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ void ObjKibako2_SpawnCollectible(ObjKibako2* this, GlobalContext* globalCtx) {
|
|||
|
||||
collectibleFlagTemp = this->collectibleFlag;
|
||||
itemDropped = this->dyna.actor.home.rot.x;
|
||||
if (itemDropped >= 0 && itemDropped < 0x1A) {
|
||||
if (itemDropped >= 0 && itemDropped < ITEM00_MAX) {
|
||||
Item_DropCollectible(globalCtx, &this->dyna.actor.world.pos, itemDropped | (collectibleFlagTemp << 8));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ static InitChainEntry sInitChain[] = {
|
|||
void ObjTsubo_SpawnCollectible(ObjTsubo* this, GlobalContext* globalCtx) {
|
||||
s16 dropParams = this->actor.params & 0x1F;
|
||||
|
||||
if ((dropParams >= ITEM00_RUPEE_GREEN) && (dropParams <= ITEM00_BOMBS_SPECIAL)) {
|
||||
if ((dropParams >= 0) && (dropParams < ITEM00_MAX)) {
|
||||
Item_DropCollectible(globalCtx, &this->actor.world.pos,
|
||||
(dropParams | (((this->actor.params >> 9) & 0x3F) << 8)));
|
||||
}
|
||||
|
|
|
@ -493,7 +493,7 @@ void ObjectKankyo_DrawFairies(ObjectKankyo* this2, GlobalContext* globalCtx2) {
|
|||
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_object_kankyo.c", 807);
|
||||
POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x14);
|
||||
gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(gSun1Tex));
|
||||
gSPDisplayList(POLY_XLU_DISP++, gKokiriDustMoteTextureLoadDL);
|
||||
gSPDisplayList(POLY_XLU_DISP++, gKokiriDustMoteMaterialDL);
|
||||
|
||||
for (i = 0; i < globalCtx->envCtx.unk_EE[3]; i++) {
|
||||
Matrix_Translate(this->effects[i].base.x + this->effects[i].pos.x,
|
||||
|
@ -560,7 +560,7 @@ void ObjectKankyo_DrawFairies(ObjectKankyo* this2, GlobalContext* globalCtx2) {
|
|||
Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY);
|
||||
Matrix_RotateZ(DEG_TO_RAD(globalCtx->state.frames * 20.0f), MTXMODE_APPLY);
|
||||
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_object_kankyo.c", 913), G_MTX_LOAD);
|
||||
gSPDisplayList(POLY_XLU_DISP++, gKokiriDustMoteDL);
|
||||
gSPDisplayList(POLY_XLU_DISP++, gKokiriDustMoteModelDL);
|
||||
}
|
||||
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_object_kankyo.c", 922);
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ void func_80BADF0C(ShotSun* this, GlobalContext* globalCtx) {
|
|||
s32 pad;
|
||||
s32 params = this->actor.params & 0xFF;
|
||||
|
||||
if (Math3D_Vec3fDistSq(&this->actor.world.pos, &player->actor.world.pos) > 22500.0f) {
|
||||
if (Math3D_Vec3fDistSq(&this->actor.world.pos, &player->actor.world.pos) > SQ(150.0f)) {
|
||||
this->unk_1A4 = 0;
|
||||
} else {
|
||||
if (this->unk_1A4 == 0) {
|
||||
|
|
|
@ -6064,12 +6064,13 @@ static s32 D_80854598[] = {
|
|||
};
|
||||
|
||||
void func_8083E4C4(GlobalContext* globalCtx, Player* this, GetItemEntry* giEntry) {
|
||||
s32 sp1C = giEntry->field & 0x1F;
|
||||
s32 dropType = giEntry->field & 0x1F;
|
||||
|
||||
if (!(giEntry->field & 0x80)) {
|
||||
Item_DropCollectible(globalCtx, &this->actor.world.pos, sp1C | 0x8000);
|
||||
if ((sp1C != 4) && (sp1C != 8) && (sp1C != 9) && (sp1C != 0xA) && (sp1C != 0) && (sp1C != 1) && (sp1C != 2) &&
|
||||
(sp1C != 0x14) && (sp1C != 0x13)) {
|
||||
Item_DropCollectible(globalCtx, &this->actor.world.pos, dropType | 0x8000);
|
||||
if ((dropType != ITEM00_BOMBS_A) && (dropType != ITEM00_ARROWS_SMALL) && (dropType != ITEM00_ARROWS_MEDIUM) &&
|
||||
(dropType != ITEM00_ARROWS_LARGE) && (dropType != ITEM00_RUPEE_GREEN) && (dropType != ITEM00_RUPEE_BLUE) &&
|
||||
(dropType != ITEM00_RUPEE_RED) && (dropType != ITEM00_RUPEE_PURPLE) && (dropType != ITEM00_RUPEE_ORANGE)) {
|
||||
Item_Give(globalCtx, giEntry->itemId);
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue