Repository navigation
Conversation
Lara::checkTrigger() let heavy objects (boulders, blocks, enemies) trip any trigger type except the ones guarded explicitly. PAD triggers even compared Lara's height with the floor of the sector under the object, so a rolling boulder tripped every pad it passed while Lara stood on the same floor. In The Hive (room 18) this chained until almost all 25 hanging boulders fell, instead of the 1-3 linked to the pad Lara stepped on. The lava check had the same mix-up and could kill Lara when a heavy object was over lava at her height. As in the original, heavy objects now trip heavy triggers only, and the lava check runs only for Lara. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MutantEgg spawned its enemy without checking that the level has a model for it. The Hive has 22 eggs (and Atlantean Stronghold 8) coded to spawn a giant mutant, which neither level contains, so the egg crashed the game in Animation::initOverrides() on a NULL model. As in the original (and TRX), the egg now still shatters but spawns nothing in that case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes two bugs in The Hive (TR1 Unfinished Business,
END2.PHD). One of them also affects Atlantean Stronghold (END.PHD). The causes were found from the crash report and the level data (entities, floor data triggers and the model list).1. Hanging boulders in the first room: almost all of them fall instead of 1–3
Room 18, right after the start room. The red lumps on the ceiling are the boulders.
Symptom
Room 18 has 25
TRAP_BOULDERs in a 5×5 grid, 2048 units above a flat floor (-4608). The floor has 30 PAD trigger sectors (mask 31, no timer, not one-shot), plus 3 more at the entrance of room 19. Each sector activates 1–3 boulders, usually not the one right above it. Stepping on a sector should drop only the boulders linked to it.In OpenLara, almost all 25 boulders fall and roll at Lara after the first step.
Root cause
A boulder calls
game->checkTrigger(this, true)every frame while it rolls. InLara::checkTrigger():heavy = true, only theHEAVYcase was guarded (if (!heavy) return;for non-heavy callers). Every other trigger type could still be tripped by a heavy object.if (pos.y != info.floor) return;. Hereinfois read at the heavy object's sector, butposis Lara's position, because this is aLaramember function. Room 18 has a flat floor, so the check passed whenever Lara stood anywhere on it.So each rolling boulder tripped every PAD sector it rolled over. That dropped more boulders, which rolled over more PADs, and so on, until the room emptied.
The lava check at the top of the function has the same mix-up: a heavy object over a lava sector would kill Lara if her height matched that floor.
Fix
Lara::checkTrigger(), return early whenheavyis set and the trigger is notHEAVY. Heavy objects now trip only theHEAVYtriggers meant for them.This affects every heavy caller:
TrapBoulder,Block,MovingBlock,ThorHammer,GiantMutant,DoppelgangerandScionTarget. All of them now trip onlyHEAVYtriggers.2. Crash when Lara gets near some mutant eggs
The Hive: the area with the mutant eggs (rooms 9, 10 and 13).
Symptom
The game crashes when Lara gets close to some eggs:
Root cause
MutantEggpicks its enemy from the entity code bits: 1 = mutant 2, 2 = centaur, 4 = giant mutant, 8 = mutant 3, anything else = winged mutant. When it hatches, it callsgame->addEntity()without checking that the level has a model for that enemy.END2.PHD)END.PHD)addEntity()then setsmodelIndex = 0, andgetModel()returnsNULL. TheGiantMutantconstructor reachesAnimation::initOverrides(), which readsmodel->mCountat offset 6 of a NULL pointer. That matches the faulting address0x6.Fix
In
MutantEgg::update(), still shatter the egg, but calladdEntity()only whenlevel->getModelIndex(enemy)is non-zero. Eggs whose enemy has no model in the level now hatch empty instead of crashing.Testing
🤖 Generated with Claude Code