diff --git a/src/game/initunk_005450.c b/src/game/initunk_005450.c index 197a358e..47600d39 100644 --- a/src/game/initunk_005450.c +++ b/src/game/initunk_005450.c @@ -2,13 +2,11 @@ #include "bondtypes.h" #include "initunk_005450.h" -#define MODELHITENTRIES_LEN 600 - extern struct ModelHitEntry *g_ModelHitFreeList; // canonically freedist /** * These are linker/BSS labels. g_ModelHitEntries is the start of a - * ModelHitEntry[600] pool. g_ModelHitEntriesPenultimate labels entry 598 + * ModelHitEntry[MODELHITENTRIES_LEN] pool. g_ModelHitEntriesPenultimate labels entry 598 * inside that same pool and is kept as a raw char symbol so IDO emits the * original relocation. */ diff --git a/src/game/initunk_005450.h b/src/game/initunk_005450.h index d2648633..398f689a 100644 --- a/src/game/initunk_005450.h +++ b/src/game/initunk_005450.h @@ -2,6 +2,16 @@ #define _INITUNK_005450_H_ #include +/* Hit-test/draw-order entries shared by every model drawn in a frame (each + * chr takes one per drawable node, ~20-30). PC: room for many more drawn + * chrs, e.g. bodies kept by Game.MaxCorpses; exhausting the pool left later + * chrs without entries and crashed the next shot test. */ +#if defined(PLATFORM_64BIT) +#define MODELHITENTRIES_LEN 8192 +#else +#define MODELHITENTRIES_LEN 600 +#endif + void initModelHitEntryFreeList(void); #endif diff --git a/src/game/objecthandler.c b/src/game/objecthandler.c index 03098e1f..c8ad17d7 100644 --- a/src/game/objecthandler.c +++ b/src/game/objecthandler.c @@ -1,6 +1,7 @@ #include #include #include "objecthandler.h" +#include "initunk_005450.h" #include "model.h" // bss @@ -11,7 +12,7 @@ // writes 600*40 bytes from g_ModelHitEntries and overruns the N64-sized placeholders // by 12KB into adjacent .bss globals. Size the pool for the real struct on PC; keep // the original placeholder chain verbatim on N64. -char g_ModelHitEntries[600 * sizeof(ModelHitEntry)]; +char g_ModelHitEntries[MODELHITENTRIES_LEN * sizeof(ModelHitEntry)]; #else //CODE.bss:80076A50 char g_ModelHitEntries[0xC]; @@ -1269,6 +1270,16 @@ s32 sub_GAME_7F06C010(ModelHitEntry **entryptr, coord3d *modelRayStart, coord3d { ModelHitEntry *entry = *entryptr; +#ifdef PORT + /* No entries (the shared pool ran out while drawing): nothing to hit */ + if (entry == NULL) + { + *outModel = NULL; + *outNode = NULL; + return 0; + } +#endif + while (entry->next != NULL) { entry = entry->next;