minetest-mapserver / mapserver_mod

Complementary mod for the minetest mapserver
17 stars 14 forks source link

[crash] mapserver_mod causes crashloop on EdenLost #20

Open dennisjenkins75 opened 2 years ago

dennisjenkins75 commented 2 years ago

I've got the mapserver binary running on EdenLost. However, when I add the mapserver_mod for its features, the server crashloops when loading the mod:

ServerError: AsyncErr: environment_Step: Runtime error from mod 'mapserver' in callback environment_Step(): ...worlds/world/worldmods/mapserver_mod/bridge/defaults.lua:5: bad argument #1 to 'gmatch' (string expected, got nil)
stack traceback:
        [C]: in function 'gmatch'
        ...worlds/world/worldmods/mapserver_mod/bridge/defaults.lua:5: in function 'explode'
        ...worlds/world/worldmods/mapserver_mod/bridge/defaults.lua:14: in function 'get_max_lag'
        ...worlds/world/worldmods/mapserver_mod/bridge/defaults.lua:22: in function 'add_defaults'
        ...hit/worlds/world/worldmods/mapserver_mod/bridge/init.lua:43: in function 'func'
        /home/1hit/multicraft/bin/../builtin/common/after.lua:20: in function </home/1hit/multicraft/bin/../builtin/common/after.lua:5>
        /home/1hit/multicraft/bin/../builtin/game/register.lua:441: in function </home/1hit/multicraft/bin/../builtin/game/register.lua:425>
dennisjenkins75 commented 2 years ago

Looks line minetest.get_server_status() returns nil (the server is "Multicraft" and not "minetest"), and the mod is not prepared to handle that.

From the API doc

* `minetest.get_server_status(name, joined)`
    * Returns the server status string when a player joins or when the command
      `/status` is called. Returns `nil` or an empty string when the message is
      disabled.

Well, /status is disabled. IDK why. I see nothing in the minetest.conf that explicitly disables /status. Maybe it defaults to disabled, and since not specified, is disabled. I'll keep digging.

dennisjenkins75 commented 2 years ago

Well, it looks like "/status" is actually intentionally nerfed in the C++ code for Multicraft.

https://github.com/MultiCraft/MultiCraft2/commit/2aa0400bd2a1c205de50ce46e1758f09e1b0c306 (committed 2021-02-14 as part of a mass code change merge into multicraft).

From multicraft/src/server.cpp

std::string Server::getStatusString()
{
        std::ostringstream os(std::ios_base::binary);

        // Disabled due to misuse.
        /*os << "# Server: ";
        // Version
        os << "version=" << g_version_string;
        // Uptime
        os << ", uptime=" << m_uptime_counter->get();
        // Max lag estimate
        os << ", max_lag=" << (m_env ? m_env->getMaxLagEstimate() : 0);

So we need to make mapserver_mod robust when minetest.get_server_status() returns nil.