Skip to content

Commit

Permalink
Actor cleanup (#32)
Browse files Browse the repository at this point in the history
* Actor cleanup

---------

Co-authored-by: elijah-thomas774 <[email protected]>
  • Loading branch information
robojumper and elijah-thomas774 authored Sep 15, 2024
1 parent 732a119 commit 508d5b9
Show file tree
Hide file tree
Showing 26 changed files with 80 additions and 93 deletions.
4 changes: 3 additions & 1 deletion include/d/a/obj/d_a_obj_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ class dAcObjBase_c : public dAcBase_c {
};

// Actors' createHeap functions often have patterns that can be matched with this macro
#define TRY_CREATE(thing) do { bool result = (thing); if (!result) return result; } while (0);
#define TRY_CREATE(thing) do { bool result = (thing); if (!result) return result; } while (0)

#define CREATE_ALLOCATOR(className) do { if (!initAllocatorWork1Heap(-1, #className "::m_allocator", 0x20)) { return FAILED; } } while (0)

#endif
2 changes: 1 addition & 1 deletion include/m/m3d/m_shadow.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class mShadow_c : public proc_c {
void draw(const mMtx_c &, u32);
void afterDraw();

EGG::FrmHeap *changeHeap(int index) {
void changeHeap(int index) {
mCurrentHeapIdx = index % 2;
mpCurrentHeap = mpFrmHeaps[mCurrentHeapIdx];
}
Expand Down
10 changes: 5 additions & 5 deletions src/REL/d/a/d_a_t_wood_area.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ int dAcTWoodArea_c::actorCreate() {
PSMTXTrans(worldMatrix.m, position.x, position.y, position.z);
boundingBox.min = mVec3_c(-0.0f, -0.0f, -0.0f);
boundingBox.max = mVec3_c(0.0f, 0.0f, 0.0f);
return 1;
return SUCCEEDED;
}

static const ProfileName FILTER_PROFILE[] = {
Expand All @@ -28,20 +28,20 @@ int dAcTWoodArea_c::actorPostCreate() {
for (u32 i = 0; i < 5; i++) {
attachCloseObjects(FILTER_PROFILE[i]);
}
return 1;
return SUCCEEDED;
}

int dAcTWoodArea_c::doDelete() {
return 1;
return SUCCEEDED;
}

int dAcTWoodArea_c::actorExecute() {
mStateMgr.executeState();
return 1;
return SUCCEEDED;
}

int dAcTWoodArea_c::draw() {
return 1;
return SUCCEEDED;
}

void dAcTWoodArea_c::initializeState_Init() {}
Expand Down
12 changes: 5 additions & 7 deletions src/REL/d/a/e/d_a_e_hb_leaf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ bool dAcEhb_leaf_c::createHeap() {
}

int dAcEhb_leaf_c::create() {
if (!initAllocatorWork1Heap(-1, "dAcEhb_leaf_c::m_allocator", 0x20)) {
return FAILED;
}
CREATE_ALLOCATOR(dAcEhb_leaf_c);

setBoundingBox(mVec3_c(-100.0f, -100.0f, -100.0f), mVec3_c(100.0f, 100.0f, 100.0f));

Expand Down Expand Up @@ -72,14 +70,14 @@ int dAcEhb_leaf_c::create() {
}

int dAcEhb_leaf_c::doDelete() {
return 1;
return SUCCEEDED;
}

int dAcEhb_leaf_c::actorExecute() {
if (mType != 0) {
doCheck();
if (isNearZero()) {
return 1;
return SUCCEEDED;
}
}

Expand All @@ -93,15 +91,15 @@ int dAcEhb_leaf_c::actorExecute() {
mModel.getModel().calc(false);
someRot++;

return 1;
return SUCCEEDED;
}

int dAcEhb_leaf_c::draw() {
if (!isHidden()) {
drawModelType1(&mModel.getModel());
}

return 1;
return SUCCEEDED;
}

void dAcEhb_leaf_c::setAnm(const char *anm, f32 pos) {
Expand Down
10 changes: 4 additions & 6 deletions src/REL/d/a/obj/d_a_obj_junk_repairing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ bool dAcOJunkRep_c::createHeap() {
}

int dAcOJunkRep_c::create() {
if (!initAllocatorWork1Heap(-1, "dAcOJunkRep_c::m_allocator", 0x20)) {
return FAILED;
}
CREATE_ALLOCATOR(dAcOJunkRep_c);

forwardAccel = -1.0f;
forwardMaxSpeed = -40.0f;
Expand All @@ -48,21 +46,21 @@ int dAcOJunkRep_c::create() {
}

int dAcOJunkRep_c::doDelete() {
return 1;
return SUCCEEDED;
}

int dAcOJunkRep_c::actorExecute() {
mStateMgr.executeState();
updateMatrix();
mpModelToUse->setLocalMtx(worldMatrix);
return 1;
return SUCCEEDED;
}

int dAcOJunkRep_c::draw() {
drawModelType1(mpModelToUse);
static mQuat_c rot(0.0f, 37.5f, 0.0f, 75.0f);
fn_8002edb0(mShadow, *mpModelToUse, &rot, -1, -1, sSomeFloat);
return 1;
return SUCCEEDED;
}

void dAcOJunkRep_c::realizeState() {
Expand Down
10 changes: 4 additions & 6 deletions src/REL/d/a/obj/d_a_obj_lava_F200.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ bool dAcOlavaF200_c::createHeap() {
}

int dAcOlavaF200_c::create() {
if (!initAllocatorWork1Heap(-1, "dAcOlavaF200_c::m_allocator", 0x20)) {
return FAILED;
}
CREATE_ALLOCATOR(dAcOlavaF200_c);

mModels[0].setAnm(mTexAnms[0]);
mModels[1].setAnm(mTexAnms[1]);
Expand All @@ -47,20 +45,20 @@ int dAcOlavaF200_c::create() {
}

int dAcOlavaF200_c::doDelete() {
return 1;
return SUCCEEDED;
}

int dAcOlavaF200_c::actorExecute() {
mTexAnms[0].play();
mTexAnms[1].play();
mClrAnms[0].play();
mClrAnms[1].play();
return 1;
return SUCCEEDED;
}

int dAcOlavaF200_c::draw() {
for (int i = 0; i < 2; i++) {
drawModelType1(&mModels[i]);
}
return 1;
return SUCCEEDED;
}
10 changes: 4 additions & 6 deletions src/REL/d/a/obj/d_a_obj_mole_soil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ bool intToBool(int a) {
}

int dAcOmoleSoil_c::create() {
if (!initAllocatorWork1Heap(-1, "dAcOmoleSoil_c::m_allocator", 0x20)) {
return FAILED;
}
CREATE_ALLOCATOR(dAcOmoleSoil_c);

mScale = sHalfScale;
scale.set(sHalfScale, sHalfScale, sHalfScale);
Expand All @@ -40,7 +38,7 @@ int dAcOmoleSoil_c::create() {
}

int dAcOmoleSoil_c::doDelete() {
return 1;
return SUCCEEDED;
}

int dAcOmoleSoil_c::actorExecute() {
Expand All @@ -64,14 +62,14 @@ int dAcOmoleSoil_c::actorExecute() {
mStateMgr.executeState();
updateMatrix();
mModel.setLocalMtx(worldMatrix);
return 1;
return SUCCEEDED;
}

int dAcOmoleSoil_c::draw() {
if (field_0x391) {
drawModelType1(&mModel);
}
return 1;
return SUCCEEDED;
}

void dAcOmoleSoil_c::initializeState_Wait() {
Expand Down
10 changes: 4 additions & 6 deletions src/REL/d/a/obj/d_a_obj_ring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ bool dAcOring_c::createHeap() {
}

int dAcOring_c::create() {
if (!initAllocatorWork1Heap(-1, "dAcOring_c::m_allocator", 0x20)) {
return FAILED;
}
CREATE_ALLOCATOR(dAcOring_c);

field_0x388 = getArgFromParams();

Expand All @@ -32,7 +30,7 @@ int dAcOring_c::create() {
}

int dAcOring_c::doDelete() {
return 1;
return SUCCEEDED;
}

int dAcOring_c::actorExecute() {
Expand All @@ -42,12 +40,12 @@ int dAcOring_c::actorExecute() {
position += posIncrements;
updateMatrix();
mModel.setLocalMtx(worldMatrix);
return 1;
return SUCCEEDED;
}

int dAcOring_c::draw() {
drawModelType1(&mModel);
return 1;
return SUCCEEDED;
}

void dAcOring_c::initializeState_Move() {}
Expand Down
10 changes: 4 additions & 6 deletions src/REL/d/a/obj/d_a_obj_smoke.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ bool dAcOsmoke_c::createHeap() {
}

int dAcOsmoke_c::create() {
if (!initAllocatorWork1Heap(-1, "dAcOsmoke_c::m_allocator", 0x20)) {
return FAILED;
}
CREATE_ALLOCATOR(dAcOsmoke_c);

mModel.setAnm(mTexAnm);
updateMatrix();
Expand All @@ -39,18 +37,18 @@ int dAcOsmoke_c::create() {
}

int dAcOsmoke_c::doDelete() {
return 1;
return SUCCEEDED;
}

int dAcOsmoke_c::actorExecute() {
mStateMgr.executeState();
mTexAnm.play();
return 1;
return SUCCEEDED;
}

int dAcOsmoke_c::draw() {
drawModelType1(&mModel);
return 1;
return SUCCEEDED;
}

void dAcOsmoke_c::initializeState_Wait() {}
Expand Down
10 changes: 4 additions & 6 deletions src/REL/d/a/obj/d_a_obj_sun_light.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ bool dAcOsunLight_c::createHeap() {
}

int dAcOsunLight_c::create() {
if (!initAllocatorWork1Heap(-1, "dAcOsunLight_c::m_allocator", 0x20)) {
return FAILED;
}
CREATE_ALLOCATOR(dAcOsunLight_c);

mModel.setAnm(mTexAnm);
mStateMgr.changeState(StateID_Wait);
Expand All @@ -31,7 +29,7 @@ int dAcOsunLight_c::create() {
}

int dAcOsunLight_c::doDelete() {
return 1;
return SUCCEEDED;
}

int dAcOsunLight_c::actorExecute() {
Expand All @@ -41,14 +39,14 @@ int dAcOsunLight_c::actorExecute() {
}
updateMatrix();
mModel.setLocalMtx(worldMatrix);
return 1;
return SUCCEEDED;
}

int dAcOsunLight_c::draw() {
if (isDay()) {
drawModelType1(&mModel);
}
return 1;
return SUCCEEDED;
}

void dAcOsunLight_c::initializeState_Wait() {}
Expand Down
6 changes: 3 additions & 3 deletions src/REL/d/t/d_t_dowsing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ int dTgDowsing_c::create() {
}

int dTgDowsing_c::doDelete() {
return 1;
return SUCCEEDED;
}

int dTgDowsing_c::actorExecute() {
Expand All @@ -37,11 +37,11 @@ int dTgDowsing_c::actorExecute() {
mDowsingTarget.doRegister();
mTargetActive = true;
}
return 1;
return SUCCEEDED;
}

int dTgDowsing_c::draw() {
return 1;
return SUCCEEDED;
}

bool dTgDowsing_c::checkDowsing() const {
Expand Down
4 changes: 2 additions & 2 deletions src/REL/d/t/d_t_genki_dws_tgt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int dTgGenkiDwsTgt_c::create() {

int dTgGenkiDwsTgt_c::doDelete() {
changeLoadedEntitiesNoSet();
return 1;
return SUCCEEDED;
}

int dTgGenkiDwsTgt_c::actorExecute() {
Expand All @@ -61,7 +61,7 @@ int dTgGenkiDwsTgt_c::actorExecute() {
}
}
}
return 1;
return SUCCEEDED;
}

u16 dTgGenkiDwsTgt_c::getSceneFlagFromParams() {
Expand Down
6 changes: 3 additions & 3 deletions src/REL/d/t/d_t_holy_water.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ int dTgHolyWater_c::create() {
}

int dTgHolyWater_c::doDelete() {
return 1;
return SUCCEEDED;
}

int dTgHolyWater_c::actorExecute() {
Expand All @@ -21,11 +21,11 @@ int dTgHolyWater_c::actorExecute() {
if (isLinkNearby()) {
dPlayer::LINK->mForceOrPreventActionFlags |= 0x10000000;
}
return 1;
return SUCCEEDED;
}

int dTgHolyWater_c::draw() {
return 1;
return SUCCEEDED;
}

bool dTgHolyWater_c::isLinkNearby() {
Expand Down
6 changes: 3 additions & 3 deletions src/REL/d/t/d_t_light_shaft_eff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ int dTgLightShaftEff_c::create() {
}

int dTgLightShaftEff_c::doDelete() {
return 1;
return SUCCEEDED;
}

int dTgLightShaftEff_c::actorExecute() {
return 1;
return SUCCEEDED;
}

int dTgLightShaftEff_c::draw() {
return 1;
return SUCCEEDED;
}
Loading

0 comments on commit 508d5b9

Please sign in to comment.