MCPcopy Create free account
hub / github.com/NetHack/NetHack / save_worm

Function save_worm

src/worm.c:527–568  ·  view source on GitHub ↗

* save_worm() * * Save the worm information for later use. The count is the number * of segments, including the dummy. Called from save.c. */

Source from the content-addressed store, hash-verified

525 * of segments, including the dummy. Called from save.c.
526 */
527void
528save_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/*

Callers 1

savelev_coreFunction · 0.85

Calls 1

update_fileFunction · 0.85

Tested by

no test coverage detected