Lord-of-the-Test icon indicating copy to clipboard operation
Lord-of-the-Test copied to clipboard

lottthrowing crash

Open MoNTE48 opened this issue 1 year ago • 4 comments

2023-07-16 05:58:37: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'lottthrowing' in callback luaentity_Step(): ...n/../games/lordofthetest/mods/lottthrowing/arrow.lua:120: attempt to index field 'player' (a nil value)
2023-07-16 05:58:37: ERROR[Main]: stack traceback:
2023-07-16 05:58:37: ERROR[Main]: 	...n/../games/lordofthetest/mods/lottthrowing/arrow.lua:120: in function <...n/../games/lordofthetest/mods/lottthrowing/arrow.lua:84>

MoNTE48 avatar Jul 16 '23 07:07 MoNTE48

- if self.player ~= "" then
+ if self.player and self.player:is_player() then

MoNTE48 avatar Jul 16 '23 07:07 MoNTE48

Hi,

Thanks for the bug report. I was about to commit your fix, but I think there's more to the bug than meets the eye at first. If you look in the function lottthrowing_shoot_arrow in init.lua, the field player of the placed entity is set to the actual ObjectRef of the player, which is probably not the sensible thing to do here (and then it doesn't make any sense to compare player to ""). I'm assuming that this should actually be set to the name of the player instead. Then the on_step callback in arrow.lua can use minetest.get_player_by_name to get the actual player.

@neinwhal thoughts?

lumidify avatar Jul 16 '23 18:07 lumidify

@lumidify, that's a good point. I suggested a simple fix given that LOTT is in maintenance mode. But I'm always in favor of a more proper and clean way of doing things.

MoNTE48 avatar Jul 16 '23 21:07 MoNTE48

good eye, yeah, the logic is broken. seems like a lazy attempt by me 7 years back to attempt to get mob detection for arrows; https://github.com/minetest-LOTR/Lord-of-the-Test/commit/44c16f7442636b7a6586e4776f6acfef4add9274 I should probably look through the rest of outdated code to spot for any other broken logic as well...

neinwhal avatar Jul 16 '23 23:07 neinwhal