A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
ResDic.hh
1#pragma once
2
3#include <Common.hh>
4
5#include <cstring>
6
7// Credit: kiwi515/ogws
8
9namespace Abstract {
10namespace g3d {
11
13class ResDic {
14public:
15 struct NodeData {
16 u16 ref;
17 u16 flag;
18 u16 idxLeft;
19 u16 idxRight;
20 s32 ofsString;
21 s32 ofsData;
22 };
23 STATIC_ASSERT(sizeof(NodeData) == 0x10);
24
25 struct Data {
26 u32 size;
27 u32 numData;
28 NodeData data[1];
29 };
30
31 ResDic(const void *data);
32
34 [[nodiscard]] void *operator[](const char *name) const {
35 if (!m_data || !name) {
36 return nullptr;
37 }
38
39 const NodeData *node = get(name, std::strlen(name));
40
41 if (node) {
42 return reinterpret_cast<void *>(
43 reinterpret_cast<uintptr_t>(m_data) + parse<s32>(node->ofsData));
44 }
45
46 return nullptr;
47 }
48
49private:
50 [[nodiscard]] const NodeData *get(const char *pName, u32 len) const;
51
52 const Data *m_data;
53};
54
55} // namespace g3d
56} // namespace Abstract
This header houses common data types such as our integral types and enums.
Essentially a lookup table to find different sections within the resource file.
Definition ResDic.hh:13
An abstraction of components from the nw4r and RVL libraries.
Definition Archive.cc:5