Kinoko
A reimplementation of Mario Kart Wii's physics engine in C++
Toggle main menu visibility
Loading...
Searching...
No Matches
GhostFile.hh
1
#pragma once
2
3
#include "game/system/TimerManager.hh"
4
5
#include <egg/util/Stream.hh>
6
7
#include <array>
8
9
namespace
Kinoko::System
{
10
11
static
constexpr
size_t
RKG_HEADER_SIZE = 0x88;
12
static
constexpr
size_t
RKG_UNCOMPRESSED_INPUT_DATA_SECTION_SIZE = 0x2774;
13
45
class
RawGhostFile {
46
public
:
47
RawGhostFile();
48
RawGhostFile(
const
u8 *rkg);
49
~RawGhostFile();
50
51
RawGhostFile &operator=(
const
u8 *rkg);
52
53
void
init(
const
u8 *rkg);
54
[[nodiscard]]
bool
decompress(
const
u8 *rkg);
55
[[nodiscard]]
bool
isValid
(
const
u8 *rkg)
const
;
56
57
[[nodiscard]]
const
u8 *buffer()
const
{
58
return
m_buffer;
59
}
60
61
template
<
typename
T>
62
[[nodiscard]] T parseAt(
size_t
offset)
const
{
63
return
parse<T>(*
reinterpret_cast<
const
T *
>
(m_buffer + offset));
64
}
65
66
private
:
67
[[nodiscard]]
bool
compressed(
const
u8 *rkg)
const
{
68
return
((*(rkg + 0xC) >> 3) & 1) == 1;
69
}
70
71
u8 m_buffer[0x2800];
72
};
73
STATIC_ASSERT(
sizeof
(
RawGhostFile
) == 0x2800);
74
77
class
GhostFile {
78
public
:
79
GhostFile(
const
RawGhostFile
&raw);
80
~GhostFile();
81
82
void
read
(
EGG::RamStream
&stream);
83
85
[[nodiscard]]
const
Timer
&lapTimer(
size_t
i)
const
{
86
ASSERT(i < m_lapTimes.size());
87
return
m_lapTimes[i];
88
}
89
90
[[nodiscard]]
const
Timer
&raceTimer()
const
{
91
return
m_raceTime;
92
}
93
94
[[nodiscard]] Character character()
const
{
95
return
m_character;
96
}
97
98
[[nodiscard]] Vehicle vehicle()
const
{
99
return
m_vehicle;
100
}
101
102
[[nodiscard]] Course course()
const
{
103
return
m_course;
104
}
105
106
[[nodiscard]]
const
u8 *inputs()
const
{
107
return
m_inputs;
108
}
109
110
[[nodiscard]]
bool
driftIsAuto()
const
{
111
return
m_driftIsAuto
;
112
}
114
115
private
:
116
std::array<wchar_t, 11> m_userData;
117
std::array<u8, 76> m_miiData;
118
u8 m_lapCount;
119
std::array<Timer, 5> m_lapTimes;
120
Timer
m_raceTime;
121
Character m_character;
122
Vehicle m_vehicle;
123
Course m_course;
124
[[maybe_unused]] u32 m_controllerId;
125
u8
m_year
;
126
u8 m_month;
127
u8 m_day;
128
u32
m_type
;
129
bool
m_driftIsAuto
;
130
u32
m_location
;
131
u16
m_inputSize
;
132
const
u8 *m_inputs;
133
};
134
135
}
// namespace Kinoko::System
Kinoko::EGG::RamStream
A stream of data stored in memory.
Definition
Stream.hh:83
Kinoko::System::GhostFile::read
void read(EGG::RamStream &stream)
Organizes binary data into members. See RawGhostFile.
Definition
GhostFile.cc:21
Kinoko::System::GhostFile::m_location
u32 m_location
0xFFFF if sharing disabled
Definition
GhostFile.hh:130
Kinoko::System::GhostFile::m_type
u32 m_type
The type of ghost.
Definition
GhostFile.hh:128
Kinoko::System::GhostFile::m_year
u8 m_year
The year, relative to 2000.
Definition
GhostFile.hh:125
Kinoko::System::GhostFile::m_driftIsAuto
bool m_driftIsAuto
True for automatic, false for manual.
Definition
GhostFile.hh:129
Kinoko::System::GhostFile::m_inputSize
u16 m_inputSize
The size of the decompressed input data section.
Definition
GhostFile.hh:131
Kinoko::System::RawGhostFile
The binary data of a ghost saved to a file.
Definition
GhostFile.hh:45
Kinoko::System::RawGhostFile::isValid
bool isValid(const u8 *rkg) const
Definition
GhostFile.cc:120
Kinoko::System
High-level handling for generic system operations, such as input reading, race configuration,...
Definition
CourseMap.cc:5
Kinoko::System::Timer
A simple struct to represent a lap or race finish time.
Definition
TimerManager.hh:8
game
system
GhostFile.hh
Made by
Malleo
. Logo by
vabold
. Website generated by
Doxygen
1.17.0