Pottus/ColAndreas

ERROR: CA_RemoveBuilding : Map has already been initialized. Use this before CA_Init.

Zorono opened this issue · 2 comments

i had already removed those buildings using CA_RemoveBuilding before initializing using CA_Init under OnGameModeInit...
however, when i call the command gmx the whole server gonna crazy and gets full of ERROR: CA_RemoveBuilding : Map has already been initialized. Use this before CA_Init. errors...

as i am removing buildings again from the Database after Server restart so ColAndreas is already initialized and the Buildings is already removed... which is annoying

Seems that either the plugin or you will have to somehow check whether this gamemode loading due to server restart or the server was started for the first time. I can recommend the following code on your part at the moment:

public OnGameModeInit()
{
    if(GetSVarInt("gmxCounter") == 0)
    {
        //Do your remove objects stuff
        CA_Init();
    }
    SetSVarInt("gmxCounter", GetSVarInt("gmxCounter") + 1);
    return 1;
}

Yes for quite a few reasons this would not be changed. Deciding whether objects should be removed is up to the mode. Like, some servers literally use different modes. And filterscripts. TextureStudio for example could be broken by this if it was designed to also remove collisions, any map editor would. Or another example might be servers that debug or test with gmx, if changes were made to the collision stuff things could get messy. In all these cases the server variable example is probably best suited actually.

Think like a callback would be sufficient for what you need? Like, by default the CA_RemoveBuilding function could call "OnCollisionRemove" with parameters to know whether it failed or not. There would just be a parameter in CA_RemoveBuilding so that this call could be disabled (would speed up server load because less calls, if for example the callback had a lot of code in it for some reason). Similar callbacks for other things could be useful as well.