mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2026-07-07 23:16:46 +00:00
When generating multiple actors, if two or more data nodes share the same name, the generated actors can reference the wrong nodes in their display lists/geo layouts. This results in: - The wrong nodes compiled into binary files - Intermediate layouts generated as actors since nothing is referencing them anymore, treating them as root geo layouts The simplest fix was to first check for the model identifier (renamed to `mDataIdentifier`, since it's no longer related to models) when looking for nodes, to ensure it picks the right node, even if multiple nodes share the same name.
77 lines
2.1 KiB
C++
77 lines
2.1 KiB
C++
#include "dynos.cpp.h"
|
|
extern "C" {
|
|
#include "game/area.h"
|
|
}
|
|
|
|
struct RegisteredMovtexQC {
|
|
DataNode<MovtexQC>* dataNode;
|
|
s16 level;
|
|
s16 area;
|
|
s16 type;
|
|
};
|
|
|
|
static std::vector<RegisteredMovtexQC> &DynosRegisteredMovtexQCs() {
|
|
static std::vector<RegisteredMovtexQC> sDynosRegisteredMovtexQCs;
|
|
return sDynosRegisteredMovtexQCs;
|
|
}
|
|
|
|
void DynOS_MovtexQC_Register(const char* name, s16 level, s16 area, s16 type) {
|
|
auto& _DynosRegisteredMovtexQCs = DynosRegisteredMovtexQCs();
|
|
|
|
// check for duplicates
|
|
for (auto& registered : _DynosRegisteredMovtexQCs) {
|
|
if (registered.level == level && registered.area == area && registered.type == type) { return; }
|
|
}
|
|
|
|
// find it in the levels
|
|
for (auto& lvlPair : DynOS_Lvl_GetArray()) {
|
|
auto node = lvlPair.second->mMovtexQCs.Find(name);
|
|
if (node) {
|
|
// add it
|
|
_DynosRegisteredMovtexQCs.push_back({
|
|
.dataNode = node,
|
|
.level = level,
|
|
.area = area,
|
|
.type = type
|
|
});
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
DataNode<MovtexQC>* DynOS_MovtexQC_GetFromId(u32 id) {
|
|
auto& _DynosRegisteredMovtexQCs = DynosRegisteredMovtexQCs();
|
|
|
|
// find the datanode
|
|
s16 type = (id & 0xF);
|
|
for (auto& registered : _DynosRegisteredMovtexQCs) {
|
|
if (registered.level == gCurrLevelNum && registered.area == gCurrAreaIndex && registered.type == type) {
|
|
return registered.dataNode;
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
DataNode<MovtexQC>* DynOS_MovtexQC_GetFromIndex(s32 index) {
|
|
GfxData* gfxData = DynOS_Lvl_GetActiveGfx();
|
|
if (gfxData == NULL) {
|
|
return NULL;
|
|
}
|
|
|
|
auto &mMovtexQCs = gfxData->mMovtexQCs;
|
|
|
|
// Sanity check the index we passed.
|
|
if (index < 0 || index >= mMovtexQCs.Count()) {
|
|
return NULL;
|
|
}
|
|
|
|
return mMovtexQCs[index];
|
|
}
|
|
|
|
void DynOS_MovtexQC_ModShutdown() {
|
|
auto& _DynosRegisteredMovtexQCs = DynosRegisteredMovtexQCs();
|
|
for (auto ®istered : _DynosRegisteredMovtexQCs) {
|
|
Delete(registered.dataNode);
|
|
}
|
|
_DynosRegisteredMovtexQCs.clear();
|
|
}
|