summaryrefslogtreecommitdiff
path: root/src/code/z_actor.c
diff options
context:
space:
mode:
authorDragorn421 <Dragorn421@users.noreply.github.com>2023-09-19 20:10:12 +0200
committerGitHub <noreply@github.com>2023-09-19 14:10:12 -0400
commit57ce0cf8d9827e1c88013a318f35e9677167d900 (patch)
treecf14ca95e1bbc834c97addf553ef903ad946d5ad /src/code/z_actor.c
parent83a13a64c710e8a0e418ec469c2550ebfb9ca345 (diff)
Doc/Cleanup pass on object handling (#1227)
* `Object_InitBank` -> `Object_InitContext` * Add and use `OBJECT_SPACE_SIZE_BASE` * Remove `OBJECT_EXCHANGE_BANK_MAX` -> use `ARRAY_COUNT()` instead * "object status" -> "object load entry" * Misc. cleanup/renames * Partial docs and way too much batch renaming and cleanup for a single commit * ctrl shift h * format * format clang-11.1 * fix regressions * Improve a `@bug` comment * Move `OBJECT_SPACE_SIZE_BASE` from header to near `Object_InitContext` * "objectID" -> "objectId" * Revert iterator index to `i` in `Actor_KillActorsWithUnloadedObject` * "object load entry index" -> "object entry" * `Object_UpdateLoadEntries` -> `Object_UpdateEntries` * Run format.sh * "object entry" -> "object slot" (except internal usage) * Proper `Object_SpawnPersistent` doc Co-authored-by: fig02 <fig02srl@gmail.com> * fixup one comment "object bank index" -> "object slot" * Amend `Object_SpawnPersistent` comment to mention running out of free slots * `Actor_KillActorsWithUnloadedObject` -> `Actor_KillAllWithMissingObject` * Remove useless mention of what uses `Object_SpawnPersistent` * Fix mistake on `Object_SpawnPersistent` doing sync dma, not async * run formatter * `Object_InitContext` -> `Object_Init` * `waitObjectSlot` -> `requiredObjectSlot` * `Object_Init` -> `func_80097DD8` * one objectIndex -> objectSlot * Remove `OBJECT_SPACE_SIZE_BASE` * light fix on the merge (rm OBJECT_EXCHANGE_BANK_MAX) * `func_80097DD8` -> `Object_InitContext` --------- Co-authored-by: fig02 <fig02srl@gmail.com>
Diffstat (limited to 'src/code/z_actor.c')
-rw-r--r--src/code/z_actor.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/src/code/z_actor.c b/src/code/z_actor.c
index aa1f16291..4ef0bf10f 100644
--- a/src/code/z_actor.c
+++ b/src/code/z_actor.c
@@ -799,7 +799,7 @@ void Actor_SetScale(Actor* actor, f32 scale) {
}
void Actor_SetObjectDependency(PlayState* play, Actor* actor) {
- gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[actor->objBankIndex].segment);
+ gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[actor->objectSlot].segment);
}
void Actor_Init(Actor* actor, PlayState* play) {
@@ -818,7 +818,7 @@ void Actor_Init(Actor* actor, PlayState* play) {
CollisionCheck_InitInfo(&actor->colChkInfo);
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;
@@ -2143,13 +2143,13 @@ void Actor_UpdateAll(PlayState* play, ActorContext* actorCtx) {
actor->sfx = 0;
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;
}
actor = actor->next;
- } else if (!Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) {
+ } else if (!Object_IsLoaded(&play->objectCtx, actor->objectSlot)) {
Actor_Kill(actor);
actor = actor->next;
} else if ((requiredActorFlag && !(actor->flags & requiredActorFlag)) ||
@@ -2272,8 +2272,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.status[actor->objBankIndex].segment);
- gSPSegment(POLY_XLU_DISP++, 0x06, play->objectCtx.status[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) {
Color_RGBA8 color = { 0, 0, 0, 255 };
@@ -2570,7 +2570,7 @@ void Actor_KillAllWithMissingObject(PlayState* play, ActorContext* actorCtx) {
for (i = 0; i < ARRAY_COUNT(actorCtx->actorLists); i++) {
actor = actorCtx->actorLists[i].head;
while (actor != NULL) {
- if (!Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) {
+ if (!Object_IsLoaded(&play->objectCtx, actor->objectSlot)) {
Actor_Kill(actor);
}
actor = actor->next;
@@ -2745,7 +2745,7 @@ Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 pos
s32 pad;
Actor* actor;
ActorInit* actorInit;
- s32 objBankIndex;
+ s32 objectSlot;
ActorOverlay* overlayEntry;
uintptr_t temp;
char* name;
@@ -2828,13 +2828,13 @@ Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 pos
: NULL);
}
- objBankIndex = Object_GetIndex(&play->objectCtx, actorInit->objectId);
+ objectSlot = Object_GetSlot(&play->objectCtx, actorInit->objectId);
- if ((objBankIndex < 0) ||
+ if ((objectSlot < 0) ||
((actorInit->category == ACTORCAT_ENEMY) && Flags_GetClear(play, play->roomCtx.curRoom.num))) {
// "No data bank!! <data bank=%d> (profilep->bank=%d)"
osSyncPrintf(VT_COL(RED, WHITE) "データバンク無し!!<データバンク=%d>(profilep->bank=%d)\n" VT_RST,
- objBankIndex, actorInit->objectId);
+ objectSlot, actorInit->objectId);
Actor_FreeOverlay(overlayEntry);
return NULL;
}
@@ -2864,10 +2864,10 @@ Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 pos
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;
@@ -3155,7 +3155,7 @@ s16 func_80032D60(s16* arg0, s16 arg1, s16 arg2, s16 arg3) {
void BodyBreak_Alloc(BodyBreak* bodyBreak, s32 count, PlayState* play) {
u32 matricesSize;
u32 dListsSize;
- u32 objectIdsSize;
+ u32 objectSlotsSize;
matricesSize = (count + 1) * sizeof(*bodyBreak->matrices);
bodyBreak->matrices = ZeldaArena_MallocDebug(matricesSize, "../z_actor.c", 7540);
@@ -3165,13 +3165,13 @@ void BodyBreak_Alloc(BodyBreak* bodyBreak, s32 count, PlayState* play) {
bodyBreak->dLists = ZeldaArena_MallocDebug(dListsSize, "../z_actor.c", 7543);
if (bodyBreak->dLists != NULL) {
- objectIdsSize = (count + 1) * sizeof(*bodyBreak->objectIds);
- bodyBreak->objectIds = ZeldaArena_MallocDebug(objectIdsSize, "../z_actor.c", 7546);
+ objectSlotsSize = (count + 1) * sizeof(*bodyBreak->objectSlots);
+ bodyBreak->objectSlots = ZeldaArena_MallocDebug(objectSlotsSize, "../z_actor.c", 7546);
- if (bodyBreak->objectIds != NULL) {
+ if (bodyBreak->objectSlots != NULL) {
Lib_MemSet((u8*)bodyBreak->matrices, matricesSize, 0);
Lib_MemSet((u8*)bodyBreak->dLists, dListsSize, 0);
- Lib_MemSet((u8*)bodyBreak->objectIds, objectIdsSize, 0);
+ Lib_MemSet((u8*)bodyBreak->objectSlots, objectSlotsSize, 0);
bodyBreak->val = 1;
return;
}
@@ -3186,20 +3186,20 @@ void BodyBreak_Alloc(BodyBreak* bodyBreak, s32 count, PlayState* play) {
ZeldaArena_FreeDebug(bodyBreak->dLists, "../z_actor.c", 7561);
}
- if (bodyBreak->objectIds != NULL) {
- ZeldaArena_FreeDebug(bodyBreak->objectIds, "../z_actor.c", 7564);
+ if (bodyBreak->objectSlots != NULL) {
+ ZeldaArena_FreeDebug(bodyBreak->objectSlots, "../z_actor.c", 7564);
}
}
void BodyBreak_SetInfo(BodyBreak* bodyBreak, s32 limbIndex, s32 minLimbIndex, s32 maxLimbIndex, u32 count, Gfx** dList,
- s16 objectId) {
+ s16 objectSlot) {
PlayState* play = Effect_GetPlayState();
if ((play->actorCtx.freezeFlashTimer == 0) && (bodyBreak->val > 0)) {
if ((limbIndex >= minLimbIndex) && (limbIndex <= maxLimbIndex) && (*dList != NULL)) {
bodyBreak->dLists[bodyBreak->val] = *dList;
Matrix_Get(&bodyBreak->matrices[bodyBreak->val]);
- bodyBreak->objectIds[bodyBreak->val] = objectId;
+ bodyBreak->objectSlots[bodyBreak->val] = objectSlot;
bodyBreak->val++;
}
@@ -3219,7 +3219,7 @@ void BodyBreak_SetInfo(BodyBreak* bodyBreak, s32 limbIndex, s32 minLimbIndex, s3
s32 BodyBreak_SpawnParts(Actor* actor, BodyBreak* bodyBreak, PlayState* play, s16 type) {
EnPart* spawnedEnPart;
MtxF* mtx;
- s16 objBankIndex;
+ s16 objectSlot;
if (bodyBreak->val != BODYBREAK_STATUS_READY) {
return false;
@@ -3231,17 +3231,17 @@ s32 BodyBreak_SpawnParts(Actor* actor, BodyBreak* bodyBreak, PlayState* play, s1
Matrix_Get(&bodyBreak->matrices[bodyBreak->count]);
if (1) {
- if (bodyBreak->objectIds[bodyBreak->count] >= 0) {
- objBankIndex = bodyBreak->objectIds[bodyBreak->count];
+ if (bodyBreak->objectSlots[bodyBreak->count] > BODYBREAK_OBJECT_SLOT_DEFAULT) {
+ objectSlot = bodyBreak->objectSlots[bodyBreak->count];
} else {
- objBankIndex = actor->objBankIndex;
+ objectSlot = actor->objectSlot;
}
}
mtx = &bodyBreak->matrices[bodyBreak->count];
spawnedEnPart = (EnPart*)Actor_SpawnAsChild(&play->actorCtx, actor, play, ACTOR_EN_PART, mtx->xw, mtx->yw,
- mtx->zw, 0, 0, objBankIndex, type);
+ mtx->zw, 0, 0, objectSlot, type);
if (spawnedEnPart != NULL) {
Matrix_MtxFToYXZRotS(&bodyBreak->matrices[bodyBreak->count], &spawnedEnPart->actor.shape.rot, 0);
@@ -3256,7 +3256,7 @@ s32 BodyBreak_SpawnParts(Actor* actor, BodyBreak* bodyBreak, PlayState* play, s1
ZeldaArena_FreeDebug(bodyBreak->matrices, "../z_actor.c", 7678);
ZeldaArena_FreeDebug(bodyBreak->dLists, "../z_actor.c", 7679);
- ZeldaArena_FreeDebug(bodyBreak->objectIds, "../z_actor.c", 7680);
+ ZeldaArena_FreeDebug(bodyBreak->objectSlots, "../z_actor.c", 7680);
return true;
}
@@ -4329,7 +4329,7 @@ Actor* func_800358DC(Actor* actor, Vec3f* spawnPos, Vec3s* spawnRot, f32* arg3,
EnPart* spawnedEnPart;
spawnedEnPart = (EnPart*)Actor_SpawnAsChild(&play->actorCtx, actor, play, ACTOR_EN_PART, spawnPos->x, spawnPos->y,
- spawnPos->z, spawnRot->x, spawnRot->y, actor->objBankIndex, params);
+ spawnPos->z, spawnRot->x, spawnRot->y, actor->objectSlot, params);
if (spawnedEnPart != NULL) {
spawnedEnPart->actor.scale = actor->scale;
spawnedEnPart->actor.speed = arg3[0];