comparison src/yadex.cc @ 83:002bc70a3982

More cleanups. Mostly variable renames.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 26 Sep 2011 18:06:30 +0300
parents 154714f3ab2e
children c518e08d5961
comparison
equal deleted inserted replaced
82:154714f3ab2e 83:002bc70a3982
83 Wad_res wad_res(&cfg.MasterDir); 83 Wad_res wad_res(&cfg.MasterDir);
84 YadexConfig cfg; 84 YadexConfig cfg;
85 85
86 void InitializeConfig() 86 void InitializeConfig()
87 { 87 {
88 memset(cfg, 0, sizeof(cfg)); 88 memset(&cfg, 0, sizeof(cfg));
89 89
90 cfg.install_dir = NULL, // Where Yadex is installed 90 cfg.install_dir = NULL, // Where Yadex is installed
91 cfg.logfile = NULL, // Filepointer to the error log 91 cfg.logfile = NULL, // Filepointer to the error log
92 cfg.Registered = false, // Registered or shareware game? 92 cfg.registered = false, // Registered or shareware game?
93 cfg.screen_lines = 24, // Lines that our TTY can display 93 cfg.screen_lines = 24, // Lines that our TTY can display
94 cfg.remind_to_build_nodes = false, // Remind user to build nodes 94 cfg.remind_to_build_nodes = false, // Remind user to build nodes
95 cfg.config_file = NULL; 95 cfg.config_file = NULL;
96 cfg.Debug = false; 96 cfg.debug = false;
97 97
98 // Set from command line and/or config file 98 // Set from command line and/or config file
99 cfg.autoscroll = false; 99 cfg.autoscroll = false;
100 cfg.autoscroll_amp = 10; 100 cfg.autoscroll_amp = 10;
101 cfg.autoscroll_edge = 30; 101 cfg.autoscroll_edge = 30;
110 strcpy(cfg.def.lower_texture, "STARTAN3"); 110 strcpy(cfg.def.lower_texture, "STARTAN3");
111 strcpy(cfg.def.middle_texture, "STARTAN3"); 111 strcpy(cfg.def.middle_texture, "STARTAN3");
112 strcpy(cfg.def.upper_texture, "STARTAN3"); 112 strcpy(cfg.def.upper_texture, "STARTAN3");
113 cfg.def.thing = 3004; 113 cfg.def.thing = 3004;
114 cfg.double_click_timeout = 200; 114 cfg.double_click_timeout = 200;
115 cfg.Expert = false; 115 cfg.expert = false;
116 cfg.Game = NULL; 116 cfg.Game = NULL;
117 117
118 cfg.PatchWads = NULL; 118 cfg.patchwads = NULL;
119 cfg.Quiet = false; 119 cfg.quiet = false;
120 cfg.Quieter = false; 120 cfg.quieter = false;
121 cfg.scroll_less = 10; 121 cfg.scroll_less = 10;
122 cfg.scroll_more = 90; 122 cfg.scroll_more = 90;
123 cfg.Select0 = false; 123 cfg.autoselect0 = false;
124 cfg.show_help = false; 124 cfg.show_help = false;
125 cfg.sprite_scale = 100; 125 cfg.sprite_scale = 100;
126 cfg.SwapButtons = false; 126 cfg.swap_buttons = false;
127 cfg.verbose = 0; 127 cfg.verbose = 0;
128 cfg.welcome_message = 1; 128 cfg.welcome_message = 1;
129 cfg.bench = NULL; 129 cfg.bench = NULL;
130 130
131 memset(cfg.Iwad, 0, sizeof(cfg.Iwad)); 131 memset(cfg.iwadnames, 0, sizeof(cfg.iwadnames));
132 cfg.MainWad = NULL; 132 cfg.MainWad = NULL;
133 133
134 134
135 cfg.grid_pixels_min = 10; 135 cfg.grid_pixels_min = 10;
136 cfg.GridMin = 2; 136 cfg.GridMin = 2;
270 for (n = 0; n < IWAD_LAST; n++) 270 for (n = 0; n < IWAD_LAST; n++)
271 { 271 {
272 GameInfo *info = &gameList[n]; 272 GameInfo *info = &gameList[n];
273 if (strcmp(cfg.Game, info->game) == 0) 273 if (strcmp(cfg.Game, info->game) == 0)
274 { 274 {
275 if (cfg.Iwad[n] == NULL) 275 if (cfg.iwadnames[n] == NULL)
276 { 276 {
277 err("You have to tell me where %s is.", info->wadname); 277 err("You have to tell me where %s is.", info->wadname);
278 fprintf(stderr, 278 fprintf(stderr,
279 "Use \"-i%d <file>\" or put \"iwad%d=<file>\" in yadex.cfg\n", 279 "Use \"-i%d <file>\" or put \"iwad%d=<file>\" in yadex.cfg\n",
280 n + 1, n + 1); 280 n + 1, n + 1);
281 exit(1); 281 exit(1);
282 } 282 }
283 cfg.MainWad = cfg.Iwad[n]; 283 cfg.MainWad = cfg.iwadnames[n];
284 } 284 }
285 } 285 }
286 } 286 }
287 287
288 if (cfg.MainWad == NULL) 288 if (cfg.MainWad == NULL)
303 } 303 }
304 fprintf(stderr, ".\n"); 304 fprintf(stderr, ".\n");
305 exit(1); 305 exit(1);
306 } 306 }
307 307
308 if (cfg.Debug) 308 if (cfg.debug)
309 { 309 {
310 cfg.logfile = fopen(yadex_log_filename, "a"); 310 cfg.logfile = fopen(yadex_log_filename, "a");
311 if (cfg.logfile == NULL) 311 if (cfg.logfile == NULL)
312 { 312 {
313 warn("Can't open log file \"%s\" (%s)", yadex_log_filename, 313 warn("Can't open log file \"%s\" (%s)", yadex_log_filename,
316 316
317 LogMessage(": Main IWAD = '%s'\n", cfg.MainWad); 317 LogMessage(": Main IWAD = '%s'\n", cfg.MainWad);
318 LogMessage(": Welcome to Yadex!\n"); 318 LogMessage(": Welcome to Yadex!\n");
319 } 319 }
320 320
321 if (cfg.Quieter) 321 if (cfg.quieter)
322 cfg.Quiet = true; 322 cfg.quiet = true;
323 323
324 // Sanity checks (useful when porting). 324 // Sanity checks (useful when porting).
325 check_types(); 325 check_types();
326 check_charset(); 326 check_charset();
327 327
335 335
336 // Load the iwad and the pwads. 336 // Load the iwad and the pwads.
337 if (OpenMainWad(cfg.MainWad)) 337 if (OpenMainWad(cfg.MainWad))
338 fatal_error("If you don't give me an iwad, I'll quit. I'm serious."); 338 fatal_error("If you don't give me an iwad, I'll quit. I'm serious.");
339 339
340 if (cfg.PatchWads) 340 if (cfg.patchwads)
341 { 341 {
342 const char *const *pwad_name; 342 const char *const *pwad_name;
343 for (pwad_name = cfg.PatchWads; *pwad_name; pwad_name++) 343 for (pwad_name = cfg.patchwads; *pwad_name; pwad_name++)
344 OpenPatchWad(*pwad_name); 344 OpenPatchWad(*pwad_name);
345 } 345 }
346 346
347 /* sanity check */ 347 /* sanity check */
348 CloseUnusedWadFiles(); 348 CloseUnusedWadFiles();
433 fputs("Error: ", stderr); 433 fputs("Error: ", stderr);
434 vfprintf(stderr, fmt, args); 434 vfprintf(stderr, fmt, args);
435 fputc('\n', stderr); 435 fputc('\n', stderr);
436 fflush(stderr); 436 fflush(stderr);
437 437
438 if (cfg.Debug && cfg.logfile != NULL) 438 if (cfg.debug && cfg.logfile != NULL)
439 { 439 {
440 fputs("Error: ", cfg.logfile); 440 fputs("Error: ", cfg.logfile);
441 vfprintf(cfg.logfile, fmt, args); 441 vfprintf(cfg.logfile, fmt, args);
442 fputc('\n', cfg.logfile); 442 fputc('\n', cfg.logfile);
443 fflush(cfg.logfile); 443 fflush(cfg.logfile);
541 { 541 {
542 va_list args; 542 va_list args;
543 time_t tval; 543 time_t tval;
544 char *tstr; 544 char *tstr;
545 545
546 if (cfg.Debug && cfg.logfile != NULL) 546 if (cfg.debug && cfg.logfile != NULL)
547 { 547 {
548 va_start(args, logstr); 548 va_start(args, logstr);
549 /* if the message begins with ":", output the current date & time first */ 549 /* if the message begins with ":", output the current date & time first */
550 if (logstr[0] == ':') 550 if (logstr[0] == ':')
551 { 551 {
674 } 674 }
675 675
676 /* user asked to quit */ 676 /* user asked to quit */
677 else if (!strcmp(com, "quit") || !strcmp(com, "q")) 677 else if (!strcmp(com, "quit") || !strcmp(com, "q"))
678 { 678 {
679 if (!cfg.Registered) 679 if (!cfg.registered)
680 printf("Remember to register your copy of the game !\n"); 680 printf("Remember to register your copy of the game !\n");
681 break; 681 break;
682 } 682 }
683 683
684 /* user asked to edit a level */ 684 /* user asked to edit a level */
712 if ((tolower(*com) == 'e' && yg_level_name == YGLN_MAP01) || 712 if ((tolower(*com) == 'e' && yg_level_name == YGLN_MAP01) ||
713 (tolower(*com) == 'm' && yg_level_name == YGLN_E1M1)) 713 (tolower(*com) == 'm' && yg_level_name == YGLN_E1M1))
714 printf(" You are in %s mode.", cfg.Game); 714 printf(" You are in %s mode.", cfg.Game);
715 else 715 else
716 716
717 if (tolower(*com) == 'e' && com[1] > '1' && !cfg.Registered) 717 if (tolower(*com) == 'e' && com[1] > '1' && !cfg.registered)
718 printf(" You have the shareware IWAD."); 718 printf(" You have the shareware IWAD.");
719 719
720 printf("\n"); 720 printf("\n");
721 continue; 721 continue;
722 } 722 }