Prevent clearing permanent vanilla model slot

This commit is contained in:
MysterD 2023-06-05 15:19:33 -07:00
parent 7b47069611
commit 493fefd89a
1 changed files with 6 additions and 1 deletions

View File

@ -8,6 +8,8 @@ extern "C" {
#include "model_ids.h"
}
#define VANILLA_ID_END 255
enum ModelLoadType {
MLT_GEO,
MLT_DL,
@ -28,7 +30,7 @@ static std::map<u32, std::vector<struct ModelInfo>> sIdMap;
static std::map<u32, u32> sOverwriteMap;
static u32 find_empty_id() {
u32 id = 256;
u32 id = VANILLA_ID_END + 1;
while (true) {
if (id != 0) {
if (sIdMap.count(id) == 0) { return id; }
@ -199,6 +201,9 @@ void DynOS_Model_ClearPool(enum ModelPool aModelPool) {
auto& info = asset.second;
if (sIdMap.count(info.id) == 0) { continue; }
// preventing clearing permanent vanilla model slot
if (info.id <= VANILLA_ID_END && sIdMap.count(info.id) <= 1) { continue; }
// erase from id map
auto& idMap = sIdMap[info.id];
for (auto info2 = idMap.begin(); info2 != idMap.end(); ) {