Mercurial > hg > early-roguelike
comparison xrogue/state.c @ 220:f54901b9c39b
XRogue: convert to ANSI-style function declarations.
author | John "Elwin" Edwards |
---|---|
date | Wed, 02 Mar 2016 21:13:26 -0500 |
parents | 3def5e487faa |
children | 7c1cb43f346e |
comparison
equal
deleted
inserted
replaced
219:f9ef86cf22b2 | 220:f54901b9c39b |
---|---|
95 int format_error = FALSE; | 95 int format_error = FALSE; |
96 | 96 |
97 int save_debug = FALSE; | 97 int save_debug = FALSE; |
98 #define DBG(x) {if (save_debug) rsPrintf x;} | 98 #define DBG(x) {if (save_debug) rsPrintf x;} |
99 | 99 |
100 bool rs_read_new_string(int inf, char **s); | |
101 int find_list_ptr(struct linked_list *l, void *ptr); | |
102 bool rs_write_coord_list(FILE *savef, struct linked_list *l); | |
103 bool rs_read_coord_list(int inf, struct linked_list **list); | |
104 int list_size(struct linked_list *l); | |
105 bool rs_write_object_list(FILE *savef, struct linked_list *l); | |
106 bool rs_read_object_list(int inf, struct linked_list **list); | |
107 | |
100 int | 108 int |
101 rsPrintf(char *fmt, ...) | 109 rsPrintf(char *fmt, ...) |
102 { | 110 { |
103 va_list ap; | 111 va_list ap; |
104 | 112 |
126 } | 134 } |
127 | 135 |
128 return(NULL); | 136 return(NULL); |
129 } | 137 } |
130 | 138 |
139 bool | |
131 rs_write(FILE *savef, void *ptr, size_t size) | 140 rs_write(FILE *savef, void *ptr, size_t size) |
132 { | 141 { |
133 size_t i = 0; | 142 size_t i = 0; |
134 | 143 |
135 if (!write_error) | 144 if (!write_error) |
141 return(WRITESTAT); | 150 return(WRITESTAT); |
142 } | 151 } |
143 | 152 |
144 int end_of_file = FALSE; | 153 int end_of_file = FALSE; |
145 | 154 |
155 bool | |
146 rs_read(int inf, void *ptr, size_t size) | 156 rs_read(int inf, void *ptr, size_t size) |
147 { | 157 { |
148 int actual; | 158 int actual; |
149 end_of_file =FALSE; | 159 end_of_file =FALSE; |
150 if (!read_error && !format_error) | 160 if (!read_error && !format_error) |
163 return(READSTAT); | 173 return(READSTAT); |
164 } | 174 } |
165 | 175 |
166 int big_endian = 0; | 176 int big_endian = 0; |
167 | 177 |
178 bool | |
168 rs_write_uint(FILE *savef, unsigned int c) | 179 rs_write_uint(FILE *savef, unsigned int c) |
169 { | 180 { |
170 char bytes[4]; | 181 char bytes[4]; |
171 char *buf = (char *) &c; | 182 char *buf = (char *) &c; |
172 | 183 |
182 rs_write(savef, buf, 4); | 193 rs_write(savef, buf, 4); |
183 | 194 |
184 return(WRITESTAT); | 195 return(WRITESTAT); |
185 } | 196 } |
186 | 197 |
198 bool | |
187 rs_write_int(FILE *savef, int c) | 199 rs_write_int(FILE *savef, int c) |
188 { | 200 { |
189 char bytes[4]; | 201 char bytes[4]; |
190 char *buf = (char *) &c; | 202 char *buf = (char *) &c; |
191 | 203 |
201 rs_write(savef, buf, 4); | 213 rs_write(savef, buf, 4); |
202 | 214 |
203 return(WRITESTAT); | 215 return(WRITESTAT); |
204 } | 216 } |
205 | 217 |
218 bool | |
206 rs_write_ulong(FILE *savef, unsigned long c) | 219 rs_write_ulong(FILE *savef, unsigned long c) |
207 { | 220 { |
208 unsigned int c2; | 221 unsigned int c2; |
209 char bytes[4]; | 222 char bytes[4]; |
210 char *buf = (char *)&c; | 223 char *buf = (char *)&c; |
227 rs_write(savef, buf, 4); | 240 rs_write(savef, buf, 4); |
228 | 241 |
229 return(WRITESTAT); | 242 return(WRITESTAT); |
230 } | 243 } |
231 | 244 |
245 bool | |
232 rs_write_long(FILE *savef, long c) | 246 rs_write_long(FILE *savef, long c) |
233 { | 247 { |
234 int c2; | 248 int c2; |
235 char bytes[4]; | 249 char bytes[4]; |
236 char *buf = (char *)&c; | 250 char *buf = (char *)&c; |
253 rs_write(savef, buf, 4); | 267 rs_write(savef, buf, 4); |
254 | 268 |
255 return(WRITESTAT); | 269 return(WRITESTAT); |
256 } | 270 } |
257 | 271 |
272 bool | |
258 rs_write_boolean(FILE *savef, bool c) | 273 rs_write_boolean(FILE *savef, bool c) |
259 { | 274 { |
260 char buf; | 275 char buf; |
261 | 276 |
262 if (c == 0) | 277 if (c == 0) |
267 rs_write(savef, &buf, 1); | 282 rs_write(savef, &buf, 1); |
268 | 283 |
269 return(WRITESTAT); | 284 return(WRITESTAT); |
270 } | 285 } |
271 | 286 |
287 bool | |
272 rs_read_int(int inf, int *i) | 288 rs_read_int(int inf, int *i) |
273 { | 289 { |
274 char bytes[4]; | 290 char bytes[4]; |
275 int input; | 291 int input; |
276 char *buf = (char *)&input; | 292 char *buf = (char *)&input; |
289 *i = *((int *) buf); | 305 *i = *((int *) buf); |
290 | 306 |
291 return(READSTAT); | 307 return(READSTAT); |
292 } | 308 } |
293 | 309 |
310 bool | |
294 rs_read_uint(int inf, unsigned int *i) | 311 rs_read_uint(int inf, unsigned int *i) |
295 { | 312 { |
296 char bytes[4]; | 313 char bytes[4]; |
297 int input; | 314 int input; |
298 char *buf = (char *)&input; | 315 char *buf = (char *)&input; |
311 *i = *((int *) buf); | 328 *i = *((int *) buf); |
312 | 329 |
313 return(READSTAT); | 330 return(READSTAT); |
314 } | 331 } |
315 | 332 |
333 bool | |
316 rs_read_ulong(int inf, unsigned long *i) | 334 rs_read_ulong(int inf, unsigned long *i) |
317 { | 335 { |
318 char bytes[4]; | 336 char bytes[4]; |
319 unsigned long input; | 337 unsigned long input; |
320 char *buf = (char *) &input; | 338 char *buf = (char *) &input; |
335 else | 353 else |
336 *i = *((unsigned long *) buf); | 354 *i = *((unsigned long *) buf); |
337 return(READSTAT); | 355 return(READSTAT); |
338 } | 356 } |
339 | 357 |
358 bool | |
340 rs_read_long(int inf, long *i) | 359 rs_read_long(int inf, long *i) |
341 { | 360 { |
342 char bytes[4]; | 361 char bytes[4]; |
343 long input; | 362 long input; |
344 char *buf = (char *) &input; | 363 char *buf = (char *) &input; |
359 else | 378 else |
360 *i = *((long *) buf); | 379 *i = *((long *) buf); |
361 return(READSTAT); | 380 return(READSTAT); |
362 } | 381 } |
363 | 382 |
383 bool | |
364 rs_read_boolean(int inf, bool *i) | 384 rs_read_boolean(int inf, bool *i) |
365 { | 385 { |
366 char buf; | 386 char buf; |
367 | 387 |
368 rs_read(inf, &buf, 1); | 388 rs_read(inf, &buf, 1); |
370 *i = buf; | 390 *i = buf; |
371 | 391 |
372 return(READSTAT); | 392 return(READSTAT); |
373 } | 393 } |
374 | 394 |
395 bool | |
375 rs_write_ints(FILE *savef, int *c, int count) | 396 rs_write_ints(FILE *savef, int *c, int count) |
376 { | 397 { |
377 int n=0; | 398 int n=0; |
378 | 399 |
379 rs_write_int(savef,count); | 400 rs_write_int(savef,count); |
382 rs_write_int(savef,c[n]); | 403 rs_write_int(savef,c[n]); |
383 | 404 |
384 return(WRITESTAT); | 405 return(WRITESTAT); |
385 } | 406 } |
386 | 407 |
408 bool | |
387 rs_write_short(FILE *savef, short c) | 409 rs_write_short(FILE *savef, short c) |
388 { | 410 { |
389 char bytes[2]; | 411 char bytes[2]; |
390 char *buf = (char *) &c; | 412 char *buf = (char *) &c; |
391 | 413 |
399 rs_write(savef, buf, 2); | 421 rs_write(savef, buf, 2); |
400 | 422 |
401 return(WRITESTAT); | 423 return(WRITESTAT); |
402 } | 424 } |
403 | 425 |
426 bool | |
404 rs_read_short(int inf, short *s) | 427 rs_read_short(int inf, short *s) |
405 { | 428 { |
406 char bytes[2]; | 429 char bytes[2]; |
407 short input; | 430 short input; |
408 char *buf = (char *)&input; | 431 char *buf = (char *)&input; |
419 *s = *((short *) buf); | 442 *s = *((short *) buf); |
420 return(READSTAT); | 443 return(READSTAT); |
421 } | 444 } |
422 | 445 |
423 | 446 |
447 bool | |
424 rs_write_shorts(FILE *savef, short *c, int count) | 448 rs_write_shorts(FILE *savef, short *c, int count) |
425 { | 449 { |
426 int n=0; | 450 int n=0; |
427 | 451 |
428 rs_write_int(savef,count); | 452 rs_write_int(savef,count); |
431 rs_write_short(savef,c[n]); | 455 rs_write_short(savef,c[n]); |
432 | 456 |
433 return(WRITESTAT); | 457 return(WRITESTAT); |
434 } | 458 } |
435 | 459 |
460 bool | |
436 rs_write_longs(FILE *savef, long *c, int count) | 461 rs_write_longs(FILE *savef, long *c, int count) |
437 { | 462 { |
438 int n=0; | 463 int n=0; |
439 | 464 |
440 rs_write_int(savef,count); | 465 rs_write_int(savef,count); |
443 rs_write_long(savef,c[n]); | 468 rs_write_long(savef,c[n]); |
444 | 469 |
445 return(WRITESTAT); | 470 return(WRITESTAT); |
446 } | 471 } |
447 | 472 |
473 bool | |
448 rs_write_ulongs(FILE *savef, unsigned long *c, int count) | 474 rs_write_ulongs(FILE *savef, unsigned long *c, int count) |
449 { | 475 { |
450 int n=0; | 476 int n=0; |
451 | 477 |
452 rs_write_int(savef,count); | 478 rs_write_int(savef,count); |
455 rs_write_ulong(savef,c[n]); | 481 rs_write_ulong(savef,c[n]); |
456 | 482 |
457 return(WRITESTAT); | 483 return(WRITESTAT); |
458 } | 484 } |
459 | 485 |
486 bool | |
460 rs_write_booleans(FILE *savef, bool *c, int count) | 487 rs_write_booleans(FILE *savef, bool *c, int count) |
461 { | 488 { |
462 int n=0; | 489 int n=0; |
463 | 490 |
464 rs_write_int(savef,count); | 491 rs_write_int(savef,count); |
467 rs_write_boolean(savef,c[n]); | 494 rs_write_boolean(savef,c[n]); |
468 | 495 |
469 return(WRITESTAT); | 496 return(WRITESTAT); |
470 } | 497 } |
471 | 498 |
499 bool | |
472 rs_read_ints(int inf, int *i, int count) | 500 rs_read_ints(int inf, int *i, int count) |
473 { | 501 { |
474 int n=0,value=0; | 502 int n=0,value=0; |
475 | 503 |
476 if (rs_read_int(inf,&value) != 0) | 504 if (rs_read_int(inf,&value) != 0) |
485 } | 513 } |
486 | 514 |
487 return(READSTAT); | 515 return(READSTAT); |
488 } | 516 } |
489 | 517 |
518 bool | |
490 rs_read_shorts(int inf, short *i, int count) | 519 rs_read_shorts(int inf, short *i, int count) |
491 { | 520 { |
492 int n=0,value=0; | 521 int n=0,value=0; |
493 | 522 |
494 if (rs_read_int(inf,&value) != 0) | 523 if (rs_read_int(inf,&value) != 0) |
503 } | 532 } |
504 | 533 |
505 return(READSTAT); | 534 return(READSTAT); |
506 } | 535 } |
507 | 536 |
537 bool | |
508 rs_read_longs(int inf, long *i, int count) | 538 rs_read_longs(int inf, long *i, int count) |
509 { | 539 { |
510 int n=0,value=0; | 540 int n=0,value=0; |
511 | 541 |
512 if (rs_read_int(inf,&value) != 0) | 542 if (rs_read_int(inf,&value) != 0) |
521 } | 551 } |
522 | 552 |
523 return(READSTAT); | 553 return(READSTAT); |
524 } | 554 } |
525 | 555 |
556 bool | |
526 rs_read_ulongs(int inf, unsigned long *i, int count) | 557 rs_read_ulongs(int inf, unsigned long *i, int count) |
527 { | 558 { |
528 int n=0,value=0; | 559 int n=0,value=0; |
529 | 560 |
530 if (rs_read_int(inf,&value) != 0) | 561 if (rs_read_int(inf,&value) != 0) |
539 } | 570 } |
540 | 571 |
541 return(READSTAT); | 572 return(READSTAT); |
542 } | 573 } |
543 | 574 |
575 bool | |
544 rs_read_booleans(int inf, bool *i, int count) | 576 rs_read_booleans(int inf, bool *i, int count) |
545 { | 577 { |
546 int n=0,value=0; | 578 int n=0,value=0; |
547 | 579 |
548 if (rs_read_int(inf,&value) != 0) | 580 if (rs_read_int(inf,&value) != 0) |
557 } | 589 } |
558 | 590 |
559 return(READSTAT); | 591 return(READSTAT); |
560 } | 592 } |
561 | 593 |
594 bool | |
562 rs_write_levtype(FILE *savef, LEVTYPE c) | 595 rs_write_levtype(FILE *savef, LEVTYPE c) |
563 { | 596 { |
564 int lt; | 597 int lt; |
565 | 598 |
566 switch(c) | 599 switch(c) |
576 rs_write_int(savef,lt); | 609 rs_write_int(savef,lt); |
577 | 610 |
578 return(WRITESTAT); | 611 return(WRITESTAT); |
579 } | 612 } |
580 | 613 |
614 bool | |
581 rs_read_levtype(int inf, LEVTYPE *l) | 615 rs_read_levtype(int inf, LEVTYPE *l) |
582 { | 616 { |
583 int lt; | 617 int lt; |
584 | 618 |
585 rs_read_int(inf, <); | 619 rs_read_int(inf, <); |
595 } | 629 } |
596 | 630 |
597 return(READSTAT); | 631 return(READSTAT); |
598 } | 632 } |
599 | 633 |
634 bool | |
600 rs_write_char(FILE *savef, char c) | 635 rs_write_char(FILE *savef, char c) |
601 { | 636 { |
602 rs_write(savef, &c, 1); | 637 rs_write(savef, &c, 1); |
603 DBG(("%c",c)); | 638 DBG(("%c",c)); |
604 | 639 |
605 return(WRITESTAT); | 640 return(WRITESTAT); |
606 } | 641 } |
607 | 642 |
643 bool | |
608 rs_read_char(int inf, char *c) | 644 rs_read_char(int inf, char *c) |
609 { | 645 { |
610 rs_read(inf, c, 1); | 646 rs_read(inf, c, 1); |
611 | 647 |
612 return(READSTAT); | 648 return(READSTAT); |
613 } | 649 } |
614 | 650 |
651 bool | |
615 rs_write_uchar(FILE *savef, unsigned char c) | 652 rs_write_uchar(FILE *savef, unsigned char c) |
616 { | 653 { |
617 rs_write(savef, &c, 1); | 654 rs_write(savef, &c, 1); |
618 DBG(("%c",c)); | 655 DBG(("%c",c)); |
619 | 656 |
620 return(WRITESTAT); | 657 return(WRITESTAT); |
621 } | 658 } |
622 | 659 |
660 bool | |
623 rs_read_uchar(int inf, unsigned char *c) | 661 rs_read_uchar(int inf, unsigned char *c) |
624 { | 662 { |
625 rs_read(inf, c, 1); | 663 rs_read(inf, c, 1); |
626 | 664 |
627 return(READSTAT); | 665 return(READSTAT); |
628 } | 666 } |
629 | 667 |
668 bool | |
630 rs_write_string(FILE *savef, char *s) | 669 rs_write_string(FILE *savef, char *s) |
631 { | 670 { |
632 int len = 0; | 671 int len = 0; |
633 | 672 |
634 len = (s == NULL) ? 0 : (int) strlen(s) + 1; | 673 len = (s == NULL) ? 0 : (int) strlen(s) + 1; |
637 rs_write(savef, s, len); | 676 rs_write(savef, s, len); |
638 | 677 |
639 return(WRITESTAT); | 678 return(WRITESTAT); |
640 } | 679 } |
641 | 680 |
681 bool | |
642 rs_read_string_index(int inf, struct words master[], int maxindex, char **str) | 682 rs_read_string_index(int inf, struct words master[], int maxindex, char **str) |
643 { | 683 { |
644 int i; | 684 int i; |
645 | 685 |
646 if (rs_read_int(inf,&i) != 0) | 686 if (rs_read_int(inf,&i) != 0) |
658 *str = NULL; | 698 *str = NULL; |
659 } | 699 } |
660 return(READSTAT); | 700 return(READSTAT); |
661 } | 701 } |
662 | 702 |
703 bool | |
663 rs_write_string_index(FILE *savef, struct words master[], int maxindex, char *str) | 704 rs_write_string_index(FILE *savef, struct words master[], int maxindex, char *str) |
664 { | 705 { |
665 int i; | 706 int i; |
666 | 707 |
667 for(i = 0; i < maxindex; i++) | 708 for(i = 0; i < maxindex; i++) |
675 | 716 |
676 rs_write_int(savef,-1); | 717 rs_write_int(savef,-1); |
677 return(WRITESTAT); | 718 return(WRITESTAT); |
678 } | 719 } |
679 | 720 |
721 bool | |
680 rs_read_scrolls(int inf) | 722 rs_read_scrolls(int inf) |
681 { | 723 { |
682 int i; | 724 int i; |
683 | 725 |
684 for(i = 0; i < MAXSCROLLS; i++) | 726 for(i = 0; i < MAXSCROLLS; i++) |
689 } | 731 } |
690 | 732 |
691 return(READSTAT); | 733 return(READSTAT); |
692 } | 734 } |
693 | 735 |
736 bool | |
694 rs_write_scrolls(FILE *savef) | 737 rs_write_scrolls(FILE *savef) |
695 { | 738 { |
696 int i; | 739 int i; |
697 | 740 |
698 for(i = 0; i < MAXSCROLLS; i++) | 741 for(i = 0; i < MAXSCROLLS; i++) |
699 { | 742 { |
700 rs_write_string(savef,s_names[i]); | 743 rs_write_string(savef,s_names[i]); |
701 rs_write_boolean(savef,s_know[i]); | 744 rs_write_boolean(savef,s_know[i]); |
702 rs_write_string(savef,s_guess[i]); | 745 rs_write_string(savef,s_guess[i]); |
703 } | 746 } |
704 return(READSTAT); | 747 return(WRITESTAT); |
705 } | 748 } |
706 | 749 |
750 bool | |
707 rs_read_potions(int inf) | 751 rs_read_potions(int inf) |
708 { | 752 { |
709 int i; | 753 int i; |
710 | 754 |
711 for(i = 0; i < MAXPOTIONS; i++) | 755 for(i = 0; i < MAXPOTIONS; i++) |
716 } | 760 } |
717 | 761 |
718 return(READSTAT); | 762 return(READSTAT); |
719 } | 763 } |
720 | 764 |
765 bool | |
721 rs_write_potions(FILE *savef) | 766 rs_write_potions(FILE *savef) |
722 { | 767 { |
723 int i; | 768 int i; |
724 | 769 |
725 for(i = 0; i < MAXPOTIONS; i++) | 770 for(i = 0; i < MAXPOTIONS; i++) |
730 } | 775 } |
731 | 776 |
732 return(WRITESTAT); | 777 return(WRITESTAT); |
733 } | 778 } |
734 | 779 |
780 bool | |
735 rs_read_rings(int inf) | 781 rs_read_rings(int inf) |
736 { | 782 { |
737 int i; | 783 int i; |
738 | 784 |
739 for(i = 0; i < MAXRINGS; i++) | 785 for(i = 0; i < MAXRINGS; i++) |
744 } | 790 } |
745 | 791 |
746 return(READSTAT); | 792 return(READSTAT); |
747 } | 793 } |
748 | 794 |
795 bool | |
749 rs_write_rings(FILE *savef) | 796 rs_write_rings(FILE *savef) |
750 { | 797 { |
751 int i; | 798 int i; |
752 | 799 |
753 for(i = 0; i < MAXRINGS; i++) | 800 for(i = 0; i < MAXRINGS; i++) |
758 } | 805 } |
759 | 806 |
760 return(WRITESTAT); | 807 return(WRITESTAT); |
761 } | 808 } |
762 | 809 |
810 bool | |
763 rs_read_misc(int inf) | 811 rs_read_misc(int inf) |
764 { | 812 { |
765 int i; | 813 int i; |
766 | 814 |
767 for(i = 0; i < MAXMM; i++) | 815 for(i = 0; i < MAXMM; i++) |
771 } | 819 } |
772 | 820 |
773 return(READSTAT); | 821 return(READSTAT); |
774 } | 822 } |
775 | 823 |
824 bool | |
776 rs_write_misc(FILE *savef) | 825 rs_write_misc(FILE *savef) |
777 { | 826 { |
778 int i; | 827 int i; |
779 | 828 |
780 for(i = 0; i < MAXMM; i++) | 829 for(i = 0; i < MAXMM; i++) |
784 } | 833 } |
785 | 834 |
786 return(WRITESTAT); | 835 return(WRITESTAT); |
787 } | 836 } |
788 | 837 |
838 bool | |
789 rs_write_sticks(FILE *savef) | 839 rs_write_sticks(FILE *savef) |
790 { | 840 { |
791 int i; | 841 int i; |
792 | 842 |
793 for (i = 0; i < MAXSTICKS; i++) | 843 for (i = 0; i < MAXSTICKS; i++) |
807 } | 857 } |
808 | 858 |
809 return(WRITESTAT); | 859 return(WRITESTAT); |
810 } | 860 } |
811 | 861 |
862 bool | |
812 rs_read_sticks(int inf) | 863 rs_read_sticks(int inf) |
813 { | 864 { |
814 int i = 0, list = 0; | 865 int i = 0, list = 0; |
815 | 866 |
816 for(i = 0; i < MAXSTICKS; i++) | 867 for(i = 0; i < MAXSTICKS; i++) |
831 } | 882 } |
832 | 883 |
833 return(READSTAT); | 884 return(READSTAT); |
834 } | 885 } |
835 | 886 |
887 bool | |
836 rs_read_string(int inf, char *s, int max) | 888 rs_read_string(int inf, char *s, int max) |
837 { | 889 { |
838 int len = 0; | 890 int len = 0; |
839 | 891 |
840 if (rs_read_int(inf, &len) != FALSE) | 892 if (rs_read_int(inf, &len) != FALSE) |
850 } | 902 } |
851 | 903 |
852 return(READSTAT); | 904 return(READSTAT); |
853 } | 905 } |
854 | 906 |
907 bool | |
855 rs_read_new_string(int inf, char **s) | 908 rs_read_new_string(int inf, char **s) |
856 { | 909 { |
857 int len=0; | 910 int len=0; |
858 char *buf=0; | 911 char *buf=0; |
859 | 912 |
876 } | 929 } |
877 | 930 |
878 return(READSTAT); | 931 return(READSTAT); |
879 } | 932 } |
880 | 933 |
934 bool | |
881 rs_write_strings(FILE *savef, char *s[], int count) | 935 rs_write_strings(FILE *savef, char *s[], int count) |
882 { | 936 { |
883 int len = 0; | 937 int len = 0; |
884 int n = 0; | 938 int n = 0; |
885 | 939 |
894 } | 948 } |
895 | 949 |
896 return(WRITESTAT); | 950 return(WRITESTAT); |
897 } | 951 } |
898 | 952 |
953 bool | |
899 rs_write_words(FILE *savef, struct words *w, int count) | 954 rs_write_words(FILE *savef, struct words *w, int count) |
900 { | 955 { |
901 int n = 0; | 956 int n = 0; |
902 | 957 |
903 rs_write_int(savef,count); | 958 rs_write_int(savef,count); |
909 } | 964 } |
910 | 965 |
911 return(WRITESTAT); | 966 return(WRITESTAT); |
912 } | 967 } |
913 | 968 |
969 bool | |
914 rs_read_words(int inf, struct words *w, int count) | 970 rs_read_words(int inf, struct words *w, int count) |
915 { | 971 { |
916 int n = 0; | 972 int n = 0; |
917 int value = 0; | 973 int value = 0; |
918 | 974 |
931 } | 987 } |
932 | 988 |
933 return(READSTAT); | 989 return(READSTAT); |
934 } | 990 } |
935 | 991 |
992 bool | |
936 rs_read_new_strings(int inf, char **s, int count) | 993 rs_read_new_strings(int inf, char **s, int count) |
937 { | 994 { |
938 int len = 0; | 995 int len = 0; |
939 int n = 0; | 996 int n = 0; |
940 int value = 0; | 997 int value = 0; |
964 } | 1021 } |
965 | 1022 |
966 return(READSTAT); | 1023 return(READSTAT); |
967 } | 1024 } |
968 | 1025 |
1026 bool | |
969 rs_write_coord(FILE *savef, coord *c) | 1027 rs_write_coord(FILE *savef, coord *c) |
970 { | 1028 { |
971 DBG(("X =")); | 1029 DBG(("X =")); |
972 rs_write_int(savef, c->x); | 1030 rs_write_int(savef, c->x); |
973 DBG(("Y =")); | 1031 DBG(("Y =")); |
974 rs_write_int(savef, c->y); | 1032 rs_write_int(savef, c->y); |
975 | 1033 |
976 return(WRITESTAT); | 1034 return(WRITESTAT); |
977 } | 1035 } |
978 | 1036 |
1037 bool | |
979 rs_read_coord(int inf, coord *c) | 1038 rs_read_coord(int inf, coord *c) |
980 { | 1039 { |
981 rs_read_int(inf,&c->x); | 1040 rs_read_int(inf,&c->x); |
982 rs_read_int(inf,&c->y); | 1041 rs_read_int(inf,&c->y); |
983 | 1042 |
1045 if (tobj->o_type != MM || tobj->o_which != MM_JUG) | 1104 if (tobj->o_type != MM || tobj->o_which != MM_JUG) |
1046 return NULL; | 1105 return NULL; |
1047 return tobj; | 1106 return tobj; |
1048 } | 1107 } |
1049 | 1108 |
1109 bool | |
1050 rs_write_daemons(FILE *savef, struct delayed_action *d_list,int count) | 1110 rs_write_daemons(FILE *savef, struct delayed_action *d_list,int count) |
1051 { | 1111 { |
1052 int i = 0; | 1112 int i = 0; |
1053 int func = 0; | 1113 int func = 0; |
1054 | 1114 |
1171 } | 1231 } |
1172 | 1232 |
1173 return(WRITESTAT); | 1233 return(WRITESTAT); |
1174 } | 1234 } |
1175 | 1235 |
1236 bool | |
1176 rs_read_daemons(int inf, struct delayed_action *d_list, int count) | 1237 rs_read_daemons(int inf, struct delayed_action *d_list, int count) |
1177 { | 1238 { |
1178 int i = 0; | 1239 int i = 0; |
1179 int func = 0; | 1240 int func = 0; |
1180 int value = 0; | 1241 int value = 0; |
1342 } | 1403 } |
1343 | 1404 |
1344 return(READSTAT); | 1405 return(READSTAT); |
1345 } | 1406 } |
1346 | 1407 |
1408 bool | |
1347 rs_write_rooms(FILE *savef, struct room r[], int count) | 1409 rs_write_rooms(FILE *savef, struct room r[], int count) |
1348 { | 1410 { |
1349 int n = 0,i = -1; | 1411 int n = 0,i = -1; |
1350 struct linked_list *l; | 1412 struct linked_list *l; |
1351 | 1413 |
1374 } | 1436 } |
1375 } | 1437 } |
1376 return(WRITESTAT); | 1438 return(WRITESTAT); |
1377 } | 1439 } |
1378 | 1440 |
1441 bool | |
1379 rs_read_rooms(int inf, struct room *r, int count) | 1442 rs_read_rooms(int inf, struct room *r, int count) |
1380 { | 1443 { |
1381 int value = 0, n = 0, i = 0, index = 0, id = 0; | 1444 int value = 0, n = 0, i = 0, index = 0, id = 0; |
1382 struct linked_list *fires=NULL, *item = NULL; | 1445 struct linked_list *fires=NULL, *item = NULL; |
1383 | 1446 |
1434 } | 1497 } |
1435 | 1498 |
1436 return(READSTAT); | 1499 return(READSTAT); |
1437 } | 1500 } |
1438 | 1501 |
1502 bool | |
1439 rs_write_object(FILE *savef, struct object *o) | 1503 rs_write_object(FILE *savef, struct object *o) |
1440 { | 1504 { |
1441 rs_write_int(savef, RSXR_OBJECT); | 1505 rs_write_int(savef, RSXR_OBJECT); |
1442 rs_write_int(savef, o->o_type); | 1506 rs_write_int(savef, o->o_type); |
1443 rs_write_coord(savef, &o->o_pos); | 1507 rs_write_coord(savef, &o->o_pos); |
1485 DBG((" END_CONTENTS\n")); | 1549 DBG((" END_CONTENTS\n")); |
1486 | 1550 |
1487 return(WRITESTAT); | 1551 return(WRITESTAT); |
1488 } | 1552 } |
1489 | 1553 |
1554 bool | |
1490 rs_read_object(int inf, struct object *o) | 1555 rs_read_object(int inf, struct object *o) |
1491 { | 1556 { |
1492 int id; | 1557 int id; |
1493 | 1558 |
1494 if (rs_read_int(inf, &id) != 0) | 1559 if (rs_read_int(inf, &id) != 0) |
1521 } | 1586 } |
1522 | 1587 |
1523 return(READSTAT); | 1588 return(READSTAT); |
1524 } | 1589 } |
1525 | 1590 |
1591 bool | |
1526 rs_write_stats(FILE *savef, struct stats *s) | 1592 rs_write_stats(FILE *savef, struct stats *s) |
1527 { | 1593 { |
1528 DBG(("Stats\n")); | 1594 DBG(("Stats\n")); |
1529 rs_write_int(savef, RSXR_STATS); | 1595 rs_write_int(savef, RSXR_STATS); |
1530 | 1596 |
1544 rs_write(savef, s->s_dmg, sizeof(s->s_dmg)); | 1610 rs_write(savef, s->s_dmg, sizeof(s->s_dmg)); |
1545 | 1611 |
1546 return(WRITESTAT); | 1612 return(WRITESTAT); |
1547 } | 1613 } |
1548 | 1614 |
1615 bool | |
1549 rs_read_stats(int inf, struct stats *s) | 1616 rs_read_stats(int inf, struct stats *s) |
1550 { | 1617 { |
1551 int id; | 1618 int id; |
1552 | 1619 |
1553 if (rs_read_int(inf, &id) != 0) | 1620 if (rs_read_int(inf, &id) != 0) |
1578 } | 1645 } |
1579 | 1646 |
1580 return(READSTAT); | 1647 return(READSTAT); |
1581 } | 1648 } |
1582 | 1649 |
1650 bool | |
1583 rs_write_mstats(FILE *savef, struct mstats *s) | 1651 rs_write_mstats(FILE *savef, struct mstats *s) |
1584 { | 1652 { |
1585 DBG(("M-Stats\n")); | 1653 DBG(("M-Stats\n")); |
1586 rs_write_int(savef, RSXR_STATS); | 1654 rs_write_int(savef, RSXR_STATS); |
1587 rs_write_short(savef, s->ms_str); | 1655 rs_write_short(savef, s->ms_str); |
1596 /*printf(" Damage: %s\n",s->ms_dmg);*/ | 1664 /*printf(" Damage: %s\n",s->ms_dmg);*/ |
1597 | 1665 |
1598 return(WRITESTAT); | 1666 return(WRITESTAT); |
1599 } | 1667 } |
1600 | 1668 |
1669 bool | |
1601 rs_read_mstats(int inf, struct mstats *s) | 1670 rs_read_mstats(int inf, struct mstats *s) |
1602 { | 1671 { |
1603 int id; | 1672 int id; |
1604 | 1673 |
1605 if (rs_read_int(inf, &id) != 0) | 1674 if (rs_read_int(inf, &id) != 0) |
1632 } | 1701 } |
1633 | 1702 |
1634 return(READSTAT); | 1703 return(READSTAT); |
1635 } | 1704 } |
1636 | 1705 |
1706 bool | |
1637 rs_write_init_weps(FILE *savef, struct init_weps *w, int count) | 1707 rs_write_init_weps(FILE *savef, struct init_weps *w, int count) |
1638 { | 1708 { |
1639 int i; | 1709 int i; |
1640 | 1710 |
1641 DBG(("Init-Weps\n")); | 1711 DBG(("Init-Weps\n")); |
1654 rs_write_int(savef, w[i].w_worth); | 1724 rs_write_int(savef, w[i].w_worth); |
1655 } | 1725 } |
1656 return(WRITESTAT); | 1726 return(WRITESTAT); |
1657 } | 1727 } |
1658 | 1728 |
1729 bool | |
1659 rs_read_init_weps(int inf, struct init_weps *w,int count) | 1730 rs_read_init_weps(int inf, struct init_weps *w,int count) |
1660 { | 1731 { |
1661 int id,value,i; | 1732 int id,value,i; |
1662 | 1733 |
1663 rs_read_int(inf, &id); | 1734 rs_read_int(inf, &id); |
1682 rs_read_int(inf, &w[i].w_worth); | 1753 rs_read_int(inf, &w[i].w_worth); |
1683 } | 1754 } |
1684 return(READSTAT); | 1755 return(READSTAT); |
1685 } | 1756 } |
1686 | 1757 |
1758 bool | |
1687 rs_write_init_armor(FILE *savef, struct init_armor *a, int count) | 1759 rs_write_init_armor(FILE *savef, struct init_armor *a, int count) |
1688 { | 1760 { |
1689 int i; | 1761 int i; |
1690 DBG(("Init-Armor\n")); | 1762 DBG(("Init-Armor\n")); |
1691 rs_write_int(savef, RSXR_IARMOR); | 1763 rs_write_int(savef, RSXR_IARMOR); |
1699 rs_write_int(savef, a[i].a_wght); | 1771 rs_write_int(savef, a[i].a_wght); |
1700 } | 1772 } |
1701 return(WRITESTAT); | 1773 return(WRITESTAT); |
1702 } | 1774 } |
1703 | 1775 |
1776 bool | |
1704 rs_read_init_armor(int inf, struct init_armor *a,int count) | 1777 rs_read_init_armor(int inf, struct init_armor *a,int count) |
1705 { | 1778 { |
1706 int id,value,i; | 1779 int id,value,i; |
1707 | 1780 |
1708 rs_read_int(inf, &id); | 1781 rs_read_int(inf, &id); |
1718 } | 1791 } |
1719 | 1792 |
1720 return(READSTAT); | 1793 return(READSTAT); |
1721 } | 1794 } |
1722 | 1795 |
1796 bool | |
1723 rs_write_spells(FILE *savef, struct spells *s, int count) | 1797 rs_write_spells(FILE *savef, struct spells *s, int count) |
1724 { | 1798 { |
1725 int i; | 1799 int i; |
1726 DBG(("Spells\n")); | 1800 DBG(("Spells\n")); |
1727 rs_write_int(savef, RSXR_SPELLS); | 1801 rs_write_int(savef, RSXR_SPELLS); |
1734 rs_write_int(savef, s[i].s_flag); | 1808 rs_write_int(savef, s[i].s_flag); |
1735 } | 1809 } |
1736 return(WRITESTAT); | 1810 return(WRITESTAT); |
1737 } | 1811 } |
1738 | 1812 |
1813 bool | |
1739 rs_read_spells(int inf, struct spells *s,int count) | 1814 rs_read_spells(int inf, struct spells *s,int count) |
1740 { | 1815 { |
1741 int id,value,i; | 1816 int id,value,i; |
1742 | 1817 |
1743 rs_read_int(inf, &id); | 1818 rs_read_int(inf, &id); |
1751 rs_read_int(inf, &s[i].s_flag); | 1826 rs_read_int(inf, &s[i].s_flag); |
1752 } | 1827 } |
1753 return(READSTAT); | 1828 return(READSTAT); |
1754 } | 1829 } |
1755 | 1830 |
1831 bool | |
1756 rs_write_item_list(FILE *savef, struct item_list *i) | 1832 rs_write_item_list(FILE *savef, struct item_list *i) |
1757 { | 1833 { |
1758 DBG(("Item List\n")); | 1834 DBG(("Item List\n")); |
1759 rs_write_int(savef, RSXR_ILIST); | 1835 rs_write_int(savef, RSXR_ILIST); |
1760 rs_write_char(savef, i->item_ch); | 1836 rs_write_char(savef, i->item_ch); |
1761 rs_write(savef, i->item_desc, sizeof(i->item_desc)); | 1837 rs_write(savef, i->item_desc, sizeof(i->item_desc)); |
1762 return(WRITESTAT); | 1838 return(WRITESTAT); |
1763 } | 1839 } |
1840 | |
1841 bool | |
1764 rs_read_item_list(int inf, struct item_list *i) | 1842 rs_read_item_list(int inf, struct item_list *i) |
1765 { | 1843 { |
1766 int id; | 1844 int id; |
1767 | 1845 |
1768 rs_read_int(inf, &id); | 1846 rs_read_int(inf, &id); |
1770 rs_read_uchar(inf, &i->item_ch); | 1848 rs_read_uchar(inf, &i->item_ch); |
1771 rs_read(inf, i->item_desc,sizeof(i->item_desc)); | 1849 rs_read(inf, i->item_desc,sizeof(i->item_desc)); |
1772 return(READSTAT); | 1850 return(READSTAT); |
1773 } | 1851 } |
1774 | 1852 |
1853 bool | |
1775 rs_write_h_list(FILE *savef, struct h_list *h) | 1854 rs_write_h_list(FILE *savef, struct h_list *h) |
1776 { | 1855 { |
1777 DBG(("H List\n")); | 1856 DBG(("H List\n")); |
1778 rs_write_int(savef, RSXR_HLIST); | 1857 rs_write_int(savef, RSXR_HLIST); |
1779 rs_write_char(savef, h->h_ch); | 1858 rs_write_char(savef, h->h_ch); |
1780 rs_write(savef, h->h_desc, sizeof(h->h_desc)); | 1859 rs_write(savef, h->h_desc, sizeof(h->h_desc)); |
1781 return(WRITESTAT); | 1860 return(WRITESTAT); |
1782 } | 1861 } |
1783 | 1862 |
1863 bool | |
1784 rs_read_h_list(int inf, struct h_list *h) | 1864 rs_read_h_list(int inf, struct h_list *h) |
1785 { | 1865 { |
1786 int id; | 1866 int id; |
1787 | 1867 |
1788 rs_read_int(inf, &id); | 1868 rs_read_int(inf, &id); |
1790 rs_read_char(inf, &h->h_ch); | 1870 rs_read_char(inf, &h->h_ch); |
1791 rs_read(inf, h->h_desc,sizeof(h->h_desc)); | 1871 rs_read(inf, h->h_desc,sizeof(h->h_desc)); |
1792 return(READSTAT); | 1872 return(READSTAT); |
1793 } | 1873 } |
1794 | 1874 |
1875 bool | |
1795 rs_write_death_types(FILE *savef, struct death_type *d,int count) | 1876 rs_write_death_types(FILE *savef, struct death_type *d,int count) |
1796 { | 1877 { |
1797 int i; | 1878 int i; |
1798 | 1879 |
1799 DBG(("Death Types\n")); | 1880 DBG(("Death Types\n")); |
1805 rs_write_int(savef, d[i].reason); | 1886 rs_write_int(savef, d[i].reason); |
1806 rs_write(savef, d[i].name, sizeof(d[i].name)); | 1887 rs_write(savef, d[i].name, sizeof(d[i].name)); |
1807 } | 1888 } |
1808 return(WRITESTAT); | 1889 return(WRITESTAT); |
1809 } | 1890 } |
1891 | |
1892 bool | |
1810 rs_read_death_types(int inf, struct death_type *d, int count) | 1893 rs_read_death_types(int inf, struct death_type *d, int count) |
1811 { | 1894 { |
1812 int id,value,i; | 1895 int id,value,i; |
1813 | 1896 |
1814 rs_read_int(inf, &id); | 1897 rs_read_int(inf, &id); |
1826 rs_read(inf, d[i].name,sizeof(d[i].name)); | 1909 rs_read(inf, d[i].name,sizeof(d[i].name)); |
1827 } | 1910 } |
1828 return(READSTAT); | 1911 return(READSTAT); |
1829 } | 1912 } |
1830 | 1913 |
1914 bool | |
1831 rs_write_character_types(FILE *savef, struct character_types *c, int count) | 1915 rs_write_character_types(FILE *savef, struct character_types *c, int count) |
1832 { | 1916 { |
1833 int i; | 1917 int i; |
1834 | 1918 |
1835 DBG(("Character Types\n")); | 1919 DBG(("Character Types\n")); |
1849 rs_write_int(savef, c[i].range); | 1933 rs_write_int(savef, c[i].range); |
1850 } | 1934 } |
1851 return(WRITESTAT); | 1935 return(WRITESTAT); |
1852 } | 1936 } |
1853 | 1937 |
1938 bool | |
1854 rs_read_character_types(int inf, struct character_types *c,int count) | 1939 rs_read_character_types(int inf, struct character_types *c,int count) |
1855 { | 1940 { |
1856 int id,value,i; | 1941 int id,value,i; |
1857 | 1942 |
1858 rs_read_int(inf, &id); | 1943 rs_read_int(inf, &id); |
1878 rs_read_int(inf, &c[i].range); | 1963 rs_read_int(inf, &c[i].range); |
1879 } | 1964 } |
1880 return(READSTAT); | 1965 return(READSTAT); |
1881 } | 1966 } |
1882 | 1967 |
1968 bool | |
1883 rs_write_traps(FILE *savef, struct trap *trap,int count) | 1969 rs_write_traps(FILE *savef, struct trap *trap,int count) |
1884 { | 1970 { |
1885 int n; | 1971 int n; |
1886 | 1972 |
1887 DBG(("Traps\n")); | 1973 DBG(("Traps\n")); |
1893 rs_write_char(savef, trap[n].tr_type); | 1979 rs_write_char(savef, trap[n].tr_type); |
1894 rs_write_char(savef, trap[n].tr_show); | 1980 rs_write_char(savef, trap[n].tr_show); |
1895 rs_write_coord(savef, &trap[n].tr_pos); | 1981 rs_write_coord(savef, &trap[n].tr_pos); |
1896 rs_write_long(savef, trap[n].tr_flags); | 1982 rs_write_long(savef, trap[n].tr_flags); |
1897 } | 1983 } |
1898 } | 1984 return(WRITESTAT); |
1899 | 1985 } |
1986 | |
1987 bool | |
1900 rs_read_traps(int inf, struct trap *trap, int count) | 1988 rs_read_traps(int inf, struct trap *trap, int count) |
1901 { | 1989 { |
1902 int id = 0, value = 0, n = 0; | 1990 int id = 0, value = 0, n = 0; |
1903 | 1991 |
1904 if (rs_read_int(inf,&id) != 0) | 1992 if (rs_read_int(inf,&id) != 0) |
1935 } | 2023 } |
1936 | 2024 |
1937 return(READSTAT); | 2025 return(READSTAT); |
1938 } | 2026 } |
1939 | 2027 |
2028 bool | |
1940 rs_write_monsters(FILE * savef, struct monster * m, int count) | 2029 rs_write_monsters(FILE * savef, struct monster * m, int count) |
1941 { | 2030 { |
1942 int n; | 2031 int n; |
1943 | 2032 |
1944 DBG(("Monsters\n")); | 2033 DBG(("Monsters\n")); |
1963 } | 2052 } |
1964 | 2053 |
1965 return(WRITESTAT); | 2054 return(WRITESTAT); |
1966 } | 2055 } |
1967 | 2056 |
2057 bool | |
1968 rs_read_monsters(int inf, struct monster *m, int count) | 2058 rs_read_monsters(int inf, struct monster *m, int count) |
1969 { | 2059 { |
1970 int id = 0, value = 0, n = 0; | 2060 int id = 0, value = 0, n = 0; |
1971 char buffer[1024]; | 2061 char buffer[1024]; |
1972 | 2062 |
2022 return(READSTAT); | 2112 return(READSTAT); |
2023 } | 2113 } |
2024 | 2114 |
2025 /*****************************************************************************/ | 2115 /*****************************************************************************/ |
2026 | 2116 |
2117 bool | |
2027 rs_write_coord_list(FILE *savef, struct linked_list *l) | 2118 rs_write_coord_list(FILE *savef, struct linked_list *l) |
2028 { | 2119 { |
2029 DBG(("Coordinate List\n")); | 2120 DBG(("Coordinate List\n")); |
2030 rs_write_int(savef, RSXR_COORDLIST); | 2121 rs_write_int(savef, RSXR_COORDLIST); |
2031 rs_write_int(savef, list_size(l)); | 2122 rs_write_int(savef, list_size(l)); |
2037 } | 2128 } |
2038 | 2129 |
2039 return(WRITESTAT); | 2130 return(WRITESTAT); |
2040 } | 2131 } |
2041 | 2132 |
2133 bool | |
2042 rs_read_coord_list(int inf, struct linked_list **list) | 2134 rs_read_coord_list(int inf, struct linked_list **list) |
2043 { | 2135 { |
2044 int id; | 2136 int id; |
2045 int i, cnt; | 2137 int i, cnt; |
2046 struct linked_list *l = NULL, *previous = NULL, *head = NULL; | 2138 struct linked_list *l = NULL, *previous = NULL, *head = NULL; |
2080 format_error = TRUE; | 2172 format_error = TRUE; |
2081 | 2173 |
2082 return(READSTAT); | 2174 return(READSTAT); |
2083 } | 2175 } |
2084 | 2176 |
2177 bool | |
2085 rs_write_object_list(FILE *savef, struct linked_list *l) | 2178 rs_write_object_list(FILE *savef, struct linked_list *l) |
2086 { | 2179 { |
2087 DBG(("Object List\n")); | 2180 DBG(("Object List\n")); |
2088 rs_write_int(savef, RSXR_OBJECTLIST); | 2181 rs_write_int(savef, RSXR_OBJECTLIST); |
2089 rs_write_int(savef, list_size(l)); | 2182 rs_write_int(savef, list_size(l)); |
2095 } | 2188 } |
2096 | 2189 |
2097 return(WRITESTAT); | 2190 return(WRITESTAT); |
2098 } | 2191 } |
2099 | 2192 |
2193 bool | |
2100 rs_read_object_list(int inf, struct linked_list **list) | 2194 rs_read_object_list(int inf, struct linked_list **list) |
2101 { | 2195 { |
2102 int id; | 2196 int id; |
2103 int i, cnt; | 2197 int i, cnt; |
2104 struct linked_list *l = NULL, *previous = NULL, *head = NULL; | 2198 struct linked_list *l = NULL, *previous = NULL, *head = NULL; |
2173 } | 2267 } |
2174 | 2268 |
2175 return(-1); | 2269 return(-1); |
2176 } | 2270 } |
2177 | 2271 |
2272 bool | |
2178 rs_write_thing(FILE *savef, struct thing *t) | 2273 rs_write_thing(FILE *savef, struct thing *t) |
2179 { | 2274 { |
2180 int i = -1; | 2275 int i = -1; |
2181 | 2276 |
2182 DBG(("Thing\n")); | 2277 DBG(("Thing\n")); |
2283 rs_write_stats(savef, &t->maxstats); | 2378 rs_write_stats(savef, &t->maxstats); |
2284 | 2379 |
2285 return(WRITESTAT); | 2380 return(WRITESTAT); |
2286 } | 2381 } |
2287 | 2382 |
2383 void | |
2288 rs_fix_thing(struct thing *t) | 2384 rs_fix_thing(struct thing *t) |
2289 { | 2385 { |
2290 struct linked_list *item; | 2386 struct linked_list *item; |
2291 struct thing *tp; | 2387 struct thing *tp; |
2292 | 2388 |
2300 tp = THINGPTR(item); | 2396 tp = THINGPTR(item); |
2301 t->t_dest = &tp->t_pos; | 2397 t->t_dest = &tp->t_pos; |
2302 } | 2398 } |
2303 } | 2399 } |
2304 | 2400 |
2401 bool | |
2305 rs_read_thing(int inf, struct thing *t) | 2402 rs_read_thing(int inf, struct thing *t) |
2306 { | 2403 { |
2307 int id; | 2404 int id; |
2308 int listid = 0, index = -1; | 2405 int listid = 0, index = -1; |
2309 struct linked_list *item; | 2406 struct linked_list *item; |
2411 | 2508 |
2412 return(count); | 2509 return(count); |
2413 } | 2510 } |
2414 | 2511 |
2415 | 2512 |
2513 bool | |
2416 rs_write_monster_list(FILE *savef, struct linked_list *l) | 2514 rs_write_monster_list(FILE *savef, struct linked_list *l) |
2417 { | 2515 { |
2418 int cnt = 0; | 2516 int cnt = 0; |
2419 | 2517 |
2420 DBG(("Monster List\n")); | 2518 DBG(("Monster List\n")); |
2433 } | 2531 } |
2434 | 2532 |
2435 return(WRITESTAT); | 2533 return(WRITESTAT); |
2436 } | 2534 } |
2437 | 2535 |
2438 rs_fix_monster_list(list) | 2536 void |
2439 struct linked_list *list; | 2537 rs_fix_monster_list(struct linked_list *list) |
2440 { | 2538 { |
2441 struct linked_list *item; | 2539 struct linked_list *item; |
2442 | 2540 |
2443 for(item = list; item != NULL; item = item->l_next) | 2541 for(item = list; item != NULL; item = item->l_next) |
2444 rs_fix_thing(THINGPTR(item)); | 2542 rs_fix_thing(THINGPTR(item)); |
2445 } | 2543 } |
2446 | 2544 |
2545 bool | |
2447 rs_read_monster_list(int inf, struct linked_list **list) | 2546 rs_read_monster_list(int inf, struct linked_list **list) |
2448 { | 2547 { |
2449 int id; | 2548 int id; |
2450 int i, cnt; | 2549 int i, cnt; |
2451 struct linked_list *l = NULL, *previous = NULL, *head = NULL; | 2550 struct linked_list *l = NULL, *previous = NULL, *head = NULL; |
2483 else format_error = TRUE; | 2582 else format_error = TRUE; |
2484 | 2583 |
2485 return(READSTAT); | 2584 return(READSTAT); |
2486 } | 2585 } |
2487 | 2586 |
2587 bool | |
2488 rs_write_magic_items(FILE *savef, struct magic_item *i, int count) | 2588 rs_write_magic_items(FILE *savef, struct magic_item *i, int count) |
2489 { | 2589 { |
2490 int n; | 2590 int n; |
2491 | 2591 |
2492 DBG(("Magic Items\n")); | 2592 DBG(("Magic Items\n")); |
2503 } | 2603 } |
2504 | 2604 |
2505 return(WRITESTAT); | 2605 return(WRITESTAT); |
2506 } | 2606 } |
2507 | 2607 |
2608 bool | |
2508 rs_read_magic_items(int inf, struct magic_item *mi, int count) | 2609 rs_read_magic_items(int inf, struct magic_item *mi, int count) |
2509 { | 2610 { |
2510 int id; | 2611 int id; |
2511 int n; | 2612 int n; |
2512 int value; | 2613 int value; |
2544 } | 2645 } |
2545 | 2646 |
2546 return(READSTAT); | 2647 return(READSTAT); |
2547 } | 2648 } |
2548 | 2649 |
2650 bool | |
2549 rs_write_window(FILE *savef, WINDOW *win) | 2651 rs_write_window(FILE *savef, WINDOW *win) |
2550 { | 2652 { |
2551 int row,col,height,width; | 2653 int row,col,height,width; |
2552 width = getmaxx(win); | 2654 width = getmaxx(win); |
2553 height = getmaxy(win); | 2655 height = getmaxy(win); |
2556 rs_write_int(savef,width); | 2658 rs_write_int(savef,width); |
2557 | 2659 |
2558 for(row=0;row<height;row++) | 2660 for(row=0;row<height;row++) |
2559 for(col=0;col<width;col++) | 2661 for(col=0;col<width;col++) |
2560 rs_write_int(savef, mvwinch(win,row,col)); | 2662 rs_write_int(savef, mvwinch(win,row,col)); |
2561 } | 2663 |
2562 | 2664 return(WRITESTAT); |
2665 } | |
2666 | |
2667 bool | |
2563 rs_read_window(int inf, WINDOW *win) | 2668 rs_read_window(int inf, WINDOW *win) |
2564 { | 2669 { |
2565 int row,col,maxlines,maxcols,value,width,height; | 2670 int row,col,maxlines,maxcols,value,width,height; |
2566 | 2671 |
2567 width = getmaxx(win); | 2672 width = getmaxx(win); |
2586 } | 2691 } |
2587 | 2692 |
2588 return(READSTAT); | 2693 return(READSTAT); |
2589 } | 2694 } |
2590 | 2695 |
2696 bool | |
2591 rs_save_file(FILE *savef) | 2697 rs_save_file(FILE *savef) |
2592 { | 2698 { |
2593 int i, weapon, armor, ring, misc, room = -1; | 2699 int i, weapon, armor, ring, misc, room = -1; |
2594 int endian = 0x01020304; | 2700 int endian = 0x01020304; |
2595 big_endian = ( *((char *)&endian) == 0x01 ); | 2701 big_endian = ( *((char *)&endian) == 0x01 ); |
2741 sizeof(monsters)/sizeof(struct monster)); /* mons_def.c */ | 2847 sizeof(monsters)/sizeof(struct monster)); /* mons_def.c */ |
2742 rs_write_coord(savef,&move_nh); /* move.c */ | 2848 rs_write_coord(savef,&move_nh); /* move.c */ |
2743 return(WRITESTAT); | 2849 return(WRITESTAT); |
2744 } | 2850 } |
2745 | 2851 |
2852 bool | |
2746 rs_restore_file(int inf) | 2853 rs_restore_file(int inf) |
2747 { | 2854 { |
2748 int weapon, armor, ring, misc, room = -1,i,checkpoint; | 2855 int weapon, armor, ring, misc, room = -1,i,checkpoint; |
2749 int endian = 0x01020304; | 2856 int endian = 0x01020304; |
2750 big_endian = ( *((char *)&endian) == 0x01 ); | 2857 big_endian = ( *((char *)&endian) == 0x01 ); |
2902 rs_read_coord(inf,&move_nh); /* move.c */ | 3009 rs_read_coord(inf,&move_nh); /* move.c */ |
2903 | 3010 |
2904 return(READSTAT); | 3011 return(READSTAT); |
2905 } | 3012 } |
2906 | 3013 |
3014 void | |
2907 rs_write_scorefile(FILE *savef, struct sc_ent *entries, int count) | 3015 rs_write_scorefile(FILE *savef, struct sc_ent *entries, int count) |
2908 { | 3016 { |
2909 int i; | 3017 int i; |
2910 | 3018 |
2911 rs_write_int(savef, count); | 3019 rs_write_int(savef, count); |
2921 rs_write_short(savef, entries[i].sc_monster); | 3029 rs_write_short(savef, entries[i].sc_monster); |
2922 rs_write_short(savef, entries[i].sc_quest); | 3030 rs_write_short(savef, entries[i].sc_quest); |
2923 } | 3031 } |
2924 } | 3032 } |
2925 | 3033 |
3034 int | |
2926 rs_read_scorefile(FILE *savef, struct sc_ent *entries, int count) | 3035 rs_read_scorefile(FILE *savef, struct sc_ent *entries, int count) |
2927 { | 3036 { |
2928 int i,available = 0; | 3037 int i,available = 0; |
2929 int sfd = md_fileno(savef); | 3038 int sfd = md_fileno(savef); |
2930 | 3039 |
2952 return(0); | 3061 return(0); |
2953 } | 3062 } |
2954 | 3063 |
2955 | 3064 |
2956 | 3065 |
3066 void | |
2957 rs_print_thing(FILE *outf, struct thing *thing, char *prefix, int list, int index) | 3067 rs_print_thing(FILE *outf, struct thing *thing, char *prefix, int list, int index) |
2958 { | 3068 { |
2959 int i; | 3069 int i; |
2960 | 3070 |
2961 fprintf(outf,"%sList Ident : %d\n", prefix, list); | 3071 fprintf(outf,"%sList Ident : %d\n", prefix, list); |
2993 fprintf(outf,"%st_stats : Not Implemented\n",prefix); | 3103 fprintf(outf,"%st_stats : Not Implemented\n",prefix); |
2994 fprintf(outf,"%st_maxstats : Not Implemented\n",prefix); | 3104 fprintf(outf,"%st_maxstats : Not Implemented\n",prefix); |
2995 fprintf(outf,"%st_reserved : %d\n",prefix,thing->t_reserved); | 3105 fprintf(outf,"%st_reserved : %d\n",prefix,thing->t_reserved); |
2996 } | 3106 } |
2997 | 3107 |
3108 void | |
2998 rs_print_game_state(FILE *outf) | 3109 rs_print_game_state(FILE *outf) |
2999 { | 3110 { |
3000 fprintf(outf, "Player\n"); | 3111 fprintf(outf, "Player\n"); |
3001 | 3112 |
3002 rs_print_thing(outf, &player, " ", 0, 0); | 3113 rs_print_thing(outf, &player, " ", 0, 0); |
3023 md_htonl() | 3134 md_htonl() |
3024 | 3135 |
3025 ****/ | 3136 ****/ |
3026 | 3137 |
3027 int | 3138 int |
3028 md_rand(range) | 3139 md_rand(int range) |
3029 register int range; | |
3030 { | 3140 { |
3031 #ifdef _WIN32 | 3141 #ifdef _WIN32 |
3032 return(range <= 0 ? 0 : rand() % range); | 3142 return(range <= 0 ? 0 : rand() % range); |
3033 #else | 3143 #else |
3034 return(range <= 0 ? 0 : random() % range); | 3144 return(range <= 0 ? 0 : random() % range); |
3035 #endif | 3145 #endif |
3036 } | 3146 } |
3037 | 3147 |
3038 int | 3148 int |
3039 md_srand(seed) | 3149 md_srand(int seed) |
3040 register int seed; | |
3041 { | 3150 { |
3042 #ifdef _WIN32 | 3151 #ifdef _WIN32 |
3043 srand(seed); | 3152 srand(seed); |
3044 #else | 3153 #else |
3045 srandom(seed); | 3154 srandom(seed); |
3046 #endif | 3155 #endif |
3047 } | 3156 } |
3048 | 3157 |
3049 void | 3158 void |
3050 md_flushinp() | 3159 md_flushinp(void) |
3051 { | 3160 { |
3052 /* ioctl(0,TIOCFLUSH) */ | 3161 /* ioctl(0,TIOCFLUSH) */ |
3053 /* ioctl(_tty_ch,TCFLSH,0) */ | 3162 /* ioctl(_tty_ch,TCFLSH,0) */ |
3054 flushinp(); | 3163 flushinp(); |
3055 } | 3164 } |
3056 | 3165 |
3057 int | 3166 int |
3058 md_getuid() | 3167 md_getuid(void) |
3059 { | 3168 { |
3060 #ifdef _WIN32 | 3169 #ifdef _WIN32 |
3061 return(42); | 3170 return(42); |
3062 #else | 3171 #else |
3063 return(getuid()); | 3172 return(getuid()); |
3064 #endif | 3173 #endif |
3065 } | 3174 } |
3066 | 3175 |
3067 long | 3176 long |
3068 md_memused() | 3177 md_memused(void) |
3069 { | 3178 { |
3070 #ifdef _WIN32 | 3179 #ifdef _WIN32 |
3071 MEMORYSTATUS stat; | 3180 MEMORYSTATUS stat; |
3072 | 3181 |
3073 GlobalMemoryStatus(&stat); | 3182 GlobalMemoryStatus(&stat); |
3077 return( (long)sbrk(0) ); | 3186 return( (long)sbrk(0) ); |
3078 #endif | 3187 #endif |
3079 } | 3188 } |
3080 | 3189 |
3081 char * | 3190 char * |
3082 md_getusername() | 3191 md_getusername(void) |
3083 { | 3192 { |
3084 static char login[80]; | 3193 static char login[80]; |
3085 char *l = NULL; | 3194 char *l = NULL; |
3086 #ifdef _WIN32 | 3195 #ifdef _WIN32 |
3087 LPSTR mybuffer; | 3196 LPSTR mybuffer; |
3112 | 3221 |
3113 return(login); | 3222 return(login); |
3114 } | 3223 } |
3115 | 3224 |
3116 char * | 3225 char * |
3117 md_gethomedir() | 3226 md_gethomedir(void) |
3118 { | 3227 { |
3119 static char homedir[PATH_MAX]; | 3228 static char homedir[PATH_MAX]; |
3120 char *h = NULL; | 3229 char *h = NULL; |
3121 size_t len; | 3230 size_t len; |
3122 #if defined(_WIN32) | 3231 #if defined(_WIN32) |
3179 | 3288 |
3180 return(0); | 3289 return(0); |
3181 } | 3290 } |
3182 | 3291 |
3183 char * | 3292 char * |
3184 md_getroguedir() | 3293 md_getroguedir(void) |
3185 { | 3294 { |
3186 static char path[1024]; | 3295 static char path[1024]; |
3187 char *end,*home; | 3296 char *end,*home; |
3188 | 3297 |
3189 if ( (home = getenv("ROGUEHOME")) != NULL) | 3298 if ( (home = getenv("ROGUEHOME")) != NULL) |
3216 | 3325 |
3217 return(""); | 3326 return(""); |
3218 } | 3327 } |
3219 | 3328 |
3220 char * | 3329 char * |
3221 md_getshell() | 3330 md_getshell(void) |
3222 { | 3331 { |
3223 static char shell[PATH_MAX]; | 3332 static char shell[PATH_MAX]; |
3224 char *s = NULL; | 3333 char *s = NULL; |
3225 #ifdef _WIN32 | 3334 #ifdef _WIN32 |
3226 char *def = "C:\\WINDOWS\\SYSTEM32\\CMD.EXE"; | 3335 char *def = "C:\\WINDOWS\\SYSTEM32\\CMD.EXE"; |
3244 | 3353 |
3245 return(shell); | 3354 return(shell); |
3246 } | 3355 } |
3247 | 3356 |
3248 char * | 3357 char * |
3249 md_gethostname() | 3358 md_gethostname(void) |
3250 { | 3359 { |
3251 static char nodename[80]; | 3360 static char nodename[80]; |
3252 char *n = NULL; | 3361 char *n = NULL; |
3253 #if !defined(_WIN32) && !defined(__DJGPP__) | 3362 #if !defined(_WIN32) && !defined(__DJGPP__) |
3254 struct utsname ourname; | 3363 struct utsname ourname; |
3266 | 3375 |
3267 return(nodename); | 3376 return(nodename); |
3268 } | 3377 } |
3269 | 3378 |
3270 int | 3379 int |
3271 md_shellescape() | 3380 md_shellescape(void) |
3272 { | 3381 { |
3273 #if (!defined(_WIN32) && !defined(__DJGPP__)) | 3382 #if (!defined(_WIN32) && !defined(__DJGPP__)) |
3274 int ret_status; | 3383 int ret_status; |
3275 int pid; | 3384 int pid; |
3276 #endif | 3385 #endif |
3306 return(ret_status); | 3415 return(ret_status); |
3307 #endif | 3416 #endif |
3308 } | 3417 } |
3309 | 3418 |
3310 int | 3419 int |
3311 md_erasechar() | 3420 md_erasechar(void) |
3312 { | 3421 { |
3313 /* | 3422 /* |
3314 return(_tty.sg_erase); | 3423 return(_tty.sg_erase); |
3315 return(_tty.c_cc[VERASE]); | 3424 return(_tty.c_cc[VERASE]); |
3316 */ | 3425 */ |
3317 return(erasechar()); | 3426 return(erasechar()); |
3318 } | 3427 } |
3319 | 3428 |
3320 int | 3429 int |
3321 md_killchar() | 3430 md_killchar(void) |
3322 { | 3431 { |
3323 /* | 3432 /* |
3324 return(_tty.sg_kill); | 3433 return(_tty.sg_kill); |
3325 return(_tty.c_cc[VKILL]); | 3434 return(_tty.c_cc[VKILL]); |
3326 */ | 3435 */ |
3360 return( htonl(x) ); | 3469 return( htonl(x) ); |
3361 #endif | 3470 #endif |
3362 } | 3471 } |
3363 | 3472 |
3364 void | 3473 void |
3365 md_init() | 3474 md_init(void) |
3366 { | 3475 { |
3367 #ifdef __INTERIX | 3476 #ifdef __INTERIX |
3368 char *term; | 3477 char *term; |
3369 | 3478 |
3370 term = getenv("TERM"); | 3479 term = getenv("TERM"); |
3376 _fmode = _O_BINARY; | 3485 _fmode = _O_BINARY; |
3377 #endif | 3486 #endif |
3378 } | 3487 } |
3379 | 3488 |
3380 char * | 3489 char * |
3381 md_getpass(prompt) | 3490 md_getpass(char *prompt) |
3382 char *prompt; | |
3383 { | 3491 { |
3384 #ifdef _WIN32 | 3492 #ifdef _WIN32 |
3385 static char password_buffer[9]; | 3493 static char password_buffer[9]; |
3386 char *p = password_buffer; | 3494 char *p = password_buffer; |
3387 int c, count = 0; | 3495 int c, count = 0; |
3444 * handle stop and start signals | 3552 * handle stop and start signals |
3445 */ | 3553 */ |
3446 | 3554 |
3447 /*UNUSED*/ | 3555 /*UNUSED*/ |
3448 void | 3556 void |
3449 tstp(a) | 3557 tstp(int a) |
3450 int a; | |
3451 { | 3558 { |
3452 mvcur(0, cols - 1, lines - 1, 0); | 3559 mvcur(0, cols - 1, lines - 1, 0); |
3453 fflush(stdout); | 3560 fflush(stdout); |
3454 kill(0, SIGTSTP); | 3561 kill(0, SIGTSTP); |
3455 signal(SIGTSTP, tstp); | 3562 signal(SIGTSTP, tstp); |
3460 draw(cw); | 3567 draw(cw); |
3461 flushinp(); | 3568 flushinp(); |
3462 } | 3569 } |
3463 #endif | 3570 #endif |
3464 | 3571 |
3465 int | 3572 void |
3466 md_setup() | 3573 md_setup(void) |
3467 { | 3574 { |
3468 #ifdef SIGTSTP | 3575 #ifdef SIGTSTP |
3469 signal(SIGTSTP, tstp); | 3576 signal(SIGTSTP, tstp); |
3470 #endif | 3577 #endif |
3471 #ifdef SIGHUP | 3578 #ifdef SIGHUP |