A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
KartParamFileManager.hh
1#pragma once
2
3#include "game/kart/KartParam.hh"
4
5#include "game/system/ResourceManager.hh"
6
7namespace Host {
8
9class Context;
10
11} // namespace Host
12
13namespace Kart {
14
19 friend class Host::Context;
20
21public:
22 void clear();
23 void init();
24 [[nodiscard]] EGG::RamStream getDriverStream(Character character) const;
25 [[nodiscard]] EGG::RamStream getVehicleStream(Vehicle vehicle) const;
26 [[nodiscard]] EGG::RamStream getHitboxStream(Vehicle vehicle) const;
27 [[nodiscard]] EGG::RamStream getBikeDispParamsStream(Vehicle vehicle) const;
28
29 static KartParamFileManager *CreateInstance();
30 static void DestroyInstance();
31
32 [[nodiscard]] static KartParamFileManager *Instance() {
33 return s_instance;
34 }
35
36private:
37 template <typename T>
38 struct ParamFile {
39 u32 count;
40 T params[];
41 };
42
43 struct FileInfo {
44 void clear() {
45 file = nullptr;
46 size = 0;
47 }
48
49 void load(const char *filename) {
50 auto *resourceManager = System::ResourceManager::Instance();
51 file = resourceManager->getFile(filename, &size, System::ArchiveId::Core);
52 }
53
54 void *file;
55 size_t size;
56 };
57
59 ~KartParamFileManager() override;
60
61 [[nodiscard]] bool validate() const;
62
63 FileInfo m_kartParam; // kartParam.bin
64 FileInfo m_driverParam; // driverParam.bin
65 FileInfo m_bikeDispParam; // bikePartsDispParam.bin
66
67 static KartParamFileManager *s_instance;
68};
69
70} // namespace Kart
An interface for ensuring certain structures and classes are destroyed with the heap.
Definition Disposer.hh:11
A stream of data stored in memory.
Definition Stream.hh:64
Contexts can be used to restore a previous memory state for the current session.
Definition Context.hh:59
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.
Represents the host application.
Definition HeapCommon.hh:9
Pertains to kart-related functionality.