GunshipPenguin / afkkick

Afk Kick mod for minetest - This mod has been included in the serveressentials mod (http://github.com/GunshipPenguin/serveressentials), further development will take place there.
Creative Commons Zero v1.0 Universal
3 stars 5 forks source link

Crashes server if using the --terminal option and chat #4

Open grantcarthew opened 4 years ago

grantcarthew commented 4 years ago

Hi Rhys,

I have a CTF server and it crashes if I try to chat from the terminal. Not that chatting from the server terminal make sense however if I miss-type the / and hit enter, the server crashes.

I have compiled the server with ncurses enabled and am launching the server with the --terminal option. This gives me the ability to run commands from the terminal. Read the wiki document for more detail.

Technically it is not your mod that is causing the issue, it is a copy of it over into the CTF mod however it looks like the same line of code will cause issues in this mod.

The reported issue in the CTF game is on this line: https://github.com/MT-CTF/capturetheflag/blob/b1aa1366f40b099f878edbfcf5c1a6af5d8fd258/mods/other/afkkick/init.lua#L32

That translates to this line within this mod: https://github.com/GunshipPenguin/afkkick/blob/1ad26458234b599fcee2c7a7286f8751a4b33c14/init.lua#L30

Here is the error message on the console:

2020-05-08 11:55:39: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'afkkick' in callback on_chat_message(): .../../games/capturetheflag/mods/other/afkkick/init.lua:32: attempt to index field '?' (a nil value)
2020-05-08 11:55:39: ERROR[Main]: stack traceback:
2020-05-08 11:55:39: ERROR[Main]:   .../../games/capturetheflag/mods/other/afkkick/init.lua:32: in function '?'
2020-05-08 11:55:39: ERROR[Main]:   /minetest/ctf/bin/../builtin/game/register.lua:429: in function </minetest/ctf/bin/../builtin/game/register.lua:413>

I imagine the issue is that there is no player logged in because it is from ther terminal, so the playername values will be null.

grantcarthew commented 4 years ago

I've raised a cross issue on the CTF server repo.

https://github.com/MT-CTF/capturetheflag/issues/623

Beanzilla commented 3 years ago

It appears that they made a fix to this... and we just needed to add their fix to our code.

My PR should fix this.