mirror of https://github.com/zeldaret/botw.git
ksys/evt: Match OrderParam "get T by name" getters
This commit is contained in:
parent
85430d3232
commit
9c6bec732f
|
|
@ -75596,9 +75596,9 @@
|
|||
0x0000007100db504c,ksys::evt::OrderParam::addParamStr,412,
|
||||
0x0000007100db51e8,ksys::evt::OrderParam::tryAlloc_,944,_ZN4ksys3evt10OrderParam8tryAllocENS0_14OrderParamTypeEjRN4sead14SafeStringBaseIcEE?
|
||||
0x0000007100db5598,ksys::evt::OrderParam::addParamActor,240,_ZN4ksys3evt10OrderParam13addParamActorERNS_3act8BaseProcERN4sead14SafeStringBaseIcEE?
|
||||
0x0000007100db5688,ksys::evt::OrderParam::getIntByName,176,_ZN4ksys3evt10OrderParam12getIntByNameERKN4sead14SafeStringBaseIcEEPPj?
|
||||
0x0000007100db5738,ksys::evt::OrderParam::getStringByName,176,_ZN4ksys3evt10OrderParam15getStringByNameERKN4sead14SafeStringBaseIcEEPPS4_?
|
||||
0x0000007100db57e8,ksys::evt::OrderParam::getArrayByName,208,_ZN4ksys3evt10OrderParam14getArrayByNameERKN4sead14SafeStringBaseIcEEPPvPj?
|
||||
0x0000007100db5688,ksys::evt::OrderParam::getIntByName,176,_ZN4ksys3evt10OrderParam12getIntByNameERKN4sead14SafeStringBaseIcEEPPj
|
||||
0x0000007100db5738,ksys::evt::OrderParam::getStringByName,176,_ZN4ksys3evt10OrderParam15getStringByNameERKN4sead14SafeStringBaseIcEEPPS4_
|
||||
0x0000007100db57e8,ksys::evt::OrderParam::getArrayByName,208,_ZN4ksys3evt10OrderParam14getArrayByNameERKN4sead14SafeStringBaseIcEEPPvPj
|
||||
0x0000007100db58b8,evt::EventFlowBase::ctor,2140,
|
||||
0x0000007100db6114,_ZN4sead9SafeArrayINS_15FixedSafeStringILi64EEELi8EEC2Ev,360,
|
||||
0x0000007100db627c,evt::EventFlowBase::getBaseProcLink,12,
|
||||
|
|
|
|||
|
Can't render this file because it is too large.
|
|
|
@ -91,18 +91,17 @@ void OrderParam::addParamActor(ksys::act::BaseProc& actor, sead::SafeString& nam
|
|||
}
|
||||
}
|
||||
}
|
||||
// The three below have 1 pair of instructions swapped
|
||||
|
||||
bool OrderParam::getIntByName(const sead::SafeString& name, u32** out_ptr) {
|
||||
return tryGetPointerByName(name, (void**)out_ptr, nullptr, OrderParamType::INT);
|
||||
return getPointerByName(name, out_ptr, nullptr, OrderParamType::INT);
|
||||
}
|
||||
|
||||
bool OrderParam::getStringByName(const sead::SafeString& name, sead::SafeString** out_ptr) {
|
||||
return tryGetPointerByName(name, (void**)out_ptr, nullptr, OrderParamType::STRING);
|
||||
return getPointerByName(name, out_ptr, nullptr, OrderParamType::STRING);
|
||||
}
|
||||
|
||||
bool OrderParam::getArrayByName(const sead::SafeString& name, void** out_ptr, u32* out_size) {
|
||||
return tryGetPointerByName(name, out_ptr, out_size, OrderParamType::ARRAY);
|
||||
return getPointerByName(name, out_ptr, out_size, OrderParamType::ARRAY);
|
||||
}
|
||||
|
||||
// This one also does not match
|
||||
|
|
@ -170,4 +169,17 @@ OrderParamEntry* OrderParam::tryAlloc(OrderParamType type, u32 size, sead::SafeS
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace ksys::evt
|
||||
void* OrderParam::getPointerByName(const sead::SafeString& name, u32* out_size,
|
||||
OrderParamType type) const {
|
||||
const u32 hash = sead::HashCRC32::calcStringHash(name);
|
||||
for (s32 i = 0; i < mEntries.size(); i++) {
|
||||
if (mEntries[i].mHash == hash && mEntries[i].mType == type) {
|
||||
if (out_size)
|
||||
*out_size = mEntries[i].mSize;
|
||||
return mEntries[i].mPointer;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace ksys::evt
|
||||
|
|
|
|||
|
|
@ -45,38 +45,18 @@ public:
|
|||
bool getArrayByName(const sead::SafeString& name, void** out_ptr, u32* out_size);
|
||||
|
||||
private:
|
||||
inline void* getPointerByName(const sead::SafeString& name, OrderParamType type) {
|
||||
u32 hash = sead::HashCRC32::calcStringHash(name.cstr());
|
||||
s32 i;
|
||||
for (i = 0; i < mEntries.size(); i++) {
|
||||
if (mEntries[i].mHash == hash && mEntries[i].mType == type) {
|
||||
return mEntries[i].mPointer;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
inline bool tryGetPointerByName(const sead::SafeString& name, void** out_ptr, u32* out_size,
|
||||
OrderParamType type) {
|
||||
u32 hash = sead::HashCRC32::calcStringHash(name.cstr());
|
||||
s32 i;
|
||||
for (i = 0; i < mEntries.size(); i++) {
|
||||
if (mEntries[i].mHash == hash && mEntries[i].mType == type) {
|
||||
if (out_size) {
|
||||
*out_size = mEntries[i].mSize;
|
||||
}
|
||||
return tryGetPointer(i, out_ptr);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
inline bool tryGetPointer(s32 i, void** out_ptr) {
|
||||
auto* ptr = mEntries[i].mPointer;
|
||||
if (ptr) {
|
||||
*out_ptr = ptr; // minor diff with scheduling
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
void* getPointerByName(const sead::SafeString& name, u32* out_size, OrderParamType type) const;
|
||||
|
||||
template <typename T>
|
||||
bool getPointerByName(const sead::SafeString& name, T** out_ptr, u32* out_size,
|
||||
OrderParamType type) const {
|
||||
auto* ptr = getPointerByName(name, out_size, type);
|
||||
if (!ptr)
|
||||
return false;
|
||||
*out_ptr = static_cast<T*>(ptr);
|
||||
return true;
|
||||
}
|
||||
|
||||
inline void clearEntry(OrderParamEntry* e) {
|
||||
e->mHash = 0;
|
||||
e->mSize = 0;
|
||||
|
|
@ -89,4 +69,4 @@ private:
|
|||
u32 mEntryCount = 0;
|
||||
bool mInitialized = false;
|
||||
};
|
||||
} // namespace ksys::evt
|
||||
} // namespace ksys::evt
|
||||
|
|
|
|||
Loading…
Reference in New Issue