comparison xrogue/state.c @ 279:d3968e9cb98d

Use C stdio functions for score files and save files. Switching from Unix file descriptor operations to C standard FILE* functions will reduce portability problems.
author John "Elwin" Edwards
date Fri, 15 Sep 2017 19:57:54 -0400
parents 3d4252fa2ed3
children 6376b514a30b
comparison
equal deleted inserted replaced
278:c222f9d56776 279:d3968e9cb98d
94 int format_error = FALSE; 94 int format_error = FALSE;
95 95
96 int save_debug = FALSE; 96 int save_debug = FALSE;
97 #define DBG(x) {if (save_debug) rsPrintf x;} 97 #define DBG(x) {if (save_debug) rsPrintf x;}
98 98
99 bool rs_read_new_string(int inf, char **s); 99 bool rs_read_new_string(FILE *inf, char **s);
100 int find_list_ptr(struct linked_list *l, void *ptr); 100 int find_list_ptr(struct linked_list *l, void *ptr);
101 bool rs_write_coord_list(FILE *savef, struct linked_list *l); 101 bool rs_write_coord_list(FILE *savef, struct linked_list *l);
102 bool rs_read_coord_list(int inf, struct linked_list **list); 102 bool rs_read_coord_list(FILE *inf, struct linked_list **list);
103 int list_size(struct linked_list *l); 103 int list_size(struct linked_list *l);
104 bool rs_write_object_list(FILE *savef, struct linked_list *l); 104 bool rs_write_object_list(FILE *savef, struct linked_list *l);
105 bool rs_read_object_list(int inf, struct linked_list **list); 105 bool rs_read_object_list(FILE *inf, struct linked_list **list);
106 106
107 int 107 int
108 rsPrintf(char *fmt, ...) 108 rsPrintf(char *fmt, ...)
109 { 109 {
110 va_list ap; 110 va_list ap;
150 } 150 }
151 151
152 int end_of_file = FALSE; 152 int end_of_file = FALSE;
153 153
154 bool 154 bool
155 rs_read(int inf, void *ptr, size_t size) 155 rs_read(FILE *inf, void *ptr, size_t size)
156 { 156 {
157 int actual; 157 int actual;
158 end_of_file =FALSE; 158 end_of_file =FALSE;
159 if (!read_error && !format_error) 159 if (!read_error && !format_error)
160 { 160 {
282 282
283 return(WRITESTAT); 283 return(WRITESTAT);
284 } 284 }
285 285
286 bool 286 bool
287 rs_read_int(int inf, int *i) 287 rs_read_int(FILE *inf, int *i)
288 { 288 {
289 char bytes[4]; 289 char bytes[4];
290 int input; 290 int input;
291 char *buf = (char *)&input; 291 char *buf = (char *)&input;
292 292
305 305
306 return(READSTAT); 306 return(READSTAT);
307 } 307 }
308 308
309 bool 309 bool
310 rs_read_uint(int inf, unsigned int *i) 310 rs_read_uint(FILE *inf, unsigned int *i)
311 { 311 {
312 char bytes[4]; 312 char bytes[4];
313 int input; 313 int input;
314 char *buf = (char *)&input; 314 char *buf = (char *)&input;
315 315
328 328
329 return(READSTAT); 329 return(READSTAT);
330 } 330 }
331 331
332 bool 332 bool
333 rs_read_ulong(int inf, unsigned long *i) 333 rs_read_ulong(FILE *inf, unsigned long *i)
334 { 334 {
335 char bytes[4]; 335 char bytes[4];
336 unsigned long input; 336 unsigned long input;
337 char *buf = (char *) &input; 337 char *buf = (char *) &input;
338 338
353 *i = *((unsigned long *) buf); 353 *i = *((unsigned long *) buf);
354 return(READSTAT); 354 return(READSTAT);
355 } 355 }
356 356
357 bool 357 bool
358 rs_read_long(int inf, long *i) 358 rs_read_long(FILE *inf, long *i)
359 { 359 {
360 char bytes[4]; 360 char bytes[4];
361 long input; 361 long input;
362 char *buf = (char *) &input; 362 char *buf = (char *) &input;
363 363
378 *i = *((long *) buf); 378 *i = *((long *) buf);
379 return(READSTAT); 379 return(READSTAT);
380 } 380 }
381 381
382 bool 382 bool
383 rs_read_boolean(int inf, bool *i) 383 rs_read_boolean(FILE *inf, bool *i)
384 { 384 {
385 char buf; 385 char buf;
386 386
387 rs_read(inf, &buf, 1); 387 rs_read(inf, &buf, 1);
388 388
421 421
422 return(WRITESTAT); 422 return(WRITESTAT);
423 } 423 }
424 424
425 bool 425 bool
426 rs_read_short(int inf, short *s) 426 rs_read_short(FILE *inf, short *s)
427 { 427 {
428 char bytes[2]; 428 char bytes[2];
429 short input; 429 short input;
430 char *buf = (char *)&input; 430 char *buf = (char *)&input;
431 431
494 494
495 return(WRITESTAT); 495 return(WRITESTAT);
496 } 496 }
497 497
498 bool 498 bool
499 rs_read_ints(int inf, int *i, int count) 499 rs_read_ints(FILE *inf, int *i, int count)
500 { 500 {
501 int n=0,value=0; 501 int n=0,value=0;
502 502
503 if (rs_read_int(inf,&value) != 0) 503 if (rs_read_int(inf,&value) != 0)
504 { 504 {
513 513
514 return(READSTAT); 514 return(READSTAT);
515 } 515 }
516 516
517 bool 517 bool
518 rs_read_shorts(int inf, short *i, int count) 518 rs_read_shorts(FILE *inf, short *i, int count)
519 { 519 {
520 int n=0,value=0; 520 int n=0,value=0;
521 521
522 if (rs_read_int(inf,&value) != 0) 522 if (rs_read_int(inf,&value) != 0)
523 { 523 {
532 532
533 return(READSTAT); 533 return(READSTAT);
534 } 534 }
535 535
536 bool 536 bool
537 rs_read_longs(int inf, long *i, int count) 537 rs_read_longs(FILE *inf, long *i, int count)
538 { 538 {
539 int n=0,value=0; 539 int n=0,value=0;
540 540
541 if (rs_read_int(inf,&value) != 0) 541 if (rs_read_int(inf,&value) != 0)
542 { 542 {
551 551
552 return(READSTAT); 552 return(READSTAT);
553 } 553 }
554 554
555 bool 555 bool
556 rs_read_ulongs(int inf, unsigned long *i, int count) 556 rs_read_ulongs(FILE *inf, unsigned long *i, int count)
557 { 557 {
558 int n=0,value=0; 558 int n=0,value=0;
559 559
560 if (rs_read_int(inf,&value) != 0) 560 if (rs_read_int(inf,&value) != 0)
561 { 561 {
570 570
571 return(READSTAT); 571 return(READSTAT);
572 } 572 }
573 573
574 bool 574 bool
575 rs_read_booleans(int inf, bool *i, int count) 575 rs_read_booleans(FILE *inf, bool *i, int count)
576 { 576 {
577 int n=0,value=0; 577 int n=0,value=0;
578 578
579 if (rs_read_int(inf,&value) != 0) 579 if (rs_read_int(inf,&value) != 0)
580 { 580 {
609 609
610 return(WRITESTAT); 610 return(WRITESTAT);
611 } 611 }
612 612
613 bool 613 bool
614 rs_read_levtype(int inf, LEVTYPE *l) 614 rs_read_levtype(FILE *inf, LEVTYPE *l)
615 { 615 {
616 int lt; 616 int lt;
617 617
618 rs_read_int(inf, &lt); 618 rs_read_int(inf, &lt);
619 619
638 638
639 return(WRITESTAT); 639 return(WRITESTAT);
640 } 640 }
641 641
642 bool 642 bool
643 rs_read_char(int inf, char *c) 643 rs_read_char(FILE *inf, char *c)
644 { 644 {
645 rs_read(inf, c, 1); 645 rs_read(inf, c, 1);
646 646
647 return(READSTAT); 647 return(READSTAT);
648 } 648 }
655 655
656 return(WRITESTAT); 656 return(WRITESTAT);
657 } 657 }
658 658
659 bool 659 bool
660 rs_read_uchar(int inf, unsigned char *c) 660 rs_read_uchar(FILE *inf, unsigned char *c)
661 { 661 {
662 rs_read(inf, c, 1); 662 rs_read(inf, c, 1);
663 663
664 return(READSTAT); 664 return(READSTAT);
665 } 665 }
676 676
677 return(WRITESTAT); 677 return(WRITESTAT);
678 } 678 }
679 679
680 bool 680 bool
681 rs_read_string_index(int inf, struct words master[], int maxindex, char **str) 681 rs_read_string_index(FILE *inf, struct words master[], int maxindex, char **str)
682 { 682 {
683 int i; 683 int i;
684 684
685 if (rs_read_int(inf,&i) != 0) 685 if (rs_read_int(inf,&i) != 0)
686 { 686 {
716 rs_write_int(savef,-1); 716 rs_write_int(savef,-1);
717 return(WRITESTAT); 717 return(WRITESTAT);
718 } 718 }
719 719
720 bool 720 bool
721 rs_read_scrolls(int inf) 721 rs_read_scrolls(FILE *inf)
722 { 722 {
723 int i; 723 int i;
724 724
725 for(i = 0; i < MAXSCROLLS; i++) 725 for(i = 0; i < MAXSCROLLS; i++)
726 { 726 {
745 } 745 }
746 return(WRITESTAT); 746 return(WRITESTAT);
747 } 747 }
748 748
749 bool 749 bool
750 rs_read_potions(int inf) 750 rs_read_potions(FILE *inf)
751 { 751 {
752 int i; 752 int i;
753 753
754 for(i = 0; i < MAXPOTIONS; i++) 754 for(i = 0; i < MAXPOTIONS; i++)
755 { 755 {
775 775
776 return(WRITESTAT); 776 return(WRITESTAT);
777 } 777 }
778 778
779 bool 779 bool
780 rs_read_rings(int inf) 780 rs_read_rings(FILE *inf)
781 { 781 {
782 int i; 782 int i;
783 783
784 for(i = 0; i < MAXRINGS; i++) 784 for(i = 0; i < MAXRINGS; i++)
785 { 785 {
805 805
806 return(WRITESTAT); 806 return(WRITESTAT);
807 } 807 }
808 808
809 bool 809 bool
810 rs_read_misc(int inf) 810 rs_read_misc(FILE *inf)
811 { 811 {
812 int i; 812 int i;
813 813
814 for(i = 0; i < MAXMM; i++) 814 for(i = 0; i < MAXMM; i++)
815 { 815 {
857 857
858 return(WRITESTAT); 858 return(WRITESTAT);
859 } 859 }
860 860
861 bool 861 bool
862 rs_read_sticks(int inf) 862 rs_read_sticks(FILE *inf)
863 { 863 {
864 int i = 0, list = 0; 864 int i = 0, list = 0;
865 865
866 for(i = 0; i < MAXSTICKS; i++) 866 for(i = 0; i < MAXSTICKS; i++)
867 { 867 {
882 882
883 return(READSTAT); 883 return(READSTAT);
884 } 884 }
885 885
886 bool 886 bool
887 rs_read_string(int inf, char *s, int max) 887 rs_read_string(FILE *inf, char *s, int max)
888 { 888 {
889 int len = 0; 889 int len = 0;
890 890
891 if (rs_read_int(inf, &len) != FALSE) 891 if (rs_read_int(inf, &len) != FALSE)
892 { 892 {
902 902
903 return(READSTAT); 903 return(READSTAT);
904 } 904 }
905 905
906 bool 906 bool
907 rs_read_new_string(int inf, char **s) 907 rs_read_new_string(FILE *inf, char **s)
908 { 908 {
909 int len=0; 909 int len=0;
910 char *buf=0; 910 char *buf=0;
911 911
912 if (rs_read_int(inf, &len) != 0) 912 if (rs_read_int(inf, &len) != 0)
964 964
965 return(WRITESTAT); 965 return(WRITESTAT);
966 } 966 }
967 967
968 bool 968 bool
969 rs_read_words(int inf, struct words *w, int count) 969 rs_read_words(FILE *inf, struct words *w, int count)
970 { 970 {
971 int n = 0; 971 int n = 0;
972 int value = 0; 972 int value = 0;
973 973
974 rs_read_int(inf,&value); 974 rs_read_int(inf,&value);
987 987
988 return(READSTAT); 988 return(READSTAT);
989 } 989 }
990 990
991 bool 991 bool
992 rs_read_new_strings(int inf, char **s, int count) 992 rs_read_new_strings(FILE *inf, char **s, int count)
993 { 993 {
994 int len = 0; 994 int len = 0;
995 int n = 0; 995 int n = 0;
996 int value = 0; 996 int value = 0;
997 997
1032 1032
1033 return(WRITESTAT); 1033 return(WRITESTAT);
1034 } 1034 }
1035 1035
1036 bool 1036 bool
1037 rs_read_coord(int inf, coord *c) 1037 rs_read_coord(FILE *inf, coord *c)
1038 { 1038 {
1039 rs_read_int(inf,&c->x); 1039 rs_read_int(inf,&c->x);
1040 rs_read_int(inf,&c->y); 1040 rs_read_int(inf,&c->y);
1041 1041
1042 return(READSTAT); 1042 return(READSTAT);
1231 1231
1232 return(WRITESTAT); 1232 return(WRITESTAT);
1233 } 1233 }
1234 1234
1235 bool 1235 bool
1236 rs_read_daemons(int inf, struct delayed_action *d_list, int count) 1236 rs_read_daemons(FILE *inf, struct delayed_action *d_list, int count)
1237 { 1237 {
1238 int i = 0; 1238 int i = 0;
1239 int func = 0; 1239 int func = 0;
1240 int value = 0; 1240 int value = 0;
1241 int id = 0; 1241 int id = 0;
1436 } 1436 }
1437 return(WRITESTAT); 1437 return(WRITESTAT);
1438 } 1438 }
1439 1439
1440 bool 1440 bool
1441 rs_read_rooms(int inf, struct room *r, int count) 1441 rs_read_rooms(FILE *inf, struct room *r, int count)
1442 { 1442 {
1443 int value = 0, n = 0, i = 0, index = 0, id = 0; 1443 int value = 0, n = 0, i = 0, index = 0, id = 0;
1444 struct linked_list *fires=NULL, *item = NULL; 1444 struct linked_list *fires=NULL, *item = NULL;
1445 1445
1446 if (rs_read_int(inf,&id) != 0) 1446 if (rs_read_int(inf,&id) != 0)
1549 1549
1550 return(WRITESTAT); 1550 return(WRITESTAT);
1551 } 1551 }
1552 1552
1553 bool 1553 bool
1554 rs_read_object(int inf, struct object *o) 1554 rs_read_object(FILE *inf, struct object *o)
1555 { 1555 {
1556 int id; 1556 int id;
1557 1557
1558 if (rs_read_int(inf, &id) != 0) 1558 if (rs_read_int(inf, &id) != 0)
1559 { 1559 {
1610 1610
1611 return(WRITESTAT); 1611 return(WRITESTAT);
1612 } 1612 }
1613 1613
1614 bool 1614 bool
1615 rs_read_stats(int inf, struct stats *s) 1615 rs_read_stats(FILE *inf, struct stats *s)
1616 { 1616 {
1617 int id; 1617 int id;
1618 1618
1619 if (rs_read_int(inf, &id) != 0) 1619 if (rs_read_int(inf, &id) != 0)
1620 { 1620 {
1664 1664
1665 return(WRITESTAT); 1665 return(WRITESTAT);
1666 } 1666 }
1667 1667
1668 bool 1668 bool
1669 rs_read_mstats(int inf, struct mstats *s) 1669 rs_read_mstats(FILE *inf, struct mstats *s)
1670 { 1670 {
1671 int id; 1671 int id;
1672 1672
1673 if (rs_read_int(inf, &id) != 0) 1673 if (rs_read_int(inf, &id) != 0)
1674 { 1674 {
1724 } 1724 }
1725 return(WRITESTAT); 1725 return(WRITESTAT);
1726 } 1726 }
1727 1727
1728 bool 1728 bool
1729 rs_read_init_weps(int inf, struct init_weps *w,int count) 1729 rs_read_init_weps(FILE *inf, struct init_weps *w,int count)
1730 { 1730 {
1731 int id,value,i; 1731 int id,value,i;
1732 1732
1733 rs_read_int(inf, &id); 1733 rs_read_int(inf, &id);
1734 rs_read_int(inf, &value); 1734 rs_read_int(inf, &value);
1771 } 1771 }
1772 return(WRITESTAT); 1772 return(WRITESTAT);
1773 } 1773 }
1774 1774
1775 bool 1775 bool
1776 rs_read_init_armor(int inf, struct init_armor *a,int count) 1776 rs_read_init_armor(FILE *inf, struct init_armor *a,int count)
1777 { 1777 {
1778 int id,value,i; 1778 int id,value,i;
1779 1779
1780 rs_read_int(inf, &id); 1780 rs_read_int(inf, &id);
1781 rs_read_int(inf, &value); 1781 rs_read_int(inf, &value);
1808 } 1808 }
1809 return(WRITESTAT); 1809 return(WRITESTAT);
1810 } 1810 }
1811 1811
1812 bool 1812 bool
1813 rs_read_spells(int inf, struct spells *s,int count) 1813 rs_read_spells(FILE *inf, struct spells *s,int count)
1814 { 1814 {
1815 int id,value,i; 1815 int id,value,i;
1816 1816
1817 rs_read_int(inf, &id); 1817 rs_read_int(inf, &id);
1818 rs_read_int(inf, &value); 1818 rs_read_int(inf, &value);
1836 rs_write(savef, i->item_desc, sizeof(i->item_desc)); 1836 rs_write(savef, i->item_desc, sizeof(i->item_desc));
1837 return(WRITESTAT); 1837 return(WRITESTAT);
1838 } 1838 }
1839 1839
1840 bool 1840 bool
1841 rs_read_item_list(int inf, struct item_list *i) 1841 rs_read_item_list(FILE *inf, struct item_list *i)
1842 { 1842 {
1843 int id; 1843 int id;
1844 1844
1845 rs_read_int(inf, &id); 1845 rs_read_int(inf, &id);
1846 1846
1858 rs_write(savef, h->h_desc, sizeof(h->h_desc)); 1858 rs_write(savef, h->h_desc, sizeof(h->h_desc));
1859 return(WRITESTAT); 1859 return(WRITESTAT);
1860 } 1860 }
1861 1861
1862 bool 1862 bool
1863 rs_read_h_list(int inf, struct h_list *h) 1863 rs_read_h_list(FILE *inf, struct h_list *h)
1864 { 1864 {
1865 int id; 1865 int id;
1866 1866
1867 rs_read_int(inf, &id); 1867 rs_read_int(inf, &id);
1868 1868
1887 } 1887 }
1888 return(WRITESTAT); 1888 return(WRITESTAT);
1889 } 1889 }
1890 1890
1891 bool 1891 bool
1892 rs_read_death_types(int inf, struct death_type *d, int count) 1892 rs_read_death_types(FILE *inf, struct death_type *d, int count)
1893 { 1893 {
1894 int id,value,i; 1894 int id,value,i;
1895 1895
1896 rs_read_int(inf, &id); 1896 rs_read_int(inf, &id);
1897 rs_read_int(inf, &value); 1897 rs_read_int(inf, &value);
1933 } 1933 }
1934 return(WRITESTAT); 1934 return(WRITESTAT);
1935 } 1935 }
1936 1936
1937 bool 1937 bool
1938 rs_read_character_types(int inf, struct character_types *c,int count) 1938 rs_read_character_types(FILE *inf, struct character_types *c,int count)
1939 { 1939 {
1940 int id,value,i; 1940 int id,value,i;
1941 1941
1942 rs_read_int(inf, &id); 1942 rs_read_int(inf, &id);
1943 rs_read_int(inf, &value); 1943 rs_read_int(inf, &value);
1982 } 1982 }
1983 return(WRITESTAT); 1983 return(WRITESTAT);
1984 } 1984 }
1985 1985
1986 bool 1986 bool
1987 rs_read_traps(int inf, struct trap *trap, int count) 1987 rs_read_traps(FILE *inf, struct trap *trap, int count)
1988 { 1988 {
1989 int id = 0, value = 0, n = 0; 1989 int id = 0, value = 0, n = 0;
1990 1990
1991 if (rs_read_int(inf,&id) != 0) 1991 if (rs_read_int(inf,&id) != 0)
1992 { 1992 {
2052 2052
2053 return(WRITESTAT); 2053 return(WRITESTAT);
2054 } 2054 }
2055 2055
2056 bool 2056 bool
2057 rs_read_monsters(int inf, struct monster *m, int count) 2057 rs_read_monsters(FILE *inf, struct monster *m, int count)
2058 { 2058 {
2059 int id = 0, value = 0, n = 0; 2059 int id = 0, value = 0, n = 0;
2060 char buffer[1024]; 2060 char buffer[1024];
2061 2061
2062 if (rs_read_int(inf, &id) != 0) 2062 if (rs_read_int(inf, &id) != 0)
2128 2128
2129 return(WRITESTAT); 2129 return(WRITESTAT);
2130 } 2130 }
2131 2131
2132 bool 2132 bool
2133 rs_read_coord_list(int inf, struct linked_list **list) 2133 rs_read_coord_list(FILE *inf, struct linked_list **list)
2134 { 2134 {
2135 int id; 2135 int id;
2136 int i, cnt; 2136 int i, cnt;
2137 struct linked_list *l = NULL, *previous = NULL, *head = NULL; 2137 struct linked_list *l = NULL, *previous = NULL, *head = NULL;
2138 2138
2188 2188
2189 return(WRITESTAT); 2189 return(WRITESTAT);
2190 } 2190 }
2191 2191
2192 bool 2192 bool
2193 rs_read_object_list(int inf, struct linked_list **list) 2193 rs_read_object_list(FILE *inf, struct linked_list **list)
2194 { 2194 {
2195 int id; 2195 int id;
2196 int i, cnt; 2196 int i, cnt;
2197 struct linked_list *l = NULL, *previous = NULL, *head = NULL; 2197 struct linked_list *l = NULL, *previous = NULL, *head = NULL;
2198 2198
2396 t->t_dest = &tp->t_pos; 2396 t->t_dest = &tp->t_pos;
2397 } 2397 }
2398 } 2398 }
2399 2399
2400 bool 2400 bool
2401 rs_read_thing(int inf, struct thing *t) 2401 rs_read_thing(FILE *inf, struct thing *t)
2402 { 2402 {
2403 int id; 2403 int id;
2404 int listid = 0, index = -1; 2404 int listid = 0, index = -1;
2405 struct linked_list *item; 2405 struct linked_list *item;
2406 2406
2540 for(item = list; item != NULL; item = item->l_next) 2540 for(item = list; item != NULL; item = item->l_next)
2541 rs_fix_thing(THINGPTR(item)); 2541 rs_fix_thing(THINGPTR(item));
2542 } 2542 }
2543 2543
2544 bool 2544 bool
2545 rs_read_monster_list(int inf, struct linked_list **list) 2545 rs_read_monster_list(FILE *inf, struct linked_list **list)
2546 { 2546 {
2547 int id; 2547 int id;
2548 int i, cnt; 2548 int i, cnt;
2549 struct linked_list *l = NULL, *previous = NULL, *head = NULL; 2549 struct linked_list *l = NULL, *previous = NULL, *head = NULL;
2550 2550
2603 2603
2604 return(WRITESTAT); 2604 return(WRITESTAT);
2605 } 2605 }
2606 2606
2607 bool 2607 bool
2608 rs_read_magic_items(int inf, struct magic_item *mi, int count) 2608 rs_read_magic_items(FILE *inf, struct magic_item *mi, int count)
2609 { 2609 {
2610 int id; 2610 int id;
2611 int n; 2611 int n;
2612 int value; 2612 int value;
2613 2613
2662 2662
2663 return(WRITESTAT); 2663 return(WRITESTAT);
2664 } 2664 }
2665 2665
2666 bool 2666 bool
2667 rs_read_window(int inf, WINDOW *win) 2667 rs_read_window(FILE *inf, WINDOW *win)
2668 { 2668 {
2669 int row,col,maxlines,maxcols,value,width,height; 2669 int row,col,maxlines,maxcols,value,width,height;
2670 2670
2671 width = getmaxx(win); 2671 width = getmaxx(win);
2672 height = getmaxy(win); 2672 height = getmaxy(win);
2847 rs_write_coord(savef,&move_nh); /* move.c */ 2847 rs_write_coord(savef,&move_nh); /* move.c */
2848 return(WRITESTAT); 2848 return(WRITESTAT);
2849 } 2849 }
2850 2850
2851 bool 2851 bool
2852 rs_restore_file(int inf) 2852 rs_restore_file(FILE *inf)
2853 { 2853 {
2854 int weapon, armor, ring, misc, room = -1,i,checkpoint; 2854 int weapon, armor, ring, misc, room = -1,i,checkpoint;
2855 int endian = 0x01020304; 2855 int endian = 0x01020304;
2856 big_endian = ( *((char *)&endian) == 0x01 ); 2856 big_endian = ( *((char *)&endian) == 0x01 );
2857 2857
3032 3032
3033 int 3033 int
3034 rs_read_scorefile(FILE *savef, struct sc_ent *entries, int count) 3034 rs_read_scorefile(FILE *savef, struct sc_ent *entries, int count)
3035 { 3035 {
3036 int i,available = 0; 3036 int i,available = 0;
3037 int sfd = md_fileno(savef); 3037
3038 3038 rs_read_int(savef, &available);
3039 rs_read_int(sfd, &available);
3040 3039
3041 if (end_of_file) 3040 if (end_of_file)
3042 return(-1); 3041 return(-1);
3043 3042
3044 if (available != count) 3043 if (available != count)
3045 return(-2); 3044 return(-2);
3046 3045
3047 for(i = 0; i < count; i++) 3046 for(i = 0; i < count; i++)
3048 { 3047 {
3049 rs_read_ulong(sfd, &entries[i].sc_score); 3048 rs_read_ulong(savef, &entries[i].sc_score);
3050 rs_read(sfd, entries[i].sc_name, sizeof(entries[i].sc_name)); 3049 rs_read(savef, entries[i].sc_name, sizeof(entries[i].sc_name));
3051 rs_read(sfd, entries[i].sc_system, sizeof(entries[i].sc_system)); 3050 rs_read(savef, entries[i].sc_system, sizeof(entries[i].sc_system));
3052 rs_read(sfd, entries[i].sc_login, sizeof(entries[i].sc_login)); 3051 rs_read(savef, entries[i].sc_login, sizeof(entries[i].sc_login));
3053 rs_read_short(sfd, &entries[i].sc_flags); 3052 rs_read_short(savef, &entries[i].sc_flags);
3054 rs_read_short(sfd, &entries[i].sc_level); 3053 rs_read_short(savef, &entries[i].sc_level);
3055 rs_read_short(sfd, &entries[i].sc_ctype); 3054 rs_read_short(savef, &entries[i].sc_ctype);
3056 rs_read_short(sfd, &entries[i].sc_monster); 3055 rs_read_short(savef, &entries[i].sc_monster);
3057 rs_read_short(sfd, &entries[i].sc_quest); 3056 rs_read_short(savef, &entries[i].sc_quest);
3058 } 3057 }
3059 3058
3060 return(0); 3059 return(0);
3061 } 3060 }
3062 3061