ksys/act: Add getJobHandler wrapper to clean up casts

This commit is contained in:
Léo Lam 2021-02-07 00:28:21 +01:00
parent 5f5c27a078
commit 76eb407fe4
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
2 changed files with 11 additions and 8 deletions

View File

@ -231,7 +231,7 @@ bool BaseProc::canWakeUp_() {
void BaseProc::queueExtraJobPush_(JobType type) { void BaseProc::queueExtraJobPush_(JobType type) {
if (!isDeletedOrDeleting()) if (!isDeletedOrDeleting())
BaseProcMgr::instance()->queueExtraJobPush(&mJobHandlers[int(type)]->getLink()); BaseProcMgr::instance()->queueExtraJobPush(&getJobHandler(type)->getLink());
} }
bool BaseProc::shouldSkipJobPush(JobType type) { bool BaseProc::shouldSkipJobPush(JobType type) {
@ -262,7 +262,7 @@ void BaseProc::setJobPriority(u8 actorparam_priority, JobType type) {
if (isDeletedOrDeleting()) if (isDeletedOrDeleting())
return; return;
auto& handler = mJobHandlers[int(type)]; auto& handler = getJobHandler(type);
handler->getLink().setNewPriority(actorparam_priority); handler->getLink().setNewPriority(actorparam_priority);
if (isCalc()) { if (isCalc()) {
setJobPriorityDuringCalc_(handler, type); setJobPriorityDuringCalc_(handler, type);
@ -275,7 +275,7 @@ void BaseProc::setJobPriority2(u8 actorparam_priority, JobType type) {
if (isDeletedOrDeleting()) if (isDeletedOrDeleting())
return; return;
auto& handler = mJobHandlers[int(type)]; auto& handler = getJobHandler(type);
handler->getLink().setNewPriority2(actorparam_priority); handler->getLink().setNewPriority2(actorparam_priority);
if (isCalc()) { if (isCalc()) {
setJobPriorityDuringCalc_(handler, type); setJobPriorityDuringCalc_(handler, type);
@ -285,7 +285,7 @@ void BaseProc::setJobPriority2(u8 actorparam_priority, JobType type) {
} }
bool BaseProc::hasJobType_(JobType type) { bool BaseProc::hasJobType_(JobType type) {
return mJobHandlers[int(type)] != nullptr; return getJobHandler(type) != nullptr;
} }
void BaseProc::afterUpdateState_() { void BaseProc::afterUpdateState_() {
@ -311,11 +311,11 @@ void BaseProc::jobInvoked(JobType type) {
if (mStateFlags.isOn(StateFlags::RequestDelete)) { if (mStateFlags.isOn(StateFlags::RequestDelete)) {
if (type == JobType::Calc4) if (type == JobType::Calc4)
mJobHandlers[4]->invoke(); getJobHandler(JobType::Calc4)->invoke();
special = IsSpecialJobTypeResult::Yes; special = IsSpecialJobTypeResult::Yes;
} else { } else {
special = isSpecialJobType_(type); special = isSpecialJobType_(type);
auto* handler = mJobHandlers[int(type)]; auto* handler = getJobHandler(type);
if (special != IsSpecialJobTypeResult::No) if (special != IsSpecialJobTypeResult::No)
handler->invokeSpecial(); handler->invokeSpecial();
else else
@ -329,10 +329,10 @@ void BaseProc::jobInvoked(JobType type) {
const auto child_special = child->isSpecialJobType_(type); const auto child_special = child->isSpecialJobType_(type);
if (child->mStateFlags.isOn(StateFlags::RequestDelete)) { if (child->mStateFlags.isOn(StateFlags::RequestDelete)) {
if (type == JobType::Calc4) if (type == JobType::Calc4)
child->mJobHandlers[4]->invoke(); child->getJobHandler(JobType::Calc4)->invoke();
special = IsSpecialJobTypeResult::Yes; special = IsSpecialJobTypeResult::Yes;
} else { } else {
auto* handler = child->mJobHandlers[int(type)]; auto* handler = child->getJobHandler(type);
if (special == IsSpecialJobTypeResult::Yes || if (special == IsSpecialJobTypeResult::Yes ||
child_special != IsSpecialJobTypeResult::No) { child_special != IsSpecialJobTypeResult::No) {
handler->invokeSpecial(); handler->invokeSpecial();

View File

@ -264,6 +264,9 @@ protected:
return mSpecialJobTypesMask.isOnBit(int(type)); return mSpecialJobTypesMask.isOnBit(int(type));
} }
BaseProcJobHandler*& getJobHandler(JobType type) { return mJobHandlers[int(type)]; }
BaseProcJobHandler* getJobHandler(JobType type) const { return mJobHandlers[int(type)]; }
bool x00000071011ba9fc(); bool x00000071011ba9fc();
sead::FixedSafeString<64> mName; sead::FixedSafeString<64> mName;