1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-07-30 18:00:24 +02:00

set target in Bat.updatePosition if unset (#363)

Prevent a null pointer dereference if updatePosition is called
before the enemy gets a chance to think, such as when loading
a game involving a flying bat with unlucky timing.

Fixes #362.
This commit is contained in:
Dmitri Shuralyov
2021-07-04 21:13:17 -04:00
committed by GitHub
parent be4ef39281
commit df95f15adf

View File

@@ -1611,6 +1611,9 @@ struct Bat : Enemy {
virtual void updatePosition() {
turn(state == STATE_FLY || state == STATE_ATTACK, BAT_TURN_SPEED);
if (!target)
target = (Character*)game->getLara(pos);
if (flying) {
float wy = waypoint.y - (target->stand != STAND_ONWATER ? 765.0f : 64.0f);
lift(wy - pos.y, BAT_LIFT_SPEED);
@@ -3513,4 +3516,4 @@ struct Winston : Enemy {
}
};
#endif
#endif