Results 1 to 9 of 9

Thread: Evil crash bites my butt again

Hybrid View

  1. #1

    Default Evil crash bites my butt again

    But this time I found a script that actually trigger it rather easily...

    function OnInit() //run upon initialization
    end

    function OnPostInit() //run during the entity's first logic update
    thisMap = this:GetMap();
    --if --thisMap == GetMapManager:GetActiveMap() and
    --not thisMap:GetName() == "Gui_Stuff" then
    SpawnDefaultGui(); -- I am using a function in case I decide to support multiple GUIs
    --end
    end

    function OnKill() //run when removed
    DeleteDefaultGui();
    end

    function SpawnDefaultGui()
    BigBar = GetEntityByName("power_up_bar_big_template");
    YellowBar = GetEntityByName("power_up_bar_yellow_template");
    PinkBar = GetEntityByName("power_up_bar_pink_template");
    WhiteBar = GetEntityByName("power_up_bar_white_template");
    GreenBar = GetEntityByName("power_up_bar_green_template");

    GuiCover = GetEntityByName("gui_cover_template");

    big_bar = BigBar:Clone(thisMap, Vector2(0, 0));
    yellow_bar = YellowBar:Clone(thisMap, Vector2(0, 0));
    pink_bar = PinkBar:Clone(thisMap, Vector2(0, 0));
    white_bar = WhiteBar:Clone(thisMap, Vector2(0, 0));
    green_bar = GreenBar:Clone(thisMap, Vector2(0, 0));
    gui_cover = GuiCover:Clone(thisMap, Vector2(58, -6));
    end

    function DeleteDefaultGui()
    safe_delete(big_bar);
    safe_delete(yellow_bar);
    safe_delete(pink_bar);
    safe_delete(white_bar);
    safe_delete(green_bar);
    safe_delete(gui_cover);
    end

    function safe_delete(entity)
    if entity then entity:SetDeleteFlag(true); end
    end


    First, the "safe_delete" is totally non-safe, because it generate a error when entity is nil "big_bar does not exist"

    Anyway, it sorta worked, but as soon as I delete some object and re-loaded the script, the engine crashed...

    The same crash as the mentioned "random" crash in other topic.

    I realized that the engine hates when you call SetDeleteFlag(true) twice, it plainly crashes sometimes when you do that... So, there are a way to fix any of the issues I mentioned here? Including a way to allow me to "delete" stuff that is not even created yet?

  2. #2
    Lesser Wizard
    Join Date
    Mar 2008
    Posts
    124

    Default

    Cant you check if the Entity exists before trying to remove it?

    If !(GetEntityByName('big_bar-)=nil
    {
    safe_delete(big_bar);
    }

  3. #3

    Default

    I guess I will have to edit the C++ later, doing that in Lua totally don't work.

    But for now I am managing to avoid it with careful (VERY) lua coding.

  4. #4
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    4,245

    Default

    Calling entity:SetDeleteFlag(true) twice in a row shouldn't crash the engine as "entity" still exists until the end of the logic cycle. (if it does, that is a bug)

    However, refering an entity pointer after an entity has been deleted would - as it's just a pointer to random memory at that point.

    You should probably be doing:

    safe_delete(big_bar); big_bar = nil;

    to make sure you don't do that, otherwise the "safe_delete" function really has no meaning.
    Seth A. Robinson
    Robinson Technologies

  5. #5

    Default

    I noticed the crashes are triggered when I delete something, and the engine was going to delete it for another reason, like deleting a entity and then unloading the map.

    This trigger two deletes (and thus a deletion of a random pointer).

  6. #6

    Default

    The game is not frequently crashing, it crashes when closing, it crashes when unloading a map, it crashes when manipulating Watch Manager, and so on...

    But in all crashes, no matter how the stack trace looks (sometimes it look wildly different) one line is ALWAYS present:


    sig_delete(m_ID); (BaseGameEntity.cpp line 52)



    This is greatly bothering me, obviously the deleteflag thing is deleting invalid stuff, but I am not figuring how to figure if something is valid or not (specially because m_ID is a int, not a pointer, thus I cannot just verify if m_ID is valid or not).

Similar Threads

  1. CRASH
    By Hawk in forum Funeral Quest
    Replies: 4
    Last Post: 04-18-2010, 03:11 PM
  2. Crash this bug
    By huntercool in forum ClanLib: Developer Chat
    Replies: 2
    Last Post: 09-29-2009, 02:40 PM
  3. Evil Apprentice On Jewel Mountain
    By jenni53 in forum Dink Smallwood HD
    Replies: 2
    Last Post: 11-08-2004, 07:52 AM
  4. Saving Milder? Beating the Evil guy? HELP
    By in forum Dink Smallwood HD
    Replies: 2
    Last Post: 08-13-2004, 01:37 AM
  5. The evil &current_sprite
    By redink1 in forum Dink Smallwood HD
    Replies: 2
    Last Post: 10-09-2002, 06:23 PM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •