cato-a / CoDaM_MiscMod

Official MiscMod for CoDaM in Call of Duty 1.1
BSD 3-Clause "New" or "Revised" License
15 stars 5 forks source link

scr_mm_emptymap crashes server #11

Closed ghost closed 1 year ago

ghost commented 1 year ago

Hello When I set a map to scr_mm_emptymap, I start server, (default map is the same as the one I set in emptymap), then I switch to another map, then disconnect.

After about 1 minute, I get the following error:

******* script runtime error *******
exitlevel already called: (file 'codam\compat.gsc', line 125)
 return( map_restart( a0 ) );

Do you have an idea about how to prevent this issue?

edit:

After commenting out L241, the error is gone, but according to the game's server list, the map did not change to the emptymap.

ghost commented 1 year ago

All seem fixed after replacing the func by this one:

_timerStuck()
{
    if (!isDefined(game["maprestarts"]))
    {
        game["maprestarts"] = 0;
    }

    for(;;)
    {
        wait 60;

        players = getEntArray("player", "classname");

        if (players.size == 0)
        {
            emptymap = codam\utils::getVar("scr_mm", "emptymap", "string", 0, "");

            if (emptymap != "")
            {
                if (emptymap == level.mmmapname)
                {
                    if (game["maprestarts"] > 7)
                    {
                        [[level.gtd_call]]("map_restart", false);
                    }
                    else
                    {
                        game["maprestarts"]++;
                        [[level.gtd_call]]("map_restart", true);
                    }
                }
                else
                {
                    setCvar("sv_mapRotationCurrent", "gametype " + level.mmgametype + " map " + emptymap);
                    wait 1;

                    level.mapended = true;
                    game["state"] = "intermission";
                    level notify("intermission");
                    [[level.gtd_call]]("exitLevel", false);
                }
            }
            else
            {
                if (game["maprestarts"] > 7)
                {
                    level notify("end_map");
                }
                else
                {
                    game["maprestarts"]++;
                    [[ level.gtd_call ]]("map_restart", true);
                }
            }
        }
        else
        {
            if (game["maprestarts"] != 0)
            {
                game["maprestarts"] = 0;
            }
        }
    }
}
cato-a commented 1 year ago

Hi, when an issue is solved for you it doesn't mean it's solved for MiscMod. This issue I presume is only when you run server with developer 1, as bdz said he tested this and it was without issue, maybe he did not test it fully.

Can you test the following (similar to yours) code with developer 1 for inclusion into MiscMod?

_timerStuck() // tip by Jona
{
    if(!isDefined(game["maprestarts"]))
        game["maprestarts"] = 0;

    for(;;) {
        wait 60;

        players = getEntArray("player", "classname");
        if(players.size == 0) {
            emptymap = codam\utils::getVar("scr_mm", "emptymap", "string", 0, "");
            if(emptymap != "") {
                if(emptymap != level.mmmapname) {
                    setCvar("sv_mapRotationCurrent", "gametype " + level.mmgametype + " map " + emptymap);
                    wait 1;
                    level.mapended = true;
                    game["state"] = "intermission";
                    level notify("intermission");
                    [[ level.gtd_call ]]("exitLevel", false);
                } else
                    [[ level.gtd_call ]]("map_restart", false);
            } else {
                if(game["maprestarts"] > 7) {
                    level notify("end_map"); // idea is to just rotate the map
                    return;
                }

                game["maprestarts"]++;
                [[ level.gtd_call ]]("map_restart", true); // true playerinfo retained
            }
        } else {
            if(game["maprestarts"] != 0)
                game["maprestarts"] = 0;
        }
    }
}
ghost commented 1 year ago

I would now let you close issues I opened even if I think I posted a fix

After replacing the code I posted by yours:

-started server with developer 1, joined game -rotated to an other map, disconnected client

After about 1 minute, the server rotated to the scr_mm_emptymap

I did not notice any issue/error message Thank you

cato-a commented 1 year ago

Thanks for testing. Commit: https://github.com/cato-a/CoDaM_MiscMod/commit/72317515c78b10a8090f47d7a574ec7734204c9c.

If you want to submit code to MiscMod you need to follow the STYLE guide:

https://github.com/cato-a/CoDaM_MiscMod/blob/main/STYLE.md