Skip to content

movealgo: allow InWater to ClimbUp transition - #1091

Open
Abendlied wants to merge 1 commit into
Try:masterfrom
Abendlied:fix-inwater-climbup
Open

Abendlied wants to merge 1 commit into
Try:masterfrom
Abendlied:fix-inwater-climbup

Conversation

@Abendlied

Copy link
Copy Markdown
Contributor

Problem

Debug builds abort with:

movealgo.cpp: void MoveAlgo::assertStateChange(State): Assertion `f==Run || f==Slide || f==Jump || f==JumpUp || f==Swim || f==Dive' failed.

Reproduced with a Gothic I save: an orc clan warrior (log shows "Ork Klankrieger") fell into the water under the bridge to the orc city while following the player, player wearing Ulu-Mulu. The orc clan warrior stayed there in the water. The water is partially shallow, so orc is wading.
Because of full world simulation approach, even distant NPCs are never dropped from memory. So the orc keeps walking through the shallow water and runs into the ledge again and again.

Cause

Backtrace:

    MoveAlgo::assertStateChange (f=ClimbUp)   flags = InWater
    MoveAlgo::setState
    MoveAlgo::startClimb
    Npc::startClimb
    MoveAlgo::onMoveFailed
    MoveAlgo::implTick
    MoveAlgo::tick

Wading orc move fails at a ledge, onMoveFailed asks Npc::tryJump() for a climb and gets a low enough climb-up option, so startClimb requests ClimbUp.

Npc::tryJump() only refuses climbing only while sliding, swimming or diving. InWater -> ClimbUp entry is missing.

Implementation

Add ClimbUp to the allowed transitions for InWater in MoveAlgo::assertStateChange.

Validation

  • Gothic2Notr and Spacer (debug) built on Linux.
  • Without the fix, the attached Gothic I save aborts reproducibly with the assertion above.
  • With the fix, the same save runs without the abort

Gothic I Savegame attached:
save_slot_5.sav.tar.gz

This will work for NPCs, too. Will also work in Gothic II, so not Gothic I specific.

An NPC wading in shallow water can start a climb from onMoveFailed when it walks into a ledge. Npc::tryJump only refuses climbing while sliding, swimming or diving, so wading is a valid start state, but assertStateChange did not list ClimbUp for InWater and aborted debug builds.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant