* Save part of the timer list. The parameter 'range' specifies either * global or level timers to save. The timer ID is saved with the global * timers. * * Global range: * + timeouts that follow the hero (global) * + timeouts that follow obj & monst that are migrating * * Level range: * + timeouts that are level-specific (e.g. storms) * + timeouts that stay with the
| 2665 | * + timeouts that stay with the level (obj & monst) |
| 2666 | */ |
| 2667 | void |
| 2668 | save_timers(NHFILE *nhfp, int range) |
| 2669 | { |
| 2670 | timer_element *curr, *prev, *next_timer = 0; |
| 2671 | int count; |
| 2672 | |
| 2673 | if (update_file(nhfp)) { |
| 2674 | if (range == RANGE_GLOBAL) { |
| 2675 | Sfo_ulong(nhfp, &svt.timer_id, "timer-timer_id"); |
| 2676 | } |
| 2677 | count = maybe_write_timer(nhfp, range, FALSE); |
| 2678 | Sfo_int(nhfp, &count, "timer-timer_count"); |
| 2679 | (void) maybe_write_timer(nhfp, range, TRUE); |
| 2680 | } |
| 2681 | |
| 2682 | if (release_data(nhfp)) { |
| 2683 | for (prev = 0, curr = gt.timer_base; curr; curr = next_timer) { |
| 2684 | next_timer = curr->next; /* in case curr is removed */ |
| 2685 | |
| 2686 | if (!(!!(range == RANGE_LEVEL) ^ !!timer_is_local(curr))) { |
| 2687 | if (prev) |
| 2688 | prev->next = curr->next; |
| 2689 | else |
| 2690 | gt.timer_base = curr->next; |
| 2691 | (void) memset((genericptr_t) curr, 0, sizeof(timer_element)); |
| 2692 | free((genericptr_t) curr); |
| 2693 | /* prev stays the same */ |
| 2694 | } else { |
| 2695 | prev = curr; |
| 2696 | } |
| 2697 | } |
| 2698 | } |
| 2699 | } |
| 2700 | #endif /* !SFCTOOL */ |
| 2701 | |
| 2702 | /* |
no test coverage detected