Fix crash throwing snowball at (runaway=true) mobs #2802

Merged
epCode merged 1 commits from fix_snowball_crash into master 2022-10-17 03:14:00 +02:00
Contributor

In case of a snowball (or other projectile i guess) hitting the mob the "hitter" is the thrown object which will in some cases already be gone when processed by the mob resulting in it's get_pos returning nil.

just nil checking objects for this is not enough btw. as the object var itsself can well still be around but all the methods return nil ( https://rubenwardy.com/minetest_modding_book/en/quality/common_mistakes.html#be-careful-when-storing-objectrefs-ie-players-or-entities )

This PR fixes #2800

Testing

  • spawn a mob that will run away from the player when hit e.g. a cow or a villager ( /grantme debug, /spawn_mob cow )
  • throw a snowball at it ( /grantme give, /giveme mcl_throwing:snowball -1 )
  • observe it crashes on master but not on this branch
In case of a snowball (or other projectile i guess) hitting the mob the "hitter" is the thrown object which will in some cases already be gone when processed by the mob resulting in it's get_pos returning nil. just nil checking objects for this is not enough btw. as the object var itsself can well still be around but all the methods return nil ( https://rubenwardy.com/minetest_modding_book/en/quality/common_mistakes.html#be-careful-when-storing-objectrefs-ie-players-or-entities ) This PR fixes #2800 ### Testing * spawn a mob that will run away from the player when hit e.g. a cow or a villager ( /grantme debug, /spawn_mob cow ) * throw a snowball at it ( /grantme give, /giveme mcl_throwing:snowball -1 ) * observe it crashes on master but not on this branch
cora added 1 commit 2022-10-16 22:24:55 +02:00
Member

sorry about this.

sorry about this.
Member

Works 👍

Works 👍
epCode approved these changes 2022-10-17 01:51:30 +02:00
Author
Contributor

sorry about this.

don't worry that's why we're testing things. when you're working on a core mechanic like this theres always many things you just don't think of testing at the time.

> sorry about this. don't worry that's why we're testing things. when you're working on a core mechanic like this theres always many things you just don't think of testing at the time.
epCode merged commit 38ff7af9fe into master 2022-10-17 03:14:00 +02:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: VoxeLibre/VoxeLibre#2802
No description provided.