mirror of https://github.com/zeldaret/botw.git
ksys/act: Add BaseProcJob utilities
This commit is contained in:
parent
255677ebe2
commit
a1f5a6ed74
|
@ -91855,15 +91855,15 @@
|
|||
0x00000071011c020c,sub_71011C020C,92,
|
||||
0x00000071011c0268,sub_71011C0268,8,_ZNK4sead10IDelegate1IPN4ksys4util14StrTreeMapNodeEE9isNoDummyEv
|
||||
0x00000071011c0270,sub_71011C0270,8,_ZNK4sead10IDelegate1IPN4ksys4util14StrTreeMapNodeEE5cloneEPNS_4HeapE
|
||||
0x00000071011c0278,sub_71011C0278,32,
|
||||
0x00000071011c0278,sub_71011C0278,32,_GLOBAL__sub_I_actBaseProcJob.cpp
|
||||
0x00000071011c0298,ActorJobLink::ctor,32,_ZN4ksys3act15BaseProcJobLinkC1EPNS0_8BaseProcEh
|
||||
0x00000071011c02b8,ActorJobListsForPriority::getJobFromFront,52,
|
||||
0x00000071011c02ec,ActorJobListsForPriority::getTotalNumberOfJobs,16,
|
||||
0x00000071011c02fc,ActorJobLists::pushJob,236,
|
||||
0x00000071011c03e8,ActorJobLists::eraseJob,72,
|
||||
0x00000071011c0430,ActorJobLists::getJobWithTopPriority,332,
|
||||
0x00000071011c057c,ActorJobLists::getNextJobWithTopPriority,848,
|
||||
0x00000071011c08cc,ActorJobLists::getNextJob,140,
|
||||
0x00000071011c02b8,ActorJobListsForPriority::getJobFromFront,52,_ZNK4ksys3act15BaseProcJobList5frontEv
|
||||
0x00000071011c02ec,ActorJobListsForPriority::getTotalNumberOfJobs,16,_ZNK4ksys3act15BaseProcJobList4sizeEv
|
||||
0x00000071011c02fc,ActorJobLists::pushJob,236,_ZN4ksys3act16BaseProcJobLists7pushJobERNS0_15BaseProcJobLinkE
|
||||
0x00000071011c03e8,ActorJobLists::eraseJob,72,_ZN4ksys3act16BaseProcJobLists8eraseJobERNS0_15BaseProcJobLinkE
|
||||
0x00000071011c0430,ActorJobLists::getJobWithTopPriority,332,_ZNK4ksys3act16BaseProcJobLists21getJobWithTopPriorityEv
|
||||
0x00000071011c057c,ActorJobLists::getNextJobWithTopPriority,848,_ZNK4ksys3act16BaseProcJobLists25getNextJobWithTopPriorityEPNS0_15BaseProcJobLinkE
|
||||
0x00000071011c08cc,ActorJobLists::getNextJob,140,_ZNK4ksys3act16BaseProcJobLists10getNextJobEPNS0_15BaseProcJobLinkE
|
||||
0x00000071011c0958,sub_71011C0958,100,_ZN4ksys3act15BaseProcHeapMgr18SingletonDisposer_D2Ev
|
||||
0x00000071011c09bc,sub_71011C09BC,108,_ZN4ksys3act15BaseProcHeapMgr18SingletonDisposer_D0Ev
|
||||
0x00000071011c0a28,BaseProcMgr::Struct2::createInstance,152,_ZN4ksys3act15BaseProcHeapMgr14createInstanceEPN4sead4HeapE
|
||||
|
|
Can't render this file because it is too large.
|
2
lib/sead
2
lib/sead
|
@ -1 +1 @@
|
|||
Subproject commit f85c9358c5f043bd5e6febecd5c31f55e7f5018e
|
||||
Subproject commit a88c0975cef13aa1ace83d9a829df963da1594e3
|
|
@ -1,9 +1,77 @@
|
|||
#include "KingSystem/ActorSystem/actBaseProcJob.h"
|
||||
#include "KingSystem/Utils/InitTimeInfo.h"
|
||||
|
||||
namespace ksys::act {
|
||||
|
||||
static util::InitTimeInfo sInfo;
|
||||
|
||||
BaseProcJobLink::BaseProcJobLink(BaseProc* proc, u8 priority)
|
||||
: TListNode(proc), mPriority(priority), mNewPriority(priority), mPriority2(3),
|
||||
mNewPriority2(3) {}
|
||||
|
||||
sead::TListNode<BaseProc*>* BaseProcJobList::front() const {
|
||||
for (const auto& list : lists) {
|
||||
if (list.size() >= 1 && list.front())
|
||||
return list.front();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sead::TListNode<BaseProc*>* BaseProcJobList::next(BaseProcJobLink* link) const {
|
||||
if (auto* next = lists[link->getPriority2() >> 1].next(link))
|
||||
return next;
|
||||
|
||||
for (int i = (link->getPriority2() >> 1) + 1; i < lists.size(); ++i) {
|
||||
if (lists[i].size() >= 1 && lists[i].front())
|
||||
return lists[i].front();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int BaseProcJobList::size() const {
|
||||
return lists[0].size() + lists[1].size();
|
||||
}
|
||||
|
||||
void BaseProcJobLists::pushJob(BaseProcJobLink& link) {
|
||||
if (link.isLinked())
|
||||
return;
|
||||
|
||||
auto& list = mLists[link.getPriority()].lists[link.getPriority2() >> 1];
|
||||
if (link.getPriority2() % 2 == 0)
|
||||
list.pushFront(&link);
|
||||
else
|
||||
list.pushBack(&link);
|
||||
}
|
||||
|
||||
void BaseProcJobLists::eraseJob(BaseProcJobLink& link) {
|
||||
if (link.isLinked())
|
||||
link.erase();
|
||||
}
|
||||
|
||||
sead::TListNode<BaseProc*>* BaseProcJobLists::getJobWithTopPriority() const {
|
||||
for (const auto& list : mLists) {
|
||||
if (auto* result = list.front())
|
||||
return result;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sead::TListNode<BaseProc*>*
|
||||
BaseProcJobLists::getNextJobWithTopPriority(BaseProcJobLink* link) const {
|
||||
if (auto* next = getNextJob(link))
|
||||
return next;
|
||||
|
||||
for (u32 i = link->getPriority() + 1; i < u32(mLists.size()); ++i) {
|
||||
if (auto* next = mLists[i].front())
|
||||
return next;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sead::TListNode<BaseProc*>* BaseProcJobLists::getNextJob(BaseProcJobLink* link) const {
|
||||
return mLists[link->getPriority()].next(link);
|
||||
}
|
||||
|
||||
} // namespace ksys::act
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <container/seadSafeArray.h>
|
||||
#include <container/seadTList.h>
|
||||
#include "KingSystem/Utils/Types.h"
|
||||
|
||||
|
@ -50,4 +51,24 @@ private:
|
|||
};
|
||||
KSYS_CHECK_SIZE_NX150(BaseProcJobLink, 0x28);
|
||||
|
||||
struct BaseProcJobList {
|
||||
sead::TListNode<BaseProc*>* front() const;
|
||||
sead::TListNode<BaseProc*>* next(BaseProcJobLink* link) const;
|
||||
int size() const;
|
||||
|
||||
sead::SafeArray<sead::TList<BaseProc*>, 2> lists;
|
||||
};
|
||||
|
||||
class BaseProcJobLists {
|
||||
public:
|
||||
void pushJob(BaseProcJobLink& link);
|
||||
void eraseJob(BaseProcJobLink& link);
|
||||
sead::TListNode<BaseProc*>* getJobWithTopPriority() const;
|
||||
sead::TListNode<BaseProc*>* getNextJobWithTopPriority(BaseProcJobLink* link) const;
|
||||
sead::TListNode<BaseProc*>* getNextJob(BaseProcJobLink* link) const;
|
||||
|
||||
private:
|
||||
sead::SafeArray<BaseProcJobList, 8> mLists;
|
||||
};
|
||||
|
||||
} // namespace ksys::act
|
||||
|
|
Loading…
Reference in New Issue