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
namespace
Kinoko::System
{
6
7
struct
MapSectionHeader
{
8
s32 magic;
9
u16 count;
10
};
11
12
template
<
typename
T,
typename
TData>
13
class
MapdataAccessorBase {
14
public
:
15
MapdataAccessorBase(
const
MapSectionHeader
*header)
16
: m_entries(
nullptr
), m_entryCount(0), m_sectionHeader(header) {}
17
MapdataAccessorBase(
const
MapdataAccessorBase &) =
delete
;
18
MapdataAccessorBase(MapdataAccessorBase &&) =
delete
;
19
20
virtual
~MapdataAccessorBase() {
21
if
(m_entries) {
22
for
(
size_t
i = 0; i < m_entryCount; ++i) {
23
delete
m_entries[i];
24
}
25
}
26
27
delete
[] m_entries;
28
}
29
30
[[nodiscard]] T *get(u16 i)
const
{
31
return
i < m_entryCount ? m_entries[i] :
nullptr
;
32
}
33
34
[[nodiscard]] TData *getData(u16 i)
const
{
35
return
i < m_entryCount ? m_entries[i]->data() :
nullptr
;
36
}
37
38
[[nodiscard]] u16 size()
const
{
39
return
m_entryCount;
40
}
41
42
void
init(
const
TData *start, u16 count) {
43
if
(count != 0) {
44
m_entryCount = count;
45
m_entries =
new
T *[count];
46
}
47
48
for
(u16 i = 0; i < count; ++i) {
49
m_entries[i] =
new
T(&start[i]);
50
}
51
}
52
53
protected
:
54
T **m_entries;
55
u16 m_entryCount;
56
const
MapSectionHeader
*m_sectionHeader;
57
};
58
59
}
// 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:7
game
system
map
MapdataAccessorBase.hh
Made by
Malleo
. Logo by
vabold
. Website generated by
Doxygen
1.17.0