mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
fix dynamic custom model alloc
This commit is contained in:
parent
e9c6368210
commit
a0ad607b4e
1 changed files with 5 additions and 4 deletions
|
|
@ -527,13 +527,14 @@ enum ModelExtendedId smlua_model_util_get_id(const char* name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we've extended past our current custom model limit. Reallocate so we have more space.
|
// If we've extended past our current custom model limit. Reallocate so we have more space.
|
||||||
if (sCustomModelsCount >= sMaxCustomModelsCount && sMaxCustomModelsCount + CUSTOM_MODEL_CHUNK_SIZE < 65535) {
|
if (sCustomModelsCount >= sMaxCustomModelsCount) {
|
||||||
sMaxCustomModelsCount += CUSTOM_MODEL_CHUNK_SIZE;
|
if (sMaxCustomModelsCount + CUSTOM_MODEL_CHUNK_SIZE < 0xFFFF) {
|
||||||
sCustomModels = (struct ModelUtilsInfo *)realloc(sCustomModels, sMaxCustomModelsCount * sizeof(struct ModelUtilsInfo));
|
|
||||||
} else {
|
|
||||||
LOG_LUA("Failed to get model: '%s' (too many custom models!)", name);
|
LOG_LUA("Failed to get model: '%s' (too many custom models!)", name);
|
||||||
return E_MODEL_ERROR_MODEL;
|
return E_MODEL_ERROR_MODEL;
|
||||||
}
|
}
|
||||||
|
sMaxCustomModelsCount += CUSTOM_MODEL_CHUNK_SIZE;
|
||||||
|
sCustomModels = (struct ModelUtilsInfo *)realloc(sCustomModels, sMaxCustomModelsCount * sizeof(struct ModelUtilsInfo));
|
||||||
|
}
|
||||||
|
|
||||||
// Allocate custom model
|
// Allocate custom model
|
||||||
u16 customIndex = sCustomModelsCount++;
|
u16 customIndex = sCustomModelsCount++;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue