Kinoko
A reimplementation of Mario Kart Wii's physics engine in C++
Toggle main menu visibility
Loading...
Searching...
No Matches
MapdataAccessorBase.hh
1
#pragma once
2
3
#include <
Common.hh
>
4
5
#include <egg/core/Heap.hh>
6
7
namespace
Kinoko::System
{
8
9
struct
MapSectionHeader
{
10
s32 magic;
11
u16 count;
12
};
13
14
template
<
typename
T,
typename
TData>
15
class
MapdataAccessorBase {
16
public
:
17
MapdataAccessorBase(
const
MapSectionHeader
*header)
18
: m_entries(
nullptr
), m_entryCount(0), m_sectionHeader(header) {}
19
MapdataAccessorBase(
const
MapdataAccessorBase &) =
delete
;
20
MapdataAccessorBase(MapdataAccessorBase &&) =
delete
;
21
22
virtual
~MapdataAccessorBase() {
23
if
(m_entries) {
24
for
(
size_t
i = 0; i < m_entryCount; ++i) {
25
EGG::egg_delete(m_entries[i]);
26
}
27
EGG::egg_free(m_entries);
28
}
29
}
30
31
[[nodiscard]] T *get(u16 i)
const
{
32
return
i < m_entryCount ? m_entries[i] :
nullptr
;
33
}
34
35
[[nodiscard]] TData *getData(u16 i)
const
{
36
return
i < m_entryCount ? m_entries[i]->data() :
nullptr
;
37
}
38
39
[[nodiscard]] u16 size()
const
{
40
return
m_entryCount;
41
}
42
43
void
init(
const
TData *start, u16 count) {
44
if
(count != 0) {
45
m_entryCount = count;
46
m_entries =
static_cast<
T **
>
(EGG::egg_alloc(count *
sizeof
(T *)));
47
}
48
49
for
(u16 i = 0; i < count; ++i) {
50
m_entries[i] = EGG::egg_new<T>(&start[i]);
51
}
52
}
53
54
protected
:
55
T **m_entries;
56
u16 m_entryCount;
57
const
MapSectionHeader
*m_sectionHeader;
58
};
59
60
}
// namespace Kinoko::System
Common.hh
This header houses common data types such as our integral types and enums.
Kinoko::System
High-level handling for generic system operations, such as input reading, race configuration,...
Definition
CourseMap.cc:5
Kinoko::System::MapSectionHeader
Definition
MapdataAccessorBase.hh:9
game
system
map
MapdataAccessorBase.hh
Made by
Malleo
. Logo by
vabold
. Website generated by
Doxygen
1.17.0