minetest-LOTR / Lord-of-the-Test

LOTR-inspired Subgame for Minetest. Rewrite: https://github.com/minetest-LOTR/Third-Age
Other
67 stars 31 forks source link

Crash occurs when getting close to an enemy entity #159

Closed MCAnimators02 closed 4 years ago

MCAnimators02 commented 4 years ago

Every time I get close to another entity in the game, a crash occurs and shuts down my game.

information: OS: Ubuntu(linux) 20.04.1LTS Minetest version: 5.3 latest/stable

No mods were used during play Screenshot from 2020-07-19 22-46-35

Amaz1 commented 4 years ago

I wasn't able to reproduce this, but I pushed something that should hopefully fix it: https://github.com/minetest-LOTR/Lord-of-the-Test/commit/8742df24bffe12dec0571047ee916093122844fb

Would you be able to test that commit and see if it fixes the crash? Thanks!

hecktest commented 4 years ago

bad argument #1 to 'type' (value expected)

How about: if not (self.object and self.object:get_pos()) then return; end

hecktest commented 4 years ago

But after that is fixed, this happens: mobs/api.lua:205: attempt to index local 'b' (a nil value) The actual trouble is in: https://github.com/minetest-LOTR/Lord-of-the-Test/blob/8742df24bffe12dec0571047ee916093122844fb/mods/mobs/api.lua#L2028

You have to patch this check into every place where you use the position of a potentially deleted object.

Amaz1 commented 4 years ago

Are there any further crashes after https://github.com/minetest-LOTR/Lord-of-the-Test/commit/16761d597b37555634cfc60b3c6583592fdadb21? I updated the mobs api again.

hecktest commented 4 years ago

Doesn't crash any more, but my bow stopped working alright, that was an unrelated bug (possibly due to crashing), a fresh world works.

Amaz1 commented 4 years ago

Ah, excellent! Thank you very much for your help! @MCAnimators02 would you mind confirming if this solves your problem or not? I think it should, but just want to make sure!

I'll make a new release of LOTT on the contentDB, in a day or two, to ensure that everyone can get this fixed

hecktest commented 4 years ago

Just a hint; instead of validating every time get_pos or another property is needed, it would be more optimal to track down all entry points for entity code and bail out early there.

Amaz1 commented 4 years ago

I just copied the code from the latest commit of mobs api (https://notabug.org/TenPlus1/mobs_redo). Making large changes like that would make updating the api even harder, so unless that's done in tenplus1's repo, I'll stay away from doing that. Also, I don't have the time or interest to track down every entry point :P

Amaz1 commented 4 years ago

Seems to be fixed... If this reoccurs, this can be reopened/a new issue can be opened.