mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2026-04-22 01:52:43 +00:00
Add object limit to reduce chances of breaking
This commit is contained in:
parent
1e0b902f12
commit
0e998a672a
4 changed files with 14 additions and 8 deletions
|
|
@ -6668,7 +6668,7 @@ TIME_STOP_MARIO_OPENED_DOOR = (1 << 5)
|
|||
TIME_STOP_ACTIVE = (1 << 6)
|
||||
|
||||
--- @type integer
|
||||
OBJECT_POOL_CAPACITY = 0xFFFFFFFF
|
||||
OBJECT_POOL_CAPACITY = 4096
|
||||
|
||||
--- @type integer
|
||||
OBJECT_POOL_NODE_CAPACITY = 256
|
||||
|
|
|
|||
|
|
@ -22,9 +22,8 @@
|
|||
|
||||
/**
|
||||
* The maximum number of objects that can be loaded at once.
|
||||
* Kept for compatibility, but is unused.
|
||||
*/
|
||||
#define OBJECT_POOL_CAPACITY 0xFFFFFFFF
|
||||
#define OBJECT_POOL_CAPACITY 4096
|
||||
/**
|
||||
* The maximum number of objects that can be in a single pool node.
|
||||
* A higher number might be better for less fragmentation.
|
||||
|
|
|
|||
|
|
@ -108,12 +108,15 @@ struct Object* try_allocate_object(struct ObjectNode* destList, struct ObjectPoo
|
|||
}
|
||||
destList->prev = nextObj;
|
||||
} else {
|
||||
if (node->next != NULL) {
|
||||
return try_allocate_object(destList, node->next);
|
||||
if (gPrevFrameObjectCount > OBJECT_POOL_CAPACITY) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (node->next == NULL) {
|
||||
node->next = (struct ObjectPoolNode*)calloc(1, sizeof(struct ObjectPoolNode));
|
||||
reinit_objects(node->next);
|
||||
}
|
||||
|
||||
node->next = (struct ObjectPoolNode*)calloc(1, sizeof(struct ObjectPoolNode));
|
||||
reinit_objects(node->next);
|
||||
return try_allocate_object(destList, node->next);
|
||||
}
|
||||
|
||||
|
|
@ -288,6 +291,10 @@ struct Object *allocate_object(struct ObjectNode *objList) {
|
|||
// If an unimportant object does exist, unload it and take its slot.
|
||||
unload_object(unimportantObj);
|
||||
obj = try_allocate_object(objList, &gObjectPool);
|
||||
if (obj == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (gCurrentObject == obj) {
|
||||
//! Uh oh, the unimportant object was in the middle of
|
||||
// updating! This could cause some interesting logic errors,
|
||||
|
|
|
|||
|
|
@ -2976,7 +2976,7 @@ char gSmluaConstants[] = ""
|
|||
"TIME_STOP_ALL_OBJECTS=(1 << 4)\n"
|
||||
"TIME_STOP_MARIO_OPENED_DOOR=(1 << 5)\n"
|
||||
"TIME_STOP_ACTIVE=(1 << 6)\n"
|
||||
"OBJECT_POOL_CAPACITY=0xFFFFFFFF\n"
|
||||
"OBJECT_POOL_CAPACITY=4096\n"
|
||||
"OBJECT_POOL_NODE_CAPACITY=256\n"
|
||||
"OBJ_LIST_PLAYER=0\n"
|
||||
"OBJ_LIST_EXT=1\n"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue