Mercurial > hg > early-roguelike
comparison arogue5/io.c @ 218:56e748983fa8
Advanced Rogue 5: convert to ANSI function declarations.
This still leaves over a thousand lines of warning messages, mostly
related to the return types of daemons and fuses.
| author | John "Elwin" Edwards |
|---|---|
| date | Sun, 07 Feb 2016 14:39:21 -0500 |
| parents | c49f7927b0fa |
| children |
comparison
equal
deleted
inserted
replaced
| 217:94a0d9dd5ce1 | 218:56e748983fa8 |
|---|---|
| 16 #include <ctype.h> | 16 #include <ctype.h> |
| 17 #include <string.h> | 17 #include <string.h> |
| 18 #include <stdarg.h> | 18 #include <stdarg.h> |
| 19 #include "rogue.h" | 19 #include "rogue.h" |
| 20 | 20 |
| 21 void doadd(char *fmt, va_list ap); | |
| 22 void ministat(void); | |
| 23 | |
| 21 /* | 24 /* |
| 22 * msg: | 25 * msg: |
| 23 * Display a message at the top of the screen. | 26 * Display a message at the top of the screen. |
| 24 */ | 27 */ |
| 25 | 28 |
| 26 static char msgbuf[BUFSIZ]; | 29 static char msgbuf[BUFSIZ]; |
| 27 static int newpos = 0; | 30 static int newpos = 0; |
| 28 | 31 |
| 29 /*VARARGS1*/ | 32 /*VARARGS1*/ |
| 33 void | |
| 30 msg(char *fmt, ...) | 34 msg(char *fmt, ...) |
| 31 { | 35 { |
| 32 va_list ap; | 36 va_list ap; |
| 33 /* | 37 /* |
| 34 * if the string is "", just clear the line | 38 * if the string is "", just clear the line |
| 52 } | 56 } |
| 53 | 57 |
| 54 /* | 58 /* |
| 55 * add things to the current message | 59 * add things to the current message |
| 56 */ | 60 */ |
| 61 void | |
| 57 addmsg(char *fmt, ...) | 62 addmsg(char *fmt, ...) |
| 58 { | 63 { |
| 59 va_list ap; | 64 va_list ap; |
| 60 va_start(ap,fmt); | 65 va_start(ap,fmt); |
| 61 doadd(fmt, ap); | 66 doadd(fmt, ap); |
| 64 | 69 |
| 65 /* | 70 /* |
| 66 * Display a new msg (giving him a chance to see the previous one if it | 71 * Display a new msg (giving him a chance to see the previous one if it |
| 67 * is up there with the --More--) | 72 * is up there with the --More--) |
| 68 */ | 73 */ |
| 69 endmsg() | 74 void |
| 75 endmsg(void) | |
| 70 { | 76 { |
| 71 strncpy(huh, msgbuf, sizeof(huh)); | 77 strncpy(huh, msgbuf, sizeof(huh)); |
| 72 | 78 |
| 73 huh[ sizeof(huh) - 1 ] = 0; | 79 huh[ sizeof(huh) - 1 ] = 0; |
| 74 | 80 |
| 94 draw(cw); | 100 draw(cw); |
| 95 clearok(msgw, FALSE); | 101 clearok(msgw, FALSE); |
| 96 draw(msgw); | 102 draw(msgw); |
| 97 } | 103 } |
| 98 | 104 |
| 105 void | |
| 99 doadd(char *fmt, va_list ap) | 106 doadd(char *fmt, va_list ap) |
| 100 { | 107 { |
| 101 /* | 108 /* |
| 102 * Do the sprintf into newmsg and append to msgbuf | 109 * Do the sprintf into newmsg and append to msgbuf |
| 103 */ | 110 */ |
| 111 * step_ok: | 118 * step_ok: |
| 112 * returns true if it is ok for type to step on ch | 119 * returns true if it is ok for type to step on ch |
| 113 * flgptr will be NULL if we don't know what the monster is yet! | 120 * flgptr will be NULL if we don't know what the monster is yet! |
| 114 */ | 121 */ |
| 115 | 122 |
| 116 step_ok(y, x, can_on_monst, flgptr) | 123 bool |
| 117 register int y, x, can_on_monst; | 124 step_ok(int y, int x, int can_on_monst, struct thing *flgptr) |
| 118 register struct thing *flgptr; | |
| 119 { | 125 { |
| 120 /* can_on_monst = MONSTOK if all we care about are physical obstacles */ | 126 /* can_on_monst = MONSTOK if all we care about are physical obstacles */ |
| 121 register struct linked_list *item; | 127 register struct linked_list *item; |
| 122 char ch; | 128 char ch; |
| 123 | 129 |
| 154 /* | 160 /* |
| 155 * shoot_ok: | 161 * shoot_ok: |
| 156 * returns true if it is ok for type to shoot over ch | 162 * returns true if it is ok for type to shoot over ch |
| 157 */ | 163 */ |
| 158 | 164 |
| 159 shoot_ok(ch) | 165 bool |
| 166 shoot_ok(char ch) | |
| 160 { | 167 { |
| 161 switch (ch) | 168 switch (ch) |
| 162 { | 169 { |
| 163 case ' ': | 170 case ' ': |
| 164 case '|': | 171 case '|': |
| 175 * readchar: | 182 * readchar: |
| 176 * flushes stdout so that screen is up to date and then returns | 183 * flushes stdout so that screen is up to date and then returns |
| 177 * getchar. | 184 * getchar. |
| 178 */ | 185 */ |
| 179 | 186 |
| 180 readchar() | 187 int |
| 188 readchar(void) | |
| 181 { | 189 { |
| 182 int ch; | 190 int ch; |
| 183 | 191 |
| 184 ch = md_readchar(cw); | 192 ch = md_readchar(cw); |
| 185 | 193 |
| 193 } | 201 } |
| 194 | 202 |
| 195 /* | 203 /* |
| 196 * status: | 204 * status: |
| 197 * Display the important stats line. Keep the cursor where it was. | 205 * Display the important stats line. Keep the cursor where it was. |
| 198 */ | 206 * If display is TRUE, display unconditionally |
| 199 | 207 */ |
| 200 status(display) | 208 |
| 201 bool display; /* is TRUE, display unconditionally */ | 209 void |
| 210 status(bool display) | |
| 202 { | 211 { |
| 203 register struct stats *stat_ptr, *max_ptr; | 212 register struct stats *stat_ptr, *max_ptr; |
| 204 register int oy = 0, ox = 0, temp; | 213 register int oy = 0, ox = 0, temp; |
| 205 register char *pb; | 214 register char *pb; |
| 206 static char buf[LINELEN]; | 215 static char buf[LINELEN]; |
| 325 wclrtoeol(cw); | 334 wclrtoeol(cw); |
| 326 s_hungry = hungry_state; | 335 s_hungry = hungry_state; |
| 327 wmove(cw, oy, ox); | 336 wmove(cw, oy, ox); |
| 328 } | 337 } |
| 329 | 338 |
| 330 ministat() | 339 void |
| 340 ministat(void) | |
| 331 { | 341 { |
| 332 register int oy, ox, temp; | 342 register int oy, ox, temp; |
| 333 static char buf[LINELEN]; | 343 static char buf[LINELEN]; |
| 334 static int hpwidth = 0; | 344 static int hpwidth = 0; |
| 335 static int s_lvl = -1, s_pur, s_hp = -1; | 345 static int s_lvl = -1, s_pur, s_hp = -1; |
| 365 /* | 375 /* |
| 366 * wait_for | 376 * wait_for |
| 367 * Sit around until the guy types the right key | 377 * Sit around until the guy types the right key |
| 368 */ | 378 */ |
| 369 | 379 |
| 370 wait_for(win,ch) | 380 void |
| 371 WINDOW *win; | 381 wait_for(WINDOW *win, char ch) |
| 372 register char ch; | |
| 373 { | 382 { |
| 374 register char c; | 383 register char c; |
| 375 | 384 |
| 376 if (ch == '\n') | 385 if (ch == '\n') |
| 377 while ((c = wgetch(win)) != '\n' && c != '\r') | 386 while ((c = wgetch(win)) != '\n' && c != '\r') |
| 384 /* | 393 /* |
| 385 * show_win: | 394 * show_win: |
| 386 * function used to display a window and wait before returning | 395 * function used to display a window and wait before returning |
| 387 */ | 396 */ |
| 388 | 397 |
| 389 show_win(scr, message) | 398 void |
| 390 register WINDOW *scr; | 399 show_win(WINDOW *scr, char *message) |
| 391 char *message; | |
| 392 { | 400 { |
| 393 mvwaddstr(scr, 0, 0, message); | 401 mvwaddstr(scr, 0, 0, message); |
| 394 touchwin(scr); | 402 touchwin(scr); |
| 395 wmove(scr, hero.y, hero.x); | 403 wmove(scr, hero.y, hero.x); |
| 396 draw(scr); | 404 draw(scr); |
| 401 | 409 |
| 402 /* | 410 /* |
| 403 * dbotline: | 411 * dbotline: |
| 404 * Displays message on bottom line and waits for a space to return | 412 * Displays message on bottom line and waits for a space to return |
| 405 */ | 413 */ |
| 406 dbotline(scr,message) | 414 void |
| 407 WINDOW *scr; | 415 dbotline(WINDOW *scr, char *message) |
| 408 char *message; | |
| 409 { | 416 { |
| 410 mvwaddstr(scr,LINES-1,0,message); | 417 mvwaddstr(scr,LINES-1,0,message); |
| 411 draw(scr); | 418 draw(scr); |
| 412 wait_for(scr,' '); | 419 wait_for(scr,' '); |
| 413 } | 420 } |
| 415 | 422 |
| 416 /* | 423 /* |
| 417 * restscr: | 424 * restscr: |
| 418 * Restores the screen to the terminal | 425 * Restores the screen to the terminal |
| 419 */ | 426 */ |
| 420 restscr(scr) | 427 void |
| 421 WINDOW *scr; | 428 restscr(WINDOW *scr) |
| 422 { | 429 { |
| 423 clearok(scr,TRUE); | 430 clearok(scr,TRUE); |
| 424 touchwin(scr); | 431 touchwin(scr); |
| 425 } | 432 } |
| 426 | 433 |
| 429 * Read a byte, short, or long machine independently | 436 * Read a byte, short, or long machine independently |
| 430 * Always returns the value as an unsigned long. | 437 * Always returns the value as an unsigned long. |
| 431 */ | 438 */ |
| 432 | 439 |
| 433 unsigned long | 440 unsigned long |
| 434 netread(error, size, stream) | 441 netread(int *error, int size, FILE *stream) |
| 435 int *error; | |
| 436 int size; | |
| 437 FILE *stream; | |
| 438 { | 442 { |
| 439 unsigned long result = 0L, /* What we read in */ | 443 unsigned long result = 0L, /* What we read in */ |
| 440 partial; /* Partial value */ | 444 partial; /* Partial value */ |
| 441 int nextc, /* The next byte */ | 445 int nextc, /* The next byte */ |
| 442 i; /* To index through the result a byte at a time */ | 446 i; /* To index through the result a byte at a time */ |
| 467 | 471 |
| 468 | 472 |
| 469 /* | 473 /* |
| 470 * netwrite: | 474 * netwrite: |
| 471 * Write out a byte, short, or long machine independently. | 475 * Write out a byte, short, or long machine independently. |
| 472 */ | 476 * value: What to write |
| 473 | 477 * size: How much to write out |
| 474 netwrite(value, size, stream) | 478 * stream: Where to write it |
| 475 unsigned long value; /* What to write */ | 479 */ |
| 476 int size; /* How much to write out */ | 480 |
| 477 FILE *stream; /* Where to write it */ | 481 int |
| 482 netwrite(unsigned long value, int size, FILE *stream) | |
| 478 { | 483 { |
| 479 int i; /* Goes through value one byte at a time */ | 484 int i; /* Goes through value one byte at a time */ |
| 480 char outc; /* The next character to be written */ | 485 char outc; /* The next character to be written */ |
| 481 | 486 |
| 482 /* Be sure we have a right sized chunk */ | 487 /* Be sure we have a right sized chunk */ |
