comparison rogue4/main.c @ 225:4f6e056438eb

Merge the GCC5 and build fix branches.
author John "Elwin" Edwards
date Wed, 02 Mar 2016 21:28:34 -0500
parents 1b73a8641b37
children 3d4252fa2ed3
comparison
equal deleted inserted replaced
224:4d0f53998e8a 225:4f6e056438eb
16 #include <stdlib.h> 16 #include <stdlib.h>
17 #include <curses.h> 17 #include <curses.h>
18 #include <signal.h> 18 #include <signal.h>
19 #include <limits.h> 19 #include <limits.h>
20 #include <string.h> 20 #include <string.h>
21 #include <time.h>
21 #include "rogue.h" 22 #include "rogue.h"
22 23
23 /* 24 /*
24 * main: 25 * main:
25 * The main program, of course 26 * The main program, of course
26 */ 27 */
27 main(argc, argv, envp) 28 int
28 char **argv; 29 main(int argc, char *argv[], char *envp[])
29 char **envp;
30 { 30 {
31 register char *env; 31 register char *env;
32 int lowtime; 32 int lowtime;
33 33
34 md_init(); 34 md_init();
111 open_log(); /* do first, open_score might drop needed permissions */ 111 open_log(); /* do first, open_score might drop needed permissions */
112 open_score(); 112 open_score();
113 if (argc == 2 && strcmp(argv[1], "-s") == 0) 113 if (argc == 2 && strcmp(argv[1], "-s") == 0)
114 { 114 {
115 noscore = TRUE; 115 noscore = TRUE;
116 score(0, -1); 116 score(0, -1, 0);
117 exit(0); 117 exit(0);
118 } 118 }
119 init_check(); /* check for legal startup */ 119 init_check(); /* check for legal startup */
120 120
121 if (use_savedir) 121 if (use_savedir)
225 225
226 /* 226 /*
227 * fatal: 227 * fatal:
228 * Exit the program, printing a message. 228 * Exit the program, printing a message.
229 */ 229 */
230 fatal(s) 230 void
231 char *s; 231 fatal(char *s)
232 { 232 {
233 clear(); 233 clear();
234 move(LINES-2, 0); 234 move(LINES-2, 0);
235 printw("%s", s); 235 printw("%s", s);
236 refresh(); 236 refresh();
240 240
241 /* 241 /*
242 * rnd: 242 * rnd:
243 * Pick a very random number. 243 * Pick a very random number.
244 */ 244 */
245 rnd(range) 245 int
246 register int range; 246 rnd(int range)
247 { 247 {
248 return range == 0 ? 0 : abs((int) RN) % range; 248 return range == 0 ? 0 : abs((int) RN) % range;
249 } 249 }
250 250
251 /* 251 /*
252 * roll: 252 * roll:
253 * Roll a number of dice 253 * Roll a number of dice
254 */ 254 */
255 roll(number, sides) 255 int
256 register int number, sides; 256 roll(int number, int sides)
257 { 257 {
258 register int dtotal = 0; 258 register int dtotal = 0;
259 259
260 while (number--) 260 while (number--)
261 dtotal += rnd(sides)+1; 261 dtotal += rnd(sides)+1;
297 /* 297 /*
298 * playit: 298 * playit:
299 * The main loop of the program. Loop until the game is over, 299 * The main loop of the program. Loop until the game is over,
300 * refreshing things and looking at the proper times. 300 * refreshing things and looking at the proper times.
301 */ 301 */
302 playit() 302 void
303 playit(void)
303 { 304 {
304 register char *opts; 305 register char *opts;
305 306
306 /* 307 /*
307 * set up defaults for slow terminals 308 * set up defaults for slow terminals
350 clear(); 351 clear();
351 mvprintw(LINES - 2, 0, "You quit with %d gold pieces", purse); 352 mvprintw(LINES - 2, 0, "You quit with %d gold pieces", purse);
352 move(LINES - 1, 0); 353 move(LINES - 1, 0);
353 refresh(); 354 refresh();
354 writelog(purse, 1, 0); 355 writelog(purse, 1, 0);
355 score(purse, 1); 356 score(purse, 1, 0);
356 printf("[Press return to exit]\n"); 357 printf("[Press return to exit]\n");
357 fflush(NULL); 358 fflush(NULL);
358 getchar(); 359 getchar();
359 exit(0); 360 exit(0);
360 } 361 }
389 390
390 /* 391 /*
391 * shell: 392 * shell:
392 * Let him escape for a while 393 * Let him escape for a while
393 */ 394 */
394 shell() 395 void
396 shell(void)
395 { 397 {
396 /* 398 /*
397 * Set the terminal back to original mode 399 * Set the terminal back to original mode
398 */ 400 */
399 move(LINES-1, 0); 401 move(LINES-1, 0);