Fix corpses crash

This commit is contained in:
popux committed 2026-10-22 16:23:47 +02:00
1 parent 5787e3abbc
commit aa8c2754d9
3 files changed
+23 -4

No files matched your search

+1 -3
View File
@@ -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.
*/
+10
View File
@@ -2,6 +2,16 @@
#define _INITUNK_005450_H_
#include <ultra64.h>
/* 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
+12 -1
View File
@@ -1,6 +1,7 @@
#include <ultra64.h>
#include <memp.h>
#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;