User:Ccw: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 2: Line 2:
= Things that keep me awake at night =
= Things that keep me awake at night =


== WARNING: Gamemodes which depend on being started with the mapmanager may explode==
== Crash #1 ==


That is, gamemodes which either use the mapmanger events '''onGamemodeStop()/Start()''' or ''' onGamemodeMapStop()/Start()''' or depend on the 'one gamemode at a time' system enforced by the mapmanager, may malfunction if invoked with 'start gamemode' or startResource().
* (&CClientGame::OnMouseClick) callback had invalid 'this' pointer for CClientGame
** g_pClientGame gets renewed every connect. Perhaps a previous pointer was left behind somewhere.


Affected gamemodes are:


*assault
== Crash #2 ==
*battlefield69
*cdm
*ctf
*cto
*ctv
*fallout
*hay
*interstate69
*race
*stealth
*tdma
*teamwars
*freeroam


Noob admins who don't use the mapmanger will have gamemode errors with little obvious reason why.
* GUI Redraw queue contained an invalid item (possibly CGUIStaticImage_Impl)
Also, stuff like the web browser and the admin panel, all start resources with startResource(), which will not work correctly with the gamemodes listed above.
** CGUIStaticImage_Impl::Clear() queues itself just before destruction. Problems near here?
 
 
=== Solution A ===
When starting a gamemode from inside a script, instead of using:
<syntaxhighlight lang="lua">
    startResource( getResourceFromName('gamemode') )
</syntaxhighlight>
use this instead:
<syntaxhighlight lang="lua">
    exports.mapmanager:changeGamemode( getResourceFromName('gamemode') )
</syntaxhighlight>
 
 
=== Solution B ===
Or, perhaps a more better way would be to insert this bit of code into each affected gamemode:
 
<syntaxhighlight lang="lua">
----------------------------------------------------
-- Divert to mapmanager if 'start' command used
----------------------------------------------------
addEventHandler('onResourceStart', g_ResRoot,
    function()
        setTimer(
            function()
                if not g_bCalledOnGamemodeStart then
                    outputConsole( "Trying to restart '" .. getResourceName(getThisResource()) .. "' with mapmanager..." )
                    exports.mapmanager:changeGamemode( getThisResource() )
                end
            end
            ,900,1)
end
)
 
addEventHandler('onGamemodeStart', g_ResRoot,
    function()
        g_bCalledOnGamemodeStart = true
    end
)
</syntaxhighlight>
 
 
Both solutions assume the mapmanger is up and running first. But that is requirement for these gamemodes anyway.

Revision as of 03:06, 3 April 2009

Things that keep me awake at night

Crash #1

  • (&CClientGame::OnMouseClick) callback had invalid 'this' pointer for CClientGame
    • g_pClientGame gets renewed every connect. Perhaps a previous pointer was left behind somewhere.


Crash #2

  • GUI Redraw queue contained an invalid item (possibly CGUIStaticImage_Impl)
    • CGUIStaticImage_Impl::Clear() queues itself just before destruction. Problems near here?