Mercurial > hg > early-roguelike
comparison srogue/rip.c @ 190:f4f6734771e0
srogue: add and use md_fdopen().
The implementation was copied from rogue4. Using fdopen() is necessary
because the scorefile needs both encread() and encwrite(). For some
reason I have failed to discover, one of them uses FILE *'s and the
other uses file descriptors.
| author | John "Elwin" Edwards |
|---|---|
| date | Mon, 03 Aug 2015 09:27:43 -0400 |
| parents | 78fa1d0e5d25 |
| children | 94a0d9dd5ce1 |
comparison
equal
deleted
inserted
replaced
| 189:7c552cbc6ad9 | 190:f4f6734771e0 |
|---|---|
| 143 /* | 143 /* |
| 144 * Open file and read list | 144 * Open file and read list |
| 145 */ | 145 */ |
| 146 if ((fd = scorefd) < 0) | 146 if ((fd = scorefd) < 0) |
| 147 return; | 147 return; |
| 148 outf = (FILE *) fdopen(fd, "w"); | 148 outf = (FILE *) md_fdopen(fd, "w"); |
| 149 for (scp = top_ten; scp <= &top_ten[9]; scp++) { | 149 for (scp = top_ten; scp <= &top_ten[9]; scp++) { |
| 150 scp->sc_score = 0; | 150 scp->sc_score = 0; |
| 151 for (i = 0; i < 80; i++) | 151 for (i = 0; i < 80; i++) |
| 152 scp->sc_name[i] = rnd(255); | 152 scp->sc_name[i] = rnd(255); |
| 153 scp->sc_flags = rnd(255); | 153 scp->sc_flags = rnd(255); |
