-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
228 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include "game/system/map/MapdataCheckPath.hh" | ||
|
||
namespace System { | ||
|
||
MapdataCheckPath::MapdataCheckPath(const SData *data) : m_rawData(data), m_depth(-1) { | ||
u8 *unsafeData = reinterpret_cast<u8 *>(const_cast<SData *>(data)); | ||
EGG::RamStream stream = EGG::RamStream(unsafeData, sizeof(SData)); | ||
read(stream); | ||
m_oneOverCount = 1.0f / m_size; | ||
} | ||
|
||
void MapdataCheckPath::read(EGG::Stream &stream) { | ||
m_start = stream.read_u8(); | ||
m_size = stream.read_u8(); | ||
for (auto &prev : m_prev) { | ||
prev = stream.read_u8(); | ||
} | ||
|
||
for (auto &next : m_next) { | ||
next = stream.read_u8(); | ||
} | ||
} | ||
|
||
MapdataCheckPathAccessor::MapdataCheckPathAccessor(const MapSectionHeader *header) | ||
: MapdataAccessorBase<MapdataCheckPath, MapdataCheckPath::SData>(header) { | ||
init(reinterpret_cast<const MapdataCheckPath::SData *>(m_sectionHeader + 1), | ||
parse<u16>(m_sectionHeader->count)); | ||
} | ||
|
||
MapdataCheckPathAccessor::~MapdataCheckPathAccessor() = default; | ||
|
||
} // namespace System |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#pragma once | ||
|
||
#include "game/system/map/MapdataAccessorBase.hh" | ||
|
||
#include <egg/math/Vector.hh> | ||
|
||
namespace System { | ||
|
||
class MapdataCheckPath { | ||
public: | ||
struct SData { | ||
u8 start; | ||
u8 size; | ||
|
||
u8 prev[6]; | ||
u8 next[6]; | ||
u8 _0e[0x10 - 0x0e]; | ||
}; | ||
STATIC_ASSERT(sizeof(SData) == 0x10); | ||
|
||
MapdataCheckPath(const SData *data); | ||
void read(EGG::Stream &stream); | ||
|
||
private: | ||
const SData *m_rawData; | ||
u8 m_start; ///< Index of the first checkpoint in this checkpath | ||
u8 m_size; ///< Number of checkpoints in this checkpath | ||
std::array<u8, 6> m_prev; ///< Indices of previous connected checkpaths | ||
std::array<u8, 6> m_next; ///< Indices of next connected checkpaths | ||
s8 m_depth; ///< Number of checkpaths away from first checkpath (i.e. distance from start) | ||
f32 m_oneOverCount; | ||
}; | ||
|
||
class MapdataCheckPathAccessor | ||
: public MapdataAccessorBase<MapdataCheckPath, MapdataCheckPath::SData> { | ||
public: | ||
MapdataCheckPathAccessor(const MapSectionHeader *header); | ||
~MapdataCheckPathAccessor() override; | ||
}; | ||
|
||
} // namespace System |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include "MapdataCheckPoint.hh" | ||
|
||
#include "game/system/CourseMap.hh" | ||
|
||
namespace System { | ||
|
||
/// @addr{0x805154E4} | ||
MapdataCheckPoint::MapdataCheckPoint(const SData *data) | ||
: m_rawData(data), m_nextCount(0), m_prevCount(0) { | ||
u8 *unsafeData = reinterpret_cast<u8 *>(const_cast<SData *>(data)); | ||
EGG::RamStream stream = EGG::RamStream(unsafeData, sizeof(SData)); | ||
read(stream); | ||
m_midpoint = 0.5f * (m_left + m_right); | ||
m_dir = EGG::Vector2f(m_left.y - m_right.y, m_right.x - m_left.x); | ||
m_dir.normalise(); | ||
} | ||
|
||
void MapdataCheckPoint::read(EGG::Stream &stream) { | ||
m_left.read(stream); | ||
m_right.read(stream); | ||
m_jugemIndex = stream.read_u8(); | ||
m_checkArea = stream.read_s8(); | ||
m_prevPt = stream.read_u8(); | ||
m_nextPt = stream.read_u8(); | ||
} | ||
|
||
MapdataCheckPointAccessor::MapdataCheckPointAccessor(const MapSectionHeader *header) | ||
: MapdataAccessorBase<MapdataCheckPoint, MapdataCheckPoint::SData>(header) { | ||
MapdataAccessorBase::init( | ||
reinterpret_cast<const MapdataCheckPoint::SData *>(m_sectionHeader + 1), | ||
parse<u16>(m_sectionHeader->count)); | ||
} | ||
|
||
MapdataCheckPointAccessor::~MapdataCheckPointAccessor() = default; | ||
|
||
} // namespace System |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#pragma once | ||
|
||
#include "game/system/map/MapdataAccessorBase.hh" | ||
|
||
#include <egg/math/Vector.hh> | ||
|
||
namespace System { | ||
|
||
class MapdataCheckPoint { | ||
public: | ||
struct SData { | ||
EGG::Vector2f left; | ||
EGG::Vector2f right; | ||
u8 jugemIndex; | ||
s8 checkArea; | ||
u8 prevPt; | ||
u8 nextPt; | ||
}; | ||
STATIC_ASSERT(sizeof(SData) == 0x14); | ||
|
||
MapdataCheckPoint(const SData *data); | ||
void read(EGG::Stream &stream); | ||
|
||
private: | ||
const SData *m_rawData; | ||
EGG::Vector2f m_left; | ||
EGG::Vector2f m_right; | ||
u8 m_jugemIndex; ///< Index of respawn point associated with this checkpoint. Players who die | ||
///< here will be respawned at this point. | ||
s8 m_checkArea; | ||
u8 m_prevPt; | ||
u8 m_nextPt; | ||
u16 m_nextCount; | ||
u16 m_prevCount; | ||
EGG::Vector2f m_midpoint; | ||
EGG::Vector2f m_dir; | ||
}; | ||
|
||
class MapdataCheckPointAccessor | ||
: public MapdataAccessorBase<MapdataCheckPoint, MapdataCheckPoint::SData> { | ||
public: | ||
MapdataCheckPointAccessor(const MapSectionHeader *header); | ||
~MapdataCheckPointAccessor() override; | ||
}; | ||
|
||
} // namespace System |