1#include "ResourceManager.hh"
3#include "game/system/RaceConfig.hh"
9static const char *
const RESOURCE_PATHS[] = {
15void *ResourceManager::getFile(
const char *filename,
size_t *size, ArchiveId
id) {
16 s32 idx =
static_cast<s32
>(id);
17 return m_archives[idx]->isLoaded() ? m_archives[idx]->getFile(filename, size) :
nullptr;
21void *ResourceManager::getBsp(Vehicle vehicle,
size_t *size) {
24 const char *name = GetVehicleName(vehicle);
25 snprintf(buffer,
sizeof(buffer),
"/bsp/%s.bsp", name);
27 return m_archives[0]->isLoaded() ? m_archives[0]->getFile(buffer, size) :
nullptr;
31MultiDvdArchive *ResourceManager::load(s32 idx,
const char *filename) {
36 filename = RESOURCE_PATHS[idx];
39 if (!m_archives[idx]->isLoaded() && filename) {
40 m_archives[idx]->load(filename);
43 return m_archives[idx];
47MultiDvdArchive *ResourceManager::load(Course courseId) {
49 snprintf(buffer,
sizeof(buffer),
"Race/Course/%s", COURSE_NAMES[
static_cast<s32
>(courseId)]);
50 m_archives[1]->load(buffer);
55void ResourceManager::unmount(MultiDvdArchive *archive) {
60ResourceManager *ResourceManager::CreateInstance() {
62 s_instance =
new ResourceManager;
67void ResourceManager::DestroyInstance() {
69 auto *instance = s_instance;
75ResourceManager::ResourceManager() {
76 m_archives =
new MultiDvdArchive *[ARCHIVE_COUNT];
77 for (u8 i = 0; i < ARCHIVE_COUNT; i++) {
78 m_archives[i] = Create(i);
83ResourceManager::~ResourceManager() {
86 WARN(
"ResourceManager instance not explicitly handled!");
91MultiDvdArchive *ResourceManager::Create(u8 i) {
94 return new MultiDvdArchive;
98ResourceManager *ResourceManager::s_instance =
nullptr;
High-level handling for generic system operations, such as input reading, race configuration,...