1#include "KartParamFileManager.hh"
6void KartParamFileManager::clear() {
9 m_bikeDispParam.clear();
15 m_kartParam.load(
"kartParam.bin");
16 m_driverParam.load(
"driverParam.bin");
17 m_bikeDispParam.load(
"bikePartsDispParam.bin");
19 PANIC(
"Parameter files could not be validated!");
23EGG::RamStream KartParamFileManager::getDriverStream(Character character)
const {
26 case Character::Small_Mii_Outfit_A_Male:
27 case Character::Small_Mii_Outfit_A_Female:
28 case Character::Small_Mii_Outfit_B_Male:
29 case Character::Small_Mii_Outfit_B_Female:
30 case Character::Small_Mii_Outfit_C_Male:
31 case Character::Small_Mii_Outfit_C_Female:
32 case Character::Small_Mii:
35 case Character::Medium_Mii_Outfit_A_Male:
36 case Character::Medium_Mii_Outfit_A_Female:
37 case Character::Medium_Mii_Outfit_B_Male:
38 case Character::Medium_Mii_Outfit_B_Female:
39 case Character::Medium_Mii_Outfit_C_Male:
40 case Character::Medium_Mii_Outfit_C_Female:
41 case Character::Medium_Mii:
44 case Character::Large_Mii_Outfit_A_Male:
45 case Character::Large_Mii_Outfit_A_Female:
46 case Character::Large_Mii_Outfit_B_Male:
47 case Character::Large_Mii_Outfit_B_Female:
48 case Character::Large_Mii_Outfit_C_Male:
49 case Character::Large_Mii_Outfit_C_Female:
50 case Character::Large_Mii:
54 if (character > Character::Rosalina) {
58 idx =
static_cast<s32
>(character);
62 auto *file =
reinterpret_cast<ParamFile<KartParam::Stats> *
>(m_driverParam.file);
64 return EGG::RamStream(&file->params[idx],
sizeof(KartParam::Stats));
67EGG::RamStream KartParamFileManager::getVehicleStream(Vehicle vehicle)
const {
68 if (vehicle >= Vehicle::Max) {
72 s32 idx =
static_cast<s32
>(vehicle);
73 auto *file =
reinterpret_cast<ParamFile<KartParam::Stats> *
>(m_kartParam.file);
75 return EGG::RamStream(&file->params[idx],
sizeof(KartParam::Stats));
78EGG::RamStream KartParamFileManager::getHitboxStream(Vehicle vehicle)
const {
79 if (vehicle >= Vehicle::Max) {
83 auto *resourceManager = System::ResourceManager::Instance();
86 auto *file = resourceManager->getBsp(vehicle, &size);
88 ASSERT(size ==
sizeof(BSP));
92EGG::RamStream KartParamFileManager::getBikeDispParamsStream(Vehicle vehicle)
const {
93 if (vehicle < Vehicle::Standard_Bike_S || vehicle >= Vehicle::Max) {
98 constexpr u32 KART_MAX = 18;
99 s32 idx =
static_cast<s32
>(vehicle) - KART_MAX;
101 auto *file =
reinterpret_cast<ParamFile<KartParam::BikeDisp> *
>(m_bikeDispParam.file);
103 return EGG::RamStream(&file->params[idx],
sizeof(KartParam::BikeDisp));
106KartParamFileManager *KartParamFileManager::CreateInstance() {
108 s_instance =
new KartParamFileManager;
112void KartParamFileManager::DestroyInstance() {
114 auto *instance = s_instance;
115 s_instance =
nullptr;
119KartParamFileManager::KartParamFileManager() {
123KartParamFileManager::~KartParamFileManager() {
125 s_instance =
nullptr;
126 WARN(
"KartParamFileManager instance not explicitly handled!");
133 if (!m_kartParam.file || m_kartParam.size == 0) {
138 if (m_kartParam.size != parse<u32>(kartFile->count) *
sizeof(
KartParam::Stats) + 4) {
143 if (!m_driverParam.file || m_driverParam.size == 0) {
148 if (m_driverParam.size != parse<u32>(driverFile->count) *
sizeof(
KartParam::Stats) + 4) {
153 if (!m_bikeDispParam.file || m_bikeDispParam.size == 0) {
158 if (m_bikeDispParam.size != parse<u32>(bikeDispFile->count) *
sizeof(
KartParam::BikeDisp) + 4) {
A stream of data stored in memory.
Abstraction for the process of retrieving kart parameters from files.
void init()
Loads and validates the kart parameter files.
bool validate() const
Performs a few checks to make sure the files were loaded successfully.
Pertains to kart-related functionality.
Various character/vehicle-related handling and speed stats.