Object Cleanup (#1410)

* object cleanup

* namefixer

* objectPtr

* PR Review

* PR Review

* more uses of macro

* missed another one
This commit is contained in:
engineer124
2023-10-06 07:37:52 +11:00
committed by GitHub
parent ac8d49ea6f
commit e810559391
117 changed files with 600 additions and 592 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
#include "global.h"
s16 gPlayerFormObjectIndices[PLAYER_FORM_MAX] = {
s16 gPlayerFormObjectIds[PLAYER_FORM_MAX] = {
OBJECT_LINK_BOY, // PLAYER_FORM_FIERCE_DEITY
OBJECT_LINK_GORON, // PLAYER_FORM_GORON
OBJECT_LINK_ZORA, // PLAYER_FORM_ZORA
+15 -14
View File
@@ -1096,7 +1096,7 @@ void Actor_SetScale(Actor* actor, f32 scale) {
}
void Actor_SetObjectDependency(PlayState* play, Actor* actor) {
gSegments[0x06] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[actor->objBankIndex].segment);
gSegments[0x06] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[actor->objectSlot].segment);
}
void Actor_Init(Actor* actor, PlayState* play) {
@@ -1119,7 +1119,7 @@ void Actor_Init(Actor* actor, PlayState* play) {
actor->floorBgId = BGCHECK_SCENE;
ActorShape_Init(&actor->shape, 0.0f, NULL, 0.0f);
if (Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) {
if (Object_IsLoaded(&play->objectCtx, actor->objectSlot)) {
Actor_SetObjectDependency(play, actor);
actor->init(actor, play);
actor->init = NULL;
@@ -2486,7 +2486,7 @@ Actor* Actor_UpdateActor(UpdateActor_Params* params) {
actor->audioFlags &= ~ACTOR_AUDIO_FLAG_ALL;
if (actor->init != NULL) {
if (Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) {
if (Object_IsLoaded(&play->objectCtx, actor->objectSlot)) {
Actor_SetObjectDependency(play, actor);
actor->init(actor, play);
actor->init = NULL;
@@ -2500,7 +2500,7 @@ Actor* Actor_UpdateActor(UpdateActor_Params* params) {
nextActor = actor->next;
}
} else {
if (!Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) {
if (!Object_IsLoaded(&play->objectCtx, actor->objectSlot)) {
Actor_Kill(actor);
} else if ((params->requiredActorFlag && !(actor->flags & params->requiredActorFlag)) ||
(((!params->requiredActorFlag) != 0) &&
@@ -2700,8 +2700,8 @@ void Actor_Draw(PlayState* play, Actor* actor) {
Matrix_Scale(actor->scale.x, actor->scale.y, actor->scale.z, MTXMODE_APPLY);
Actor_SetObjectDependency(play, actor);
gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.slots[actor->objBankIndex].segment);
gSPSegment(POLY_XLU_DISP++, 0x06, play->objectCtx.slots[actor->objBankIndex].segment);
gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.slots[actor->objectSlot].segment);
gSPSegment(POLY_XLU_DISP++, 0x06, play->objectCtx.slots[actor->objectSlot].segment);
if (actor->colorFilterTimer != 0) {
s32 colorFlag = COLORFILTER_GET_COLORFLAG(actor->colorFilterParams);
@@ -3055,7 +3055,7 @@ void Actor_KillAllWithMissingObject(PlayState* play, ActorContext* actorCtx) {
actor = actorCtx->actorLists[i].first;
while (actor != NULL) {
if (!Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) {
if (!Object_IsLoaded(&play->objectCtx, actor->objectSlot)) {
Actor_Kill(actor);
}
@@ -3287,7 +3287,7 @@ Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, PlayState* play, s1
s32 pad;
Actor* actor;
ActorInit* actorInit;
s32 objBankIndex;
s32 objectSlot;
ActorOverlay* overlayEntry;
if (actorCtx->totalLoadedActors >= 0xFF) {
@@ -3299,9 +3299,10 @@ Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, PlayState* play, s1
return NULL;
}
objBankIndex = Object_GetSlot(&play->objectCtx, actorInit->objectId);
if ((objBankIndex < 0) || ((actorInit->type == ACTORCAT_ENEMY) && Flags_GetClear(play, play->roomCtx.curRoom.num) &&
(actorInit->id != ACTOR_BOSS_05))) {
objectSlot = Object_GetSlot(&play->objectCtx, actorInit->objectId);
if ((objectSlot <= OBJECT_SLOT_NONE) ||
((actorInit->type == ACTORCAT_ENEMY) && Flags_GetClear(play, play->roomCtx.curRoom.num) &&
(actorInit->id != ACTOR_BOSS_05))) {
Actor_FreeOverlay(&gActorOverlayTable[index]);
return NULL;
}
@@ -3323,10 +3324,10 @@ Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, PlayState* play, s1
actor->flags = actorInit->flags;
if (actorInit->id == ACTOR_EN_PART) {
actor->objBankIndex = rotZ;
actor->objectSlot = rotZ;
rotZ = 0;
} else {
actor->objBankIndex = objBankIndex;
actor->objectSlot = objectSlot;
}
actor->init = actorInit->init;
@@ -3705,7 +3706,7 @@ void Actor_SpawnBodyParts(Actor* actor, PlayState* play, s32 partParams, Gfx** d
spawnedPart =
Actor_SpawnAsChild(&play->actorCtx, actor, play, ACTOR_EN_PART, currentMatrix->mf[3][0],
currentMatrix->mf[3][1], currentMatrix->mf[3][2], 0, 0, actor->objBankIndex, partParams);
currentMatrix->mf[3][1], currentMatrix->mf[3][2], 0, 0, actor->objectSlot, partParams);
if (spawnedPart != NULL) {
part = (EnPart*)spawnedPart;
+3 -3
View File
@@ -823,13 +823,13 @@ void GetItem_DrawWallet(PlayState* play, s16 drawId) {
void GetItem_DrawRemains(PlayState* play, s16 drawId) {
s32 pad;
s8 objectIndex;
s8 objectSlot;
OPEN_DISPS(play->state.gfxCtx);
objectIndex = Object_GetSlot(&play->objectCtx, OBJECT_BSMASK);
objectSlot = Object_GetSlot(&play->objectCtx, OBJECT_BSMASK);
gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.slots[objectIndex].segment);
gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.slots[objectSlot].segment);
Gfx_SetupDL25_Opa(play->state.gfxCtx);
Matrix_Scale(0.02f, 0.02f, 0.02f, MTXMODE_APPLY);
+9 -9
View File
@@ -41,7 +41,7 @@ void EffectSs_DrawGEffect(PlayState* play, EffectSs* this, TexturePtr texture) {
MtxF mfTrans11DA0;
s32 pad1;
Mtx* mtx;
void* object = play->objectCtx.slots[this->rgObjBankIndex].segment;
void* objectPtr = play->objectCtx.slots[this->rgObjectSlot].segment;
OPEN_DISPS(gfxCtx);
@@ -50,8 +50,8 @@ void EffectSs_DrawGEffect(PlayState* play, EffectSs* this, TexturePtr texture) {
SkinMatrix_SetScale(&mfScale, scale, scale, scale);
SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTrans11DA0);
SkinMatrix_MtxFMtxFMult(&mfTrans11DA0, &mfScale, &mfResult);
gSegments[0x06] = VIRTUAL_TO_PHYSICAL(object);
gSPSegment(POLY_XLU_DISP++, 0x06, object);
gSegments[0x06] = VIRTUAL_TO_PHYSICAL(objectPtr);
gSPSegment(POLY_XLU_DISP++, 0x06, objectPtr);
mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult);
@@ -542,7 +542,7 @@ void EffectSsDtBubble_SpawnCustomColor(PlayState* play, Vec3f* pos, Vec3f* veloc
* - due to how life is implemented it is capped at 200. Any value over 200 is accepted, but the fragment will
* only live for 200 frames
*/
void EffectSsHahen_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 flags, s16 scale, s16 objId,
void EffectSsHahen_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 flags, s16 scale, s16 objectId,
s16 life, Gfx* dList) {
EffectSsHahenInitParams initParams;
@@ -552,7 +552,7 @@ void EffectSsHahen_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* ac
initParams.dList = dList;
initParams.flags = flags;
initParams.scale = scale;
initParams.objId = objId;
initParams.objectId = objectId;
initParams.life = life;
EffectSs_Spawn(play, EFFECT_SS_HAHEN, 128, &initParams);
@@ -568,7 +568,7 @@ void EffectSsHahen_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* ac
* only live for 200 frames
*/
void EffectSsHahen_SpawnBurst(PlayState* play, Vec3f* pos, f32 burstScale, s16 flags, s16 scale, s16 randScaleRange,
s16 count, s16 objId, s16 life, Gfx* dList) {
s16 count, s16 objectId, s16 life, Gfx* dList) {
s32 i;
Vec3f velocity;
Vec3f accel;
@@ -581,7 +581,7 @@ void EffectSsHahen_SpawnBurst(PlayState* play, Vec3f* pos, f32 burstScale, s16 f
velocity.z = (Rand_ZeroOne() - 0.5f) * burstScale;
velocity.y = ((Rand_ZeroOne() * 0.5f) + 0.5f) * burstScale;
EffectSsHahen_Spawn(play, pos, &velocity, &accel, flags, Rand_S16Offset(scale, randScaleRange), objId, life,
EffectSsHahen_Spawn(play, pos, &velocity, &accel, flags, Rand_S16Offset(scale, randScaleRange), objectId, life,
dList);
}
}
@@ -719,7 +719,7 @@ void EffectSsSolderSrchBall_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity,
// EffectSsKakera Spawn Functions
void EffectSsKakera_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* arg3, s16 gravity, s16 arg5, s16 arg6,
s16 arg7, s16 arg8, s16 scale, s16 arg10, s16 arg11, s32 life, s16 colorIdx, s16 objId,
s16 arg7, s16 arg8, s16 scale, s16 arg10, s16 arg11, s32 life, s16 colorIdx, s16 objectId,
Gfx* dList) {
EffectSsKakeraInitParams initParams;
@@ -736,7 +736,7 @@ void EffectSsKakera_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* a
initParams.unk_32 = arg11;
initParams.life = life;
initParams.colorIdx = colorIdx;
initParams.objId = objId;
initParams.objectId = objectId;
initParams.dList = dList;
EffectSs_Spawn(play, EFFECT_SS_KAKERA, 101, &initParams);
+8 -8
View File
@@ -133,7 +133,7 @@ EnDoor* EnHy_FindNearestDoor(Actor* actor, PlayState* play) {
}
void EnHy_ChangeObjectAndAnim(EnHy* enHy, PlayState* play, s16 animIndex) {
gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[enHy->animObjIndex].segment);
gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[enHy->animObjectSlot].segment);
EnHy_ChangeAnim(&enHy->skelAnime, animIndex);
}
@@ -141,7 +141,7 @@ s32 EnHy_UpdateSkelAnime(EnHy* enHy, PlayState* play) {
s32 isUpdated = false;
if (enHy->actor.draw != NULL) {
gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[enHy->animObjIndex].segment);
gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[enHy->animObjectSlot].segment);
SkelAnime_Update(&enHy->skelAnime);
isUpdated = true;
}
@@ -161,14 +161,14 @@ void EnHy_Blink(EnHy* enHy, s32 eyeTexMaxIndex) {
s32 EnHy_Init(EnHy* enHy, PlayState* play, FlexSkeletonHeader* skeletonHeaderSeg, s16 animIndex) {
s32 isInitialized = false;
if ((SubS_IsObjectLoaded(enHy->animObjIndex, play) == true) &&
(SubS_IsObjectLoaded(enHy->headObjIndex, play) == true) &&
(SubS_IsObjectLoaded(enHy->skelUpperObjIndex, play) == true) &&
(SubS_IsObjectLoaded(enHy->skelLowerObjIndex, play) == true)) {
enHy->actor.objBankIndex = enHy->skelLowerObjIndex;
if ((SubS_IsObjectLoaded(enHy->animObjectSlot, play) == true) &&
(SubS_IsObjectLoaded(enHy->headObjectSlot, play) == true) &&
(SubS_IsObjectLoaded(enHy->skelUpperObjectSlot, play) == true) &&
(SubS_IsObjectLoaded(enHy->skelLowerObjectSlot, play) == true)) {
enHy->actor.objectSlot = enHy->skelLowerObjectSlot;
isInitialized = true;
ActorShape_Init(&enHy->actor.shape, 0.0f, NULL, 0.0f);
gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[enHy->actor.objBankIndex].segment);
gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[enHy->actor.objectSlot].segment);
SkelAnime_InitFlex(play, &enHy->skelAnime, skeletonHeaderSeg, NULL, enHy->jointTable, enHy->morphTable,
ENHY_LIMB_MAX);
EnHy_ChangeObjectAndAnim(enHy, play, animIndex);
+10 -10
View File
@@ -184,17 +184,17 @@ void EnItem00_Init(Actor* thisx, PlayState* play) {
break;
case ITEM00_SHIELD_HERO:
thisx->objBankIndex = Object_GetSlot(&play->objectCtx, OBJECT_GI_SHIELD_2);
thisx->objectSlot = Object_GetSlot(&play->objectCtx, OBJECT_GI_SHIELD_2);
EnItem00_SetObject(this, play, &shadowOffset, &shadowScale);
break;
case ITEM00_MAP:
thisx->objBankIndex = Object_GetSlot(&play->objectCtx, OBJECT_GI_MAP);
thisx->objectSlot = Object_GetSlot(&play->objectCtx, OBJECT_GI_MAP);
EnItem00_SetObject(this, play, &shadowOffset, &shadowScale);
break;
case ITEM00_COMPASS:
thisx->objBankIndex = Object_GetSlot(&play->objectCtx, OBJECT_GI_COMPASS);
thisx->objectSlot = Object_GetSlot(&play->objectCtx, OBJECT_GI_COMPASS);
EnItem00_SetObject(this, play, &shadowOffset, &shadowScale);
break;
@@ -317,10 +317,10 @@ void EnItem00_Destroy(Actor* thisx, PlayState* play) {
}
void EnItem00_WaitForHeartObject(EnItem00* this, PlayState* play) {
s32 objBankIndex = Object_GetSlot(&play->objectCtx, OBJECT_GI_HEARTS);
s32 objectSlot = Object_GetSlot(&play->objectCtx, OBJECT_GI_HEARTS);
if (Object_IsLoaded(&play->objectCtx, objBankIndex)) {
this->actor.objBankIndex = objBankIndex;
if (Object_IsLoaded(&play->objectCtx, objectSlot)) {
this->actor.objectSlot = objectSlot;
this->actionFunc = func_800A640C;
}
}
@@ -725,10 +725,10 @@ void EnItem00_Draw(Actor* thisx, PlayState* play) {
case ITEM00_RECOVERY_HEART:
if (this->unk152 < 0) {
if (this->unk152 == -1) {
s8 bankIndex = Object_GetSlot(&play->objectCtx, OBJECT_GI_HEART);
s8 objectSlot = Object_GetSlot(&play->objectCtx, OBJECT_GI_HEART);
if (Object_IsLoaded(&play->objectCtx, bankIndex)) {
this->actor.objBankIndex = bankIndex;
if (Object_IsLoaded(&play->objectCtx, objectSlot)) {
this->actor.objectSlot = objectSlot;
Actor_SetObjectDependency(play, &this->actor);
this->unk152 = -2;
}
@@ -852,7 +852,7 @@ void EnItem00_DrawSprite(EnItem00* this, PlayState* play) {
void EnItem00_DrawHeartContainer(EnItem00* this, PlayState* play) {
s32 pad[2];
if (Object_GetSlot(&play->objectCtx, OBJECT_GI_HEARTS) == this->actor.objBankIndex) {
if (Object_GetSlot(&play->objectCtx, OBJECT_GI_HEARTS) == this->actor.objectSlot) {
OPEN_DISPS(play->state.gfxCtx);
Gfx_SetupDL25_Xlu(play->state.gfxCtx);
+1 -1
View File
@@ -216,7 +216,7 @@ s32 Horse_IsActive(PlayState* play, ActorContext* actorCtx) {
if (bgActor != NULL) {
while (true) {
if ((bgActor->update != NULL) && (bgActor->init == NULL)) {
if (Object_IsLoaded(&play->objectCtx, bgActor->objBankIndex)) {
if (Object_IsLoaded(&play->objectCtx, bgActor->objectSlot)) {
if ((bgActor->id == ACTOR_EN_HORSE) && (((EnHorse*)bgActor)->action != ENHORSE_ACTION_INACTIVE)) {
return true;
}
+7 -7
View File
@@ -392,16 +392,16 @@ void func_8012301C(Actor* thisx, PlayState* play2) {
this->actionVar1++;
if (this->actionVar1 == 2) {
s16 objectId = gPlayerFormObjectIndices[GET_PLAYER_FORM];
s16 objectId = gPlayerFormObjectIds[GET_PLAYER_FORM];
gActorOverlayTable[ACTOR_PLAYER].initInfo->objectId = objectId;
func_8012F73C(&play->objectCtx, this->actor.objBankIndex, objectId);
this->actor.objBankIndex = Object_GetSlot(&play->objectCtx, GAMEPLAY_KEEP);
func_8012F73C(&play->objectCtx, this->actor.objectSlot, objectId);
this->actor.objectSlot = Object_GetSlot(&play->objectCtx, GAMEPLAY_KEEP);
} else if (this->actionVar1 >= 3) {
s32 objBankIndex = Object_GetSlot(&play->objectCtx, gActorOverlayTable[ACTOR_PLAYER].initInfo->objectId);
s32 objectSlot = Object_GetSlot(&play->objectCtx, gActorOverlayTable[ACTOR_PLAYER].initInfo->objectId);
if (Object_IsLoaded(&play->objectCtx, objBankIndex)) {
this->actor.objBankIndex = objBankIndex;
if (Object_IsLoaded(&play->objectCtx, objectSlot)) {
this->actor.objectSlot = objectSlot;
this->actor.shape.rot.z = GET_PLAYER_FORM + 1;
this->actor.init = PlayerCall_Init;
this->actor.update = PlayerCall_Update;
@@ -1869,7 +1869,7 @@ void Player_DrawHookshotReticle(PlayState* play, Player* player, f32 hookshotDis
gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPSegment(OVERLAY_DISP++, 0x06, play->objectCtx.slots[player->actor.objBankIndex].segment);
gSPSegment(OVERLAY_DISP++, 0x06, play->objectCtx.slots[player->actor.objectSlot].segment);
gSPDisplayList(OVERLAY_DISP++, gHookshotReticleDL);
CLOSE_DISPS(play->state.gfxCtx);
+4 -4
View File
@@ -157,7 +157,7 @@ void* func_8012F73C(ObjectContext* objectCtx, s32 slot, s16 id) {
void Scene_CommandSpawnList(PlayState* play, SceneCmd* cmd) {
s32 loadedCount;
s16 playerObjectId;
void* nextObject;
void* objectPtr;
play->linkActorEntry =
(ActorEntry*)Lib_SegmentedToVirtual(cmd->spawnList.segment) + play->setupEntranceList[play->curSpawn].spawn;
@@ -170,14 +170,14 @@ void Scene_CommandSpawnList(PlayState* play, SceneCmd* cmd) {
}
loadedCount = Object_SpawnPersistent(&play->objectCtx, OBJECT_LINK_CHILD);
nextObject = play->objectCtx.slots[play->objectCtx.numEntries].segment;
objectPtr = play->objectCtx.slots[play->objectCtx.numEntries].segment;
play->objectCtx.numEntries = loadedCount;
play->objectCtx.numPersistentEntries = loadedCount;
playerObjectId = gPlayerFormObjectIndices[GET_PLAYER_FORM];
playerObjectId = gPlayerFormObjectIds[GET_PLAYER_FORM];
gActorOverlayTable[0].initInfo->objectId = playerObjectId;
Object_SpawnPersistent(&play->objectCtx, playerObjectId);
play->objectCtx.slots[play->objectCtx.numEntries].segment = nextObject;
play->objectCtx.slots[play->objectCtx.numEntries].segment = objectPtr;
}
// SceneTableEntry Header Command 0x01: Actor List
+4 -4
View File
@@ -1169,12 +1169,12 @@ s16 SubS_GetDistSqAndOrientPath(Path* path, s32 pointIndex, Vec3f* pos, f32* dis
return Math_Atan2S(diffX, diffZ);
}
s8 SubS_IsObjectLoaded(s8 index, PlayState* play) {
return !Object_IsLoaded(&play->objectCtx, index) ? false : true;
s8 SubS_IsObjectLoaded(s8 objectSlot, PlayState* play) {
return !Object_IsLoaded(&play->objectCtx, objectSlot) ? false : true;
}
s8 SubS_GetObjectIndex(s16 id, PlayState* play) {
return Object_GetSlot(&play->objectCtx, id);
s8 SubS_GetObjectSlot(s16 objectId, PlayState* play) {
return Object_GetSlot(&play->objectCtx, objectId);
}
/**