Frees up any memory allocated for effect, sets type to EFX_NONE
| 248 | |
| 249 | // Frees up any memory allocated for effect, sets type to EFX_NONE |
| 250 | void EfxFreeEffect(tceffect *tce) { |
| 251 | ASSERT(tce); |
| 252 | |
| 253 | // unlink it out of the list |
| 254 | int prev, next; |
| 255 | prev = tce->prev; |
| 256 | next = tce->next; |
| 257 | |
| 258 | if (prev == -1) { |
| 259 | // removing a root |
| 260 | if (next != -1) { |
| 261 | Screen_roots[tce->screen] = next; |
| 262 | } else { |
| 263 | Screen_roots[tce->screen] = -1; |
| 264 | } |
| 265 | } else { |
| 266 | // removing a middle node |
| 267 | TCEffects[prev].next = next; |
| 268 | if (next != -1) |
| 269 | TCEffects[next].prev = prev; |
| 270 | } |
| 271 | tce->prev = tce->next = -1; |
| 272 | |
| 273 | if (tce->text_buffer) { |
| 274 | mem_free(tce->text_buffer); |
| 275 | tce->text_buffer = NULL; |
| 276 | } |
| 277 | |
| 278 | if (tce->has_focus) { |
| 279 | // disable the tab stop |
| 280 | tce->tab_stop = false; |
| 281 | |
| 282 | // uh oh, we're removing the item on the screen that has focus |
| 283 | Screen_has_effect_with_focus[tce->screen] = false; |
| 284 | |
| 285 | // see if we can find another item and give it focus |
| 286 | int node = Screen_roots[tce->screen]; |
| 287 | while (node != -1) { |
| 288 | if (TCEffects[node].tab_stop) { |
| 289 | // ok we found some one with a tab stop, give em focus |
| 290 | TCEffects[node].has_focus = true; |
| 291 | Screen_has_effect_with_focus[tce->screen] = true; |
| 292 | break; |
| 293 | } |
| 294 | node = TCEffects[node].next; |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | int i; |
| 299 | |
| 300 | switch (tce->type) { |
| 301 | case EFX_TEXT_TYPE: |
| 302 | TelcomStopSound(TCSND_TYPING); |
| 303 | break; |
| 304 | case EFX_TEXT_STATIC: |
| 305 | case EFX_TEXT_FADE: |
| 306 | break; |
| 307 | case EFX_BMP_STATIC: |
no test coverage detected