A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
MapdataFileAccessor.cc
1#include "MapdataFileAccessor.hh"
2
3namespace System {
4
6MapdataFileAccessor::MapdataFileAccessor(const MapdataFileAccessor::SData *data) : m_rawData(data) {
7 u32 offset = parse<u16>(data->headerSize) - parse<u16>(data->sectionCount) * 4;
8 m_sectionDefOffset = offset;
9 m_sectionDef = reinterpret_cast<const u32 *>(reinterpret_cast<const u8 *>(m_rawData) + offset);
10 m_version = offset > 12 ? parse<u32>(m_sectionDef[-1]) : 0;
11}
12
14const MapSectionHeader *MapdataFileAccessor::findSection(u32 signature) const {
15 const MapSectionHeader *sectionPtr = nullptr;
16
17 for (size_t i = 0; i < parse<u16>(m_rawData->sectionCount); ++i) {
18 const MapSectionHeader *header =
19 reinterpret_cast<const MapSectionHeader *>(reinterpret_cast<const u8 *>(m_rawData) +
20 parse<u16>(m_rawData->headerSize) + parse<u32>(m_sectionDef[i]));
21 if (parse<u32>(header->magic) == signature) {
22 sectionPtr = header;
23 break;
24 }
25 }
26
27 return sectionPtr;
28}
29
30} // namespace System
High-level handling for generic system operations, such as input reading, race configuration,...
Definition CourseMap.cc:5