* save_worm() * * Save the worm information for later use. The count is the number * of segments, including the dummy. Called from save.c. */
| 525 | * of segments, including the dummy. Called from save.c. |
| 526 | */ |
| 527 | void |
| 528 | save_worm(NHFILE *nhfp) |
| 529 | { |
| 530 | int i; |
| 531 | int count; |
| 532 | struct wseg *curr, *temp; |
| 533 | |
| 534 | if (update_file(nhfp)) { |
| 535 | for (i = 1; i < MAX_NUM_WORMS; i++) { |
| 536 | for (count = 0, curr = wtails[i]; curr; curr = curr->nseg) |
| 537 | count++; |
| 538 | /* Save number of segments */ |
| 539 | Sfo_int(nhfp, &count, "worm-segment_count"); |
| 540 | /* Save segment locations of the monster. */ |
| 541 | if (count) { |
| 542 | for (curr = wtails[i]; curr; curr = curr->nseg) { |
| 543 | Sfo_coordxy(nhfp, &(curr->wx), "worm-wx"); |
| 544 | Sfo_coordxy(nhfp, &(curr->wy), "worm-wy"); |
| 545 | } |
| 546 | } |
| 547 | } |
| 548 | for (i = 0; i < MAX_NUM_WORMS; ++i) |
| 549 | Sfo_long(nhfp, &wgrowtime[i], "worm-wgrowtime"); |
| 550 | } |
| 551 | |
| 552 | if (release_data(nhfp)) { |
| 553 | /* Free the segments only. savemonchn() will take care of the |
| 554 | * monsters. */ |
| 555 | for (i = 1; i < MAX_NUM_WORMS; i++) { |
| 556 | if (!(curr = wtails[i])) |
| 557 | continue; |
| 558 | |
| 559 | while (curr) { |
| 560 | temp = curr->nseg; |
| 561 | dealloc_seg(curr); /* free the segment */ |
| 562 | curr = temp; |
| 563 | } |
| 564 | wheads[i] = wtails[i] = (struct wseg *) 0; |
| 565 | wgrowtime[i] = 0L; |
| 566 | } |
| 567 | } |
| 568 | } |
| 569 | #endif /* !SFCTOOL */ |
| 570 | |
| 571 | /* |
no test coverage detected