Beispiel #1
0
void IAGSEngine::DeleteDynamicSprite(int32 slot) {
  free_dynamic_sprite(slot);
}
Beispiel #2
0
// Prepares engine for actual save restore (stops processes, cleans up memory)
void DoBeforeRestore(PreservedParams &pp)
{
    pp.SpeechVOX = play.want_speech;
    pp.MusicVOX = play.separate_music_lib;

    unload_old_room();
    delete raw_saved_screen;
    raw_saved_screen = NULL;
    remove_screen_overlay(-1);
    is_complete_overlay = 0;
    is_text_overlay = 0;

    // cleanup dynamic sprites
    // NOTE: sprite 0 is a special constant sprite that cannot be dynamic
    for (int i = 1; i < spriteset.GetSpriteSlotCount(); ++i)
    {
        if (game.SpriteInfos[i].Flags & SPF_DYNAMICALLOC)
        {
            // do this early, so that it changing guibuts doesn't
            // affect the restored data
            free_dynamic_sprite(i);
        }
    }

    // cleanup GUI backgrounds
    for (int i = 0; i < game.numgui; ++i)
    {
        delete guibg[i];
        guibg[i] = NULL;

        if (guibgbmp[i])
            gfxDriver->DestroyDDB(guibgbmp[i]);
        guibgbmp[i] = NULL;
    }

    // preserve script data sizes and cleanup scripts
    pp.GlScDataSize = gameinst->globaldatasize;
    delete gameinstFork;
    delete gameinst;
    gameinstFork = NULL;
    gameinst = NULL;
    pp.ScMdDataSize.resize(numScriptModules);
    for (int i = 0; i < numScriptModules; ++i)
    {
        pp.ScMdDataSize[i] = moduleInst[i]->globaldatasize;
        delete moduleInstFork[i];
        delete moduleInst[i];
        moduleInst[i] = NULL;
    }

    play.FreeProperties();

    delete roominstFork;
    delete roominst;
    roominstFork = NULL;
    roominst = NULL;

    delete dialogScriptsInst;
    dialogScriptsInst = NULL;

    resetRoomStatuses();
    troom.FreeScriptData();
    troom.FreeProperties();
    free_do_once_tokens();

    // unregister gui controls from API exports
    // TODO: find out why are we doing this here? perhaps remove if we do full managed pool reset in DoBeforeRestore
    for (int i = 0; i < game.numgui; ++i)
    {
        unexport_gui_controls(i);
    }

    // NOTE: channels are array of MAX_SOUND_CHANNELS+1 size
    for (int i = 0; i <= MAX_SOUND_CHANNELS; ++i)
    {
        stop_and_destroy_channel_ex(i, false);
    }

    clear_music_cache();
}