diff --git a/include/Map/MapBase.hpp b/include/Map/MapBase.hpp index a99658ac..ecf92c08 100644 --- a/include/Map/MapBase.hpp +++ b/include/Map/MapBase.hpp @@ -112,7 +112,7 @@ public: /* 188 */ unk8 mUnk_188[0x14]; /* 19c */ unk32 mUnk_19c; /* 1a0 */ Vec3p mUnk_1a0; - /* 1ac */ unk32 mUnk_1ac; + /* 1ac */ s16 mUnk_1ac; /* 1b0 */ /* 00 */ virtual ~MapBase(); diff --git a/include/Player/PlayerBase.hpp b/include/Player/PlayerBase.hpp index f7caf604..ba4b3deb 100644 --- a/include/Player/PlayerBase.hpp +++ b/include/Player/PlayerBase.hpp @@ -62,6 +62,6 @@ public: }; extern PlayerBase *gPlayer; -extern Vec3p *gPlayerPos; +extern Vec3p gPlayerPos; extern Vec3p gPlayerVel; extern s16 gPlayerAngle; diff --git a/src/00_Core/Actor/Actor.cpp b/src/00_Core/Actor/Actor.cpp index b865c39e..2cbed755 100644 --- a/src/00_Core/Actor/Actor.cpp +++ b/src/00_Core/Actor/Actor.cpp @@ -342,7 +342,7 @@ ARM bool Actor::vfunc_4c(unk32 *param1) { } ARM bool Actor::IsNearLink() { - Vec3p playerPos = *gPlayerPos; + Vec3p playerPos = gPlayerPos; q20 z = playerPos.z; q20 dx = abs(playerPos.x - mPos.x); @@ -375,7 +375,7 @@ ARM bool Actor::func_ov00_020c1da0(s32 param1, Vec3p *param2) { if (param2) { vec = *param2; } else { - Vec3p_Sub(gPlayerPos, &mPrevPos, &vec); + Vec3p_Sub(&gPlayerPos, &mPrevPos, &vec); } return gPlayer->vfunc_30(mUnk_124, &vec, param1); @@ -389,7 +389,7 @@ ARM bool Actor::func_ov00_020c1e2c(s32 param1, Vec3p *param2) { if (param2) { vec = *param2; } else { - Vec3p_Sub(gPlayerPos, &mPrevPos, &vec); + Vec3p_Sub(&gPlayerPos, &mPrevPos, &vec); } Cylinder hitbox; @@ -421,7 +421,7 @@ ARM bool Actor::func_ov00_020c1fc8(PlayerCollide flags) { bool result = false; if (mHitbox.size >= 0) { Vec3p vecFromPlayer; - Vec3p_Sub(&mPos, gPlayerPos, &vecFromPlayer); + Vec3p_Sub(&mPos, &gPlayerPos, &vecFromPlayer); if (this->CollidesWithPlayer(flags & PlayerCollide_Sword)) { Knockback knockback; knockback.mUnk_00 = gPlayer->EquipItem_vfunc_2c(); @@ -469,7 +469,7 @@ ARM bool Actor::func_ov00_020c1fc8(PlayerCollide flags) { ARM bool Actor::CollidesWithShield(Cylinder *param1) { Vec3p vecFromPlayer; - Vec3p_Sub(&mPos, gPlayerPos, &vecFromPlayer); + Vec3p_Sub(&mPos, &gPlayerPos, &vecFromPlayer); s32 currAngle = gPlayerAngle; s32 angle = Atan2(vecFromPlayer.x, vecFromPlayer.z); s32 angleDiff = (s16) angle - currAngle; @@ -641,13 +641,13 @@ ARM q20 Actor::XzDistanceTo(Vec3p *vec) { } ARM q20 Actor::DistanceToLink() { - return Vec3p_Distance(&mPos, gPlayerPos); + return Vec3p_Distance(&mPos, &gPlayerPos); } ARM q20 Actor::XzDistanceToLink() { Vec3p src; Vec3p_CopyXZ(&mPos, &src); - Vec3p dest = *gPlayerPos; + Vec3p dest = gPlayerPos; dest.y = 0; return Vec3p_Distance(&src, &dest); @@ -665,7 +665,7 @@ ARM s16 Actor::GetAngleTo(Vec3p *vec) { } ARM s32 Actor::GetAngleToLink() { - return this->GetAngleTo(gPlayerPos); + return this->GetAngleTo(&gPlayerPos); } extern "C" void func_0202d95c(Vec3p *param1, q20 param2); @@ -745,7 +745,7 @@ ARM bool Actor::func_ov00_020c2c70() { this->GetLinkPos(&pos); Vec3p_Sub(&pos, &mPos, &vel); } else { - Vec3p_Sub(gPlayerPos, &mPos, &vel); + Vec3p_Sub(&gPlayerPos, &mPos, &vel); } } Vec3p_Add(&mPos, &vel, &mPos); @@ -787,7 +787,7 @@ ARM bool Actor::func_ov00_020c2de4() { func_0202d95c(&vel, FLOAT_TO_Q20(1.0)); } } else { - Vec3p_Sub(gPlayerPos, &mPos, &vel); + Vec3p_Sub(&gPlayerPos, &mPos, &vel); } Vec3p_Add(&mPos, &vel, &mPos); mVel = vel; @@ -937,7 +937,7 @@ ARM void Actor::GetLinkPos(Vec3p *result) { if (gPlayerLink != NULL && gPlayerLink->GetCurrentCharacter() != PlayerCharacter_Link) { return this->GetLinkDummyPos(result); } - result = gPlayerPos; + result = &gPlayerPos; } ARM void Actor::GetLinkDummyPos(Vec3p *result) { @@ -948,7 +948,7 @@ ARM void Actor::GetLinkDummyPos(Vec3p *result) { *result = dummy->mPos; return; } - result = gPlayerPos; + result = &gPlayerPos; } Actor_UnkStruct_09c::Actor_UnkStruct_09c() { diff --git a/src/00_Core/Map/MapManager.cpp b/src/00_Core/Map/MapManager.cpp index 15de64f6..e7e826f6 100644 --- a/src/00_Core/Map/MapManager.cpp +++ b/src/00_Core/Map/MapManager.cpp @@ -244,25 +244,21 @@ ARM bool MapManager::func_ov00_020824cc(s32 param_2) { ARM s32 MapManager::func_ov00_02082504() { s32 var = this->mMap->vfunc_4c(); - if (var == 2) { - return (s32) this->mMap->mUnk_1ac; - } + if (var == 2) return this->mMap->mUnk_1ac; return 0; } ARM Vec3p *MapManager::func_ov00_02082538() { s32 var1 = this->mMap->vfunc_4c(); Vec3p var0; - if (var1 != 2) { - q20 x = gPlayerPos->x; - q20 y = gPlayerPos->y; - var0.x = x; - var0.y = y; - q20 z = gPlayerPos->z; - var0.z = z; - return &var0; - } - return &this->mMap->mUnk_1a0; + if (var1 == 2) return &this->mMap->mUnk_1a0; + q20 x = gPlayerPos.x; + q20 y = gPlayerPos.y; + var0.x = x; + var0.y = y; + q20 z = gPlayerPos.z; + var0.z = z; + return &var0; } ARM void MapManager::func_ov00_02082594() { @@ -674,9 +670,9 @@ ARM void MapManager::func_ov00_0208306c(s32 *param_2, s32 *param_3) { *param_3 = this->mCourse->mUnk_0b8; return; } - local_1c.y = gPlayerPos->y; - local_1c.x = gPlayerPos->x; - local_1c.z = gPlayerPos->z; + local_1c.y = gPlayerPos.y; + local_1c.x = gPlayerPos.x; + local_1c.z = gPlayerPos.z; // this->func_ov00_02083a1c(auStack_2c, this, &local_1c); this->func_ov00_02082d84(auStack_2c, param_2, param_3); } @@ -710,9 +706,9 @@ ARM void MapManager::func_ov00_0208315c(s32 *param_2, s32 *param_3) { *param_3 = this->mCourse->mUnk_0c0; return; } - local_20.x = *(s32 *) gPlayerPos->x; - local_20.y = *(s32 *) gPlayerPos->y; - local_20.z = *(s32 *) gPlayerPos->z; + local_20.x = *(s32 *) gPlayerPos.x; + local_20.y = *(s32 *) gPlayerPos.y; + local_20.z = *(s32 *) gPlayerPos.z; uVar1 = this->func_ov00_02082d08(); this->func_ov00_02083298(uVar1, &local_20, param_2, param_3); } @@ -960,10 +956,10 @@ ARM bool MapManager::func_ov00_020836dc(u32 type, u32 actorId) { switch (actorId) { case 0: case 1: - q20 y = gPlayerPos->y; - playerPos.x = gPlayerPos->x; + q20 y = gPlayerPos.y; + playerPos.x = gPlayerPos.x; playerPos.y = y; - playerPos.z = gPlayerPos->z; + playerPos.z = gPlayerPos.z; break; default: actor = gActorManager->FindActorById(actorId); @@ -1669,9 +1665,9 @@ unk8 MapManager::func_ov00_02084740() { // iVar2 = this->func_ov00_02084700(?); // what param? // iVar3 = UnkStruct_027e0d38::FUN_overlay_d_0__02078b40(*(UnkStruct_027e0d38 **) PTR_PTR_overlay_d_0__020847d4); if (iVar3 != 2) { - local_1c8 = *(unk32 *) gPlayerPos->x; - local_1c4 = *(unk32 *) gPlayerPos->y; - local_1c0 = *(unk32 *) gPlayerPos->z; + local_1c8 = *(unk32 *) gPlayerPos.x; + local_1c4 = *(unk32 *) gPlayerPos.y; + local_1c0 = *(unk32 *) gPlayerPos.z; // bVar1 = FUN_overlay_d_0__02083780(&local_1c8); // MapManager method? if (bVar1) { iVar2 = this->func_ov00_020847f0(); @@ -2505,7 +2501,7 @@ unk8 MapManager::func_ov00_020858b0(MapManager *param_1, Vec3p *param_2, s32 par iVar3 = param_1->GetMapHeight(); local_38 = 0xffffffff; param_1->func_ov00_02083a1c(&local_28, param_1, param_2); - iVar6 = gPlayerPos->y; // *(int *) (PTR_gPlayerPos_overlay_d_0__02085a30 + 4); + iVar6 = gPlayerPos.y; // *(int *) (PTR_gPlayerPos_overlay_d_0__02085a30 + 4); for (iVar7 = local_28.x - 1; iVar7 <= (int) (local_28.x + 1); iVar7 = iVar7 + 1) { if ((-1 < iVar7) && (iVar1 = local_28.y - 1, iVar7 < iVar2)) { for (; iVar1 <= (int) (local_28.y + 1); iVar1 = iVar1 + 1) {