AL_API ALvoid AL_APIENTRY alDeletePresetsSOFT(ALsizei n, const ALuint *ids) { ALCdevice *device; ALCcontext *context; ALsfpreset *preset; ALsizei i; context = GetContextRef(); if(!context) return; if(!(n >= 0)) SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); device = context->Device; for(i = 0;i < n;i++) { /* Check for valid ID */ if((preset=LookupPreset(device, ids[i])) == NULL) SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done); if(ReadRef(&preset->ref) != 0) SET_ERROR_AND_GOTO(context, AL_INVALID_OPERATION, done); } for(i = 0;i < n;i++) { if((preset=LookupPreset(device, ids[i])) != NULL) DeletePreset(device, preset); } done: ALCcontext_DecRef(context); }
void ALsoundfont_deleteSoundfont(ALsoundfont *self, ALCdevice *device) { ALsfpreset **presets; ALsizei num_presets; VECTOR(ALbuffer*) buffers; ALsizei i; VECTOR_INIT(buffers); presets = ExchangePtr((XchgPtr*)&self->Presets, NULL); num_presets = ExchangeInt(&self->NumPresets, 0); for(i = 0;i < num_presets;i++) { ALsfpreset *preset = presets[i]; ALfontsound **sounds; ALsizei num_sounds; ALboolean deleting; ALsizei j; sounds = ExchangePtr((XchgPtr*)&preset->Sounds, NULL); num_sounds = ExchangeInt(&preset->NumSounds, 0); DeletePreset(device, preset); preset = NULL; for(j = 0;j < num_sounds;j++) DecrementRef(&sounds[j]->ref); /* Some fontsounds may not be immediately deletable because they're * linked to another fontsound. When those fontsounds are deleted * they should become deletable, so use a loop until all fontsounds * are deleted. */ do { deleting = AL_FALSE; for(j = 0;j < num_sounds;j++) { if(sounds[j] && ReadRef(&sounds[j]->ref) == 0) { ALbuffer *buffer; deleting = AL_TRUE; if((buffer=ATOMIC_LOAD(&sounds[j]->Buffer)) != NULL) { ALbuffer **iter; #define MATCH_BUFFER(_i) (buffer == *(_i)) VECTOR_FIND_IF(iter, ALbuffer*, buffers, MATCH_BUFFER); if(iter == VECTOR_ITER_END(buffers)) VECTOR_PUSH_BACK(buffers, buffer); #undef MATCH_BUFFER } DeleteFontsound(device, sounds[j]); sounds[j] = NULL; } } } while(deleting); free(sounds); } ALsoundfont_Destruct(self); free(self); #define DELETE_BUFFER(iter) do { \ assert(ReadRef(&(*(iter))->ref) == 0); \ DeleteBuffer(device, *(iter)); \ } while(0) VECTOR_FOR_EACH(ALbuffer*, buffers, DELETE_BUFFER); #undef DELETE_BUFFER VECTOR_DEINIT(buffers); }
//-------------------------------------------------------------------------- bool ScriptConsole::OnClick(Widget w, int x, int y, int button) { int objects_row_index; PlayerBase player = GetGame().GetPlayer(); if ( w == m_ClientLogClearButton ) { this.Clear(); return true; } else if ( w == m_PositionsListbox ) { string position_name = GetCurrentPositionName(); vector position = m_ProfileUIFixed.GetPositionByName( position_name ); m_TeleportX.SetText( ftoa( position[0] ) ); m_TeleportY.SetText( ftoa( position[2] ) ); return true; } else if ( w == m_TeleportButton ) { string pos_x = m_TeleportX.GetText(); string pos_y = m_TeleportX.GetText(); string pos_z = "0"; vector v = String2Vector(pos_x + " " + pos_z +" " + pos_y); m_Developer.SetPlayerPosition(player, v ); return true; } else if ( w == m_ObjectsTextListbox ) { m_PresetItemsTextListbox.SelectRow(-1); HideItemButtons(); ShowItemTransferButtons(); m_SelectedObjectText.SetText( "Object : " + GetCurrentObjectName() ); m_SelectedObject = GetCurrentObjectName(); m_SelectedObjectIsPreset = false; return true; } else if ( w == m_ObjectFilter ) { ChangeFilter(); return true; } else if ( w == m_SpawnInInvButton || w == m_SpawnGroundButton ) { objects_row_index = m_ObjectsTextListbox.GetSelectedRow(); if ( m_SelectedObject != "" ) { int spawn_type = SPAWNTYPE_INVENTORY; switch( w ) { case m_SpawnGroundButton: { spawn_type = SPAWNTYPE_GROUND; } break; } // int damage = -1; // int quantity = -1; // m_Developer.SpawnItem(player, object_name, spawn_type, damage, quantity ); float distance = atof( m_SpawnDistanceEditBox.GetText() ); if ( m_SelectedObjectIsPreset ) { SetPreset( true, m_SelectedObject, spawn_type, distance ); } else { m_Developer.SpawnItem(player, m_SelectedObject, spawn_type, -1, -1, distance ); } } return true; } else if ( w == m_DiagToggleButton ) { int toggle_row_index = m_DiagToggleTextListbox.GetSelectedRow(); bool toggle_state = GetGame().GetDiagModeEnable( toggle_row_index ); GetGame().SetDiagModeEnable( toggle_row_index, not( toggle_state) ); return true; } else if ( w == m_DiagDrawButton ) { int draw_row_index = m_DiagDrawmodeTextListbox.GetSelectedRow(); GetGame().SetDiagDrawMode( draw_row_index ); return true; } else if ( w == m_SQFApplyButton ) { this.ApplySQF(); return true; } else if ( w == m_SQFOKButton ) { this.ApplySQF(); Close(); return true; } else if ( w == m_CloseConsoleButton ) { Close(); return true; } else if ( w == m_PresetsTextListbox ) { RenderPresetItems(); ShowPresetButtons(); ShowItemTransferButtons(); m_SelectedObjectText.SetText( "Preset : " + GetCurrentPresetName() ); m_SelectedObject = GetCurrentPresetName(); m_SelectedObjectIsPreset = true; return true; } else if ( w == m_PresetItemsTextListbox ) { m_ObjectsTextListbox.SelectRow(-1); ShowItemButtons(); ShowItemTransferButtons(); m_SelectedObjectText.SetText( "Object : " + GetCurrentItemName() ); m_SelectedObject = GetCurrentItemName(); m_SelectedObjectIsPreset = false; return true; } else if ( w == m_PresetSetDefaultButton ) { if ( GetCurrentPresetName()!= "" ) { SetDefaultPreset( GetCurrentPresetIndex() ); } return true; } else if ( w == m_PresetNewButton ) { g_Game.GetUIManager().EnterScriptedMenu(MENU_SCRIPTCONSOLE_DIALOG_PRESET_NAME, this); return true; } else if ( w == m_PresetDeleteButton ) { if ( GetCurrentPresetName()!= "" ) { DeletePreset(); } return true; } else if ( w == m_PresetRenameButton ) { if ( GetCurrentPresetName()!= "" ) { g_Game.GetUIManager().EnterScriptedMenu(MENU_SCRIPTCONSOLE_DIALOG_PRESET_RENAME, this); } return true; } else if ( w == m_PresetAddItemtButton ) { AddItemToPreset(); return true; } else if ( w == m_PresetRemoveItemButton ) { RemoveItemFromPreset(); return true; } else if ( w == m_ItemMoveUpButton ) { ItemMoveUp(); return true; } else if ( w == m_ItemMoveDownButton ) { ItemMoveDown(); return true; } // tabs for (int i = 0; i < TABS_COUNT; i++) { if (w == m_Tab_buttons[i]) { SelectTab(i); return true; } } return false; }