mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
move models to higher priority pools if needed
sometimes, a model may be loaded by the level, but then a mod loads it for the session, which causes issues so we move the model to the right pool.
This commit is contained in:
parent
f6d6de7fc8
commit
1bfe9d509c
2 changed files with 34 additions and 34 deletions
|
|
@ -65,40 +65,40 @@ void DynOS_Model_Dump() {
|
|||
|
||||
static struct GraphNode* DynOS_Model_LoadCommonInternal(u32* aId, enum ModelPool aModelPool, void* aAsset, u8 aLayer, struct GraphNode* aGraphNode, bool aDeDuplicate, enum ModelLoadType mlt) {
|
||||
// sanity check pool
|
||||
if (aModelPool >= MODEL_POOL_MAX) { return NULL; }
|
||||
if (aModelPool < 0 || aModelPool >= MODEL_POOL_MAX) { return NULL; }
|
||||
|
||||
// allocate pool
|
||||
if (!sModelPools[aModelPool]) {
|
||||
sModelPools[aModelPool] = dynamic_pool_init();
|
||||
}
|
||||
|
||||
// check perm map
|
||||
auto& permMap = sAssetMap[MODEL_POOL_PERMANENT];
|
||||
if (aDeDuplicate && permMap.count(aAsset)) {
|
||||
auto& found = permMap[aAsset];
|
||||
if (*aId && *aId == found.id) {
|
||||
return found.graphNode;
|
||||
}
|
||||
if (*aId == 0) {
|
||||
*aId = found.id;
|
||||
return found.graphNode;
|
||||
}
|
||||
}
|
||||
|
||||
// check map
|
||||
auto& map = sAssetMap[aModelPool];
|
||||
// check maps, permanent pool is always checked
|
||||
for (int i = 0; i < MODEL_POOL_MAX; ++i) {
|
||||
auto& map = sAssetMap[i];
|
||||
if (aDeDuplicate && map.count(aAsset)) {
|
||||
auto& found = map[aAsset];
|
||||
if (*aId && *aId != found.id) {
|
||||
|
||||
// if the expected pool has a higher priority,
|
||||
// we need to move the asset to the new pool
|
||||
if (i > aModelPool) {
|
||||
found.modelPool = aModelPool;
|
||||
sAssetMap[aModelPool][aAsset] = found;
|
||||
map.erase(aAsset);
|
||||
}
|
||||
|
||||
if (i != MODEL_POOL_PERMANENT && *aId && *aId != found.id) {
|
||||
sOverwriteMap[*aId] = found.id;
|
||||
}
|
||||
|
||||
*aId = found.id;
|
||||
return found.graphNode;
|
||||
}
|
||||
|
||||
sCurrModelDuplicates = new std::vector<void*>();
|
||||
if (i < aModelPool) { i = aModelPool; } // to force check permanent pool, and then skip to the expected pool
|
||||
}
|
||||
|
||||
// load geo
|
||||
auto& map = sAssetMap[aModelPool];
|
||||
sCurrModelDuplicates = new std::vector<void*>();
|
||||
struct GraphNode* node = NULL;
|
||||
switch (mlt) {
|
||||
case MLT_GEO:
|
||||
|
|
|
|||
|
|
@ -2745,7 +2745,7 @@ s32 cur_obj_progress_direction_table(void) {
|
|||
if (tableLength < 0 || index < 0 || tableLength >= 150 || index >= tableLength) {
|
||||
ret = table[0];
|
||||
o->oToxBoxMovementStep = 0;
|
||||
LOG_ERROR("Exceeded direction table! tableLength %d, index %d\n", tableLength, index);
|
||||
LOG_ERROR("Exceeded direction table! tableLength %d, index %d", tableLength, index);
|
||||
} else if (table[index] != -1) {
|
||||
ret = table[index];
|
||||
o->oToxBoxMovementStep++;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue