ksys/evt: Fix matching issue in OrderParam::tryAlloc

This commit is contained in:
Léo Lam 2021-02-07 14:55:57 +01:00
parent f41d668cff
commit 37d4a0695c
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
3 changed files with 14 additions and 21 deletions

View File

@ -75594,7 +75594,7 @@
0x0000007100db4e24,ksys::evt::OrderParam::initialize,332,_ZN4ksys3evt10OrderParam10initializeEi?
0x0000007100db4f70,ksys::evt::OrderParam::addParamInt,220,_ZN4ksys3evt10OrderParam11addParamIntEiRKN4sead14SafeStringBaseIcEE
0x0000007100db504c,ksys::evt::OrderParam::addParamString,412,_ZN4ksys3evt10OrderParam14addParamStringERKN4sead14SafeStringBaseIcEES6_
0x0000007100db51e8,ksys::evt::OrderParam::tryAlloc_,944,_ZN4ksys3evt10OrderParam8tryAllocENS0_14OrderParamTypeEjRKN4sead14SafeStringBaseIcEE?
0x0000007100db51e8,ksys::evt::OrderParam::tryAlloc_,944,_ZN4ksys3evt10OrderParam8tryAllocENS0_14OrderParamTypeEjRKN4sead14SafeStringBaseIcEE
0x0000007100db5598,ksys::evt::OrderParam::addParamActor,240,_ZN4ksys3evt10OrderParam13addParamActorEPNS_3act8BaseProcERN4sead14SafeStringBaseIcEE
0x0000007100db5688,ksys::evt::OrderParam::getIntByName,176,_ZN4ksys3evt10OrderParam12getIntByNameERKN4sead14SafeStringBaseIcEEPPj
0x0000007100db5738,ksys::evt::OrderParam::getStringByName,176,_ZN4ksys3evt10OrderParam15getStringByNameERKN4sead14SafeStringBaseIcEEPPS4_

Can't render this file because it is too large.

View File

@ -215,44 +215,44 @@ OrderParamEntry* OrderParam::getFreeEntry() {
}
return nullptr;
}
// This one does not match
OrderParamEntry* OrderParam::tryAlloc(OrderParamType type, u32 size, const sead::SafeString& name) {
sead::FixedSafeString<0x100> error_message;
error_message.format("[%s] tryAlloc_(%d, %d, %s) is failed.", "ksys::evt::OrderParam",
static_cast<u16>(type), size, name.cstr());
OrderParamEntry* entry = getFreeEntry(); // inlining here fixed the for loop
OrderParamEntry* entry = getFreeEntry();
if (!entry)
return nullptr;
auto* heap = mHeap;
if (!heap)
return nullptr;
std::nothrow_t nothrow;
entry->mName =
new (heap, nothrow) sead::FixedSafeString<0x20>(name); // scheduling mismatches here
// entry->mName = new_name;
// inlining here doesn't fix the mismatch
entry->mName = new (heap, std::nothrow_t()) sead::FixedSafeString<0x20>(name);
switch (type) {
case OrderParamType::INT:
case OrderParamType::INT_2:
doAlloc(entry, new (heap, nothrow) s32(0));
entry->mPointer = new (heap, std::nothrow_t()) s32();
entry->mSize = sizeof(s32);
break;
case OrderParamType::STRING:
doAlloc(entry,
new (heap, nothrow) sead::FixedSafeString<0x40>); // scheduling mismatches here
entry->mPointer = new (heap, std::nothrow_t()) sead::FixedSafeString<0x40>;
entry->mSize = sizeof(sead::FixedSafeString<0x40>);
break;
case OrderParamType::BYTE:
doAlloc(entry, new (heap, nothrow) char(0));
entry->mPointer = new (heap, std::nothrow_t()) bool();
entry->mSize = sizeof(bool);
break;
case OrderParamType::ACTOR:
doAlloc(entry, new (heap, nothrow) ksys::act::BaseProcLink);
entry->mPointer = new (heap, std::nothrow_t()) ksys::act::BaseProcLink;
entry->mSize = sizeof(act::BaseProcLink);
break;
case OrderParamType::ARRAY:
doAlloc(entry, new (heap, nothrow) char[size], size);
entry->mPointer = new (heap, std::nothrow_t()) char[size];
entry->mSize = size;
break;
default:
break;

View File

@ -78,13 +78,6 @@ private:
return nullptr;
return static_cast<T*>(entry->mPointer);
}
template <typename T>
void doAlloc(OrderParamEntry* e, T* ptr, u32 size = sizeof(T)) {
//*size_ptr = sizeof(T);
e->mPointer = ptr;
e->mSize = size;
// return sizeof(T);
}
inline void clearEntry(OrderParamEntry* e) {
e->mHash = 0;