mirror of https://github.com/zeldaret/botw.git
ksys/act: Add InstParamPack
This commit is contained in:
parent
2d721f8969
commit
dbaac9cb78
|
@ -74109,11 +74109,11 @@
|
|||
0x0000007100dca244,sub_7100DCA244,32,
|
||||
0x0000007100dca264,sub_7100DCA264,32,
|
||||
0x0000007100dca284,sub_7100DCA284,52,
|
||||
0x0000007100dca2b8,_ZN15ActorInstParams3Buf5clearEv,28,
|
||||
0x0000007100dca2d4,_ZN15ActorInstParams3Buf3addEPKvRKN4sead10SafeStringEiNS_9EntryTypeE,224,
|
||||
0x0000007100dca3b4,ActorInstParams::Buf::addInvoker,196,
|
||||
0x0000007100dca478,ActorInstParams::Buf::pop,604,
|
||||
0x0000007100dca6d4,_ZN15ActorInstParams3BufaSERS0_,56,
|
||||
0x0000007100dca2b8,_ZN15ActorInstParams3Buf5clearEv,28,_ZN4ksys3act13InstParamPack6Buffer5clearEv
|
||||
0x0000007100dca2d4,_ZN15ActorInstParams3Buf3addEPKvRKN4sead10SafeStringEiNS_9EntryTypeE,224,_ZN4ksys3act13InstParamPack6Buffer3addEPKvRKN4sead14SafeStringBaseIcEEiNS1_9EntryTypeE?
|
||||
0x0000007100dca3b4,ActorInstParams::Buf::addInvoker,196,_ZN4ksys3act13InstParamPack6Buffer3addEPN4sead10IDelegate1IPNS0_8BaseProcEEERKNS3_14SafeStringBaseIcEE?
|
||||
0x0000007100dca478,ActorInstParams::Buf::pop,604,_ZN4ksys3act13InstParamPack6Buffer3popEPiPNS1_5EntryE!
|
||||
0x0000007100dca6d4,_ZN15ActorInstParams3BufaSERS0_,56,_ZN4ksys3act13InstParamPack6BufferaSERKS2_
|
||||
0x0000007100dca70c,_ZN13ActorAccessorD2Ev,56,_ZN4ksys3act24ActorLinkConstDataAccessD1Ev
|
||||
0x0000007100dca744,ActorAccessor::acquire,88,_ZN4ksys3act24ActorLinkConstDataAccess7acquireEPNS0_8BaseProcE
|
||||
0x0000007100dca79c,act::acquireActorFromGameOrHavokThread,256,_ZN4ksys3act11acquireProcEPNS0_24ActorLinkConstDataAccessEPNS0_8BaseProcERKN4sead14SafeStringBaseIcEEi
|
||||
|
|
Can't render this file because it is too large.
|
|
@ -31,5 +31,7 @@ target_sources(uking PRIVATE
|
|||
actBaseProcMgr.h
|
||||
actBaseProcUnit.cpp
|
||||
actBaseProcUnit.h
|
||||
actInstParamPack.cpp
|
||||
actInstParamPack.h
|
||||
actTag.h
|
||||
)
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
#include "KingSystem/ActorSystem/actInstParamPack.h"
|
||||
#include <prim/seadMemUtil.h>
|
||||
|
||||
namespace ksys::act {
|
||||
|
||||
void InstParamPack::Buffer::clear() {
|
||||
mNumItems = 0;
|
||||
mPosition = 0;
|
||||
mData.fill(0);
|
||||
}
|
||||
|
||||
// NON_MATCHING: write()
|
||||
void InstParamPack::Buffer::add(const void* data, const sead::SafeString& name, s32 byte_size,
|
||||
InstParamPack::EntryType type) {
|
||||
if (byte_size + mPosition + u32(sizeof(const char*)) + 1 > mData.getByteSize()) {
|
||||
SEAD_ASSERT_MSG(false, "InstParamPack::Buffer::add: Buffer overflow");
|
||||
return;
|
||||
}
|
||||
|
||||
write(name.cstr());
|
||||
write(u8(type));
|
||||
writeBytes(data, byte_size);
|
||||
++mNumItems;
|
||||
}
|
||||
|
||||
// NON_MATCHING: write()
|
||||
void InstParamPack::Buffer::add(ActorCallback* callback, const sead::SafeString& name) {
|
||||
add(callback, name, sizeof(callback), EntryType::UInt64);
|
||||
}
|
||||
|
||||
// NON_MATCHING
|
||||
bool InstParamPack::Buffer::pop(s32* position, InstParamPack::Entry* out_entry) {
|
||||
if (!read(out_entry->key, position))
|
||||
return false;
|
||||
|
||||
if (!read(out_entry->type.mValue, position))
|
||||
return false;
|
||||
|
||||
switch (out_entry->type) {
|
||||
case EntryType::Int:
|
||||
return read(out_entry->data.i, position);
|
||||
case EntryType::_1:
|
||||
return read(out_entry->data.type1, position);
|
||||
case EntryType::Float:
|
||||
return read(out_entry->data.f, position);
|
||||
case EntryType::Bool:
|
||||
return read(out_entry->data.b, position);
|
||||
case EntryType::Vec3:
|
||||
return read(out_entry->data.vec3, position);
|
||||
case EntryType::String: {
|
||||
const s32 start_pos = *position;
|
||||
char c;
|
||||
do {
|
||||
if (!read(c, position)) {
|
||||
out_entry->data.str = nullptr;
|
||||
return false;
|
||||
}
|
||||
} while (c != sead::SafeString::cNullChar);
|
||||
out_entry->data.str = reinterpret_cast<const char*>(&mData[start_pos]);
|
||||
return true;
|
||||
}
|
||||
case EntryType::UInt64:
|
||||
return read(out_entry->data.l, position);
|
||||
case EntryType::Matrix34:
|
||||
return read(out_entry->data.mtx34, position);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
InstParamPack::Buffer& InstParamPack::Buffer::operator=(const InstParamPack::Buffer& other) {
|
||||
size_t pos = other.mPosition;
|
||||
mPosition = pos;
|
||||
mNumItems = other.mNumItems;
|
||||
sead::MemUtil::copy(mData.getBufferPtr(), other.mData.getBufferPtr(), pos);
|
||||
return *this;
|
||||
}
|
||||
|
||||
} // namespace ksys::act
|
|
@ -0,0 +1,110 @@
|
|||
#pragma once
|
||||
|
||||
#include <basis/seadTypes.h>
|
||||
#include <container/seadSafeArray.h>
|
||||
#include <math/seadMatrix.h>
|
||||
#include <math/seadVector.h>
|
||||
#include <prim/seadDelegate.h>
|
||||
#include <prim/seadMemUtil.h>
|
||||
#include <prim/seadSafeString.h>
|
||||
#include <prim/seadSizedEnum.h>
|
||||
#include "KingSystem/Utils/Types.h"
|
||||
|
||||
namespace ksys::act {
|
||||
|
||||
class BaseProc;
|
||||
|
||||
class InstParamPack {
|
||||
public:
|
||||
enum class EntryType {
|
||||
/// Signed(?) 32-bit integer.
|
||||
Int = 0,
|
||||
/// Unknown.
|
||||
_1 = 1,
|
||||
/// Single-precision float.
|
||||
Float = 2,
|
||||
/// Boolean.
|
||||
Bool = 3,
|
||||
/// Vector3f.
|
||||
Vec3 = 4,
|
||||
/// String (stored inline).
|
||||
String = 5,
|
||||
/// Unsigned 64-bit integer. Can be used to store pointers.
|
||||
UInt64 = 6,
|
||||
/// 3x4 matrix (sead::Matrix34).
|
||||
Matrix34 = 7,
|
||||
};
|
||||
|
||||
using ActorCallback = sead::IDelegate1<BaseProc*>;
|
||||
|
||||
struct Entry {
|
||||
union Data {
|
||||
s32 i;
|
||||
f32 f;
|
||||
u32 type1;
|
||||
u64 l;
|
||||
bool b;
|
||||
sead::Vector3f vec3;
|
||||
sead::Matrix34f mtx34;
|
||||
const char* str;
|
||||
ActorCallback* cb;
|
||||
};
|
||||
KSYS_CHECK_SIZE_NX150(Data, 0x30);
|
||||
|
||||
const char* key;
|
||||
sead::SizedEnum<EntryType, s8> type;
|
||||
Data data;
|
||||
};
|
||||
KSYS_CHECK_SIZE_NX150(Entry, 0x40);
|
||||
|
||||
class Buffer {
|
||||
public:
|
||||
Buffer() { clear(); }
|
||||
Buffer& operator=(const Buffer& other);
|
||||
|
||||
void clear();
|
||||
void add(const void* data, const sead::SafeString& name, s32 byte_size, EntryType type);
|
||||
void add(ActorCallback* callback, const sead::SafeString& name);
|
||||
|
||||
bool pop(s32* position, Entry* out_entry);
|
||||
|
||||
private:
|
||||
void writeBytes(const void* value, s32 size) {
|
||||
sead::MemUtil::copy(&mData[mPosition], value, size);
|
||||
mPosition += size;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void write(const T& value) {
|
||||
writeBytes(&value, sizeof(value));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool read(T& value, s32* position) {
|
||||
if (*position + s32(sizeof(T)) > mData.size())
|
||||
return false;
|
||||
|
||||
sead::MemUtil::copy(&value, &mData[*position], sizeof(T));
|
||||
*position += s32(sizeof(T));
|
||||
return true;
|
||||
}
|
||||
|
||||
u16 mNumItems;
|
||||
s16 mPosition;
|
||||
sead::SafeArray<u8, 0xc0> mData;
|
||||
};
|
||||
KSYS_CHECK_SIZE_NX150(Buffer, 0xc4);
|
||||
|
||||
InstParamPack() = default;
|
||||
virtual ~InstParamPack() = default;
|
||||
|
||||
Buffer& getBuffer() { return mBuffer; }
|
||||
const Buffer& getBuffer() const { return mBuffer; }
|
||||
|
||||
private:
|
||||
BaseProc* mProc = nullptr;
|
||||
Buffer mBuffer;
|
||||
};
|
||||
KSYS_CHECK_SIZE_NX150(InstParamPack, 0xd8);
|
||||
|
||||
} // namespace ksys::act
|
Loading…
Reference in New Issue