some more NerveStateCtrl decompilation

This commit is contained in:
shibbo 2020-10-29 06:28:08 -04:00
parent 7f037bee3d
commit 787bea83e0
3 changed files with 88 additions and 6 deletions

View File

@ -4,6 +4,7 @@
namespace al
{
class NerveStateCtrl;
class NerveKeeper
{
public:
@ -14,12 +15,14 @@ namespace al
void setNerve(const al::Nerve *);
al::Nerve* getCurrentNerve() const;
void tryChangeNerve();
al::IUseNerve* mParent; // _0
unsigned long* _8;
al::Nerve* mNerve; // _10
int mStep; // _18
int _1C;
unsigned long* _20; // NerveStateCtrl*
al::NerveStateCtrl* mStateCtrl; // _20
unsigned long _28;
};
};

View File

@ -18,14 +18,17 @@ namespace al
NerveStateCtrl(int);
void addState(al::NerveStateBase *, const al::Nerve *, const char *);
bool updateCurrentState();
void startState(const al::Nerve *);
void update();
State* findStateInfo(const al::Nerve *);
bool isCurrentStateEnd() const;
void tryEndCurrentState();
int _0;
int _4;
State** mStates; // _8
int mCurrentState; // _10
int _14;
int mStateCount; // _4
State* mStates; // _8
State* mCurrentState; // _10
};
};

View File

@ -2,5 +2,81 @@
namespace al
{
// todo -- some scheduling problems with mStateCount's incrementation
void NerveStateCtrl::addState(al::NerveStateBase *pBase, const al::Nerve *pNerve, const char *pName)
{
State* state = &mStates[mStateCount];
state->mStateBase = pBase;
state->mNerve = pNerve;
state->mName = pName;
mStateCount++;
}
bool NerveStateCtrl::updateCurrentState()
{
if (!mCurrentState)
{
return false;
}
return mCurrentState->mStateBase->update();
}
// UNUSED FUNCTION
State* al::NerveStateCtrl::findStateInfo(const al::Nerve *pNerve)
{
if (mStateCount < 1)
{
return nullptr;
}
int curIdx = 0;
while (curIdx < mStateCount)
{
if (mStates[curIdx].mNerve == pNerve)
{
return &mStates[curIdx];
}
curIdx++;
}
return nullptr;
}
bool NerveStateCtrl::isCurrentStateEnd() const
{
if (!mCurrentState)
{
return true;
}
return mCurrentState->mStateBase->mIsDead != 0;
}
void NerveStateCtrl::tryEndCurrentState()
{
if (mCurrentState)
{
if (!mCurrentState->mStateBase->mIsDead)
{
mCurrentState->mStateBase->kill();
}
al::NerveKeeper* keeper = mCurrentState->mStateBase->getNerveKeeper();
if (keeper)
{
al::NerveStateCtrl* ctrl = keeper->mStateCtrl;
if (ctrl)
{
ctrl->tryEndCurrentState();
}
}
mCurrentState = nullptr;
}
}
};