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

View File

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