Main Page | Data Structures | Directories | File List | Data Fields | Globals

main.c

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------- *
00002  * main.c
00003  * This file is part of lincity.
00004  * Lincity is copyright (c) I J Peters 1995-1997, (c) Greg Sharp 1997-2001.
00005  * ---------------------------------------------------------------------- */
00006 #include "lcconfig.h"
00007 #include <stdio.h>
00008 #include <stdlib.h>
00009 #include <signal.h>
00010 #include "lcstring.h"
00011 #include "cliglobs.h"
00012 #include "lchelp.h"
00013 #include "dialbox.h"
00014 
00015 /* this is for OS/2 - RVI */
00016 #ifdef __EMX__
00017 #include <sys/select.h>
00018 #include <X11/Xlibint.h>      /* required for __XOS2RedirRoot */
00019 #define chown(x,y,z)
00020 /* #define OS2_DEFAULT_LIBDIR "/XFree86/lib/X11/lincity" */
00021 /* This was moved to fileutil.c */
00022 #endif
00023 
00024 #include <sys/types.h>
00025 #include <fcntl.h>
00026 
00027 #if defined (WIN32)
00028 #include <winsock.h>
00029 #include <io.h>
00030 #include <direct.h>
00031 #include <process.h>
00032 #endif
00033 
00034 #include <time.h>
00035 
00036 #include <ctype.h>
00037 #include "common.h"
00038 #ifdef LC_X11
00039 #include <X11/cursorfont.h>
00040 #endif
00041 
00042 #include "lctypes.h"
00043 #include "lin-city.h"
00044 #include "cliglobs.h"
00045 #include "engglobs.h"
00046 #include "timer.h"
00047 #include "ldsvgui.h"
00048 #include "simulate.h"
00049 #include "mouse.h"
00050 #include "pixmap.h"
00051 #include "screen.h"
00052 #include "lcintl.h"
00053 #include "engine.h"
00054 #include "module_buttons.h"
00055 #include "fileutil.h"
00056 
00057 #if defined (WIN32) && !defined (NDEBUG)
00058 #define START_FAST_SPEED 1
00059 //#define SKIP_OPENING_SCENE 1
00060 #endif
00061 
00062 #define SI_BLACK 252
00063 #define SI_RED 253
00064 #define SI_GREEN 254
00065 #define SI_YELLOW 255
00066 
00067 #define DEBUG_KEYS 1
00068 
00069 /* ---------------------------------------------------------------------- *
00070  * Private Fn Prototypes
00071  * ---------------------------------------------------------------------- */
00072 void dump_screen (void);
00073 void verify_package (void);
00074 char* current_month (int current_time);
00075 int current_year (int current_time);
00076 void process_keystrokes (int key);
00077 int execute_timestep (void);
00078 
00079 /* ---------------------------------------------------------------------- *
00080  * Private Global Variables
00081  * ---------------------------------------------------------------------- */
00082 #if defined (commentout)          /* Moved to fileutil.c */
00083 #if defined (WIN32)
00084 char LIBDIR[_MAX_PATH];
00085 #elif defined (__EMX__)
00086 #ifdef LIBDIR
00087 #undef LIBDIR   /* yes, I know I shouldn't ;-) */
00088 #endif
00089 /* GCS: Presumably I can do this, right? */
00090 #if defined (commentout)
00091 char LIBDIR[256];
00092 #endif
00093 char LIBDIR[LC_PATH_MAX];
00094 #endif
00095 #endif
00096 
00097 char *lc_save_dir;
00098 char *lc_temp_file;
00099 char save_names[10][42];
00100 
00101 #ifdef CS_PROFILE
00102 int prof_countdown = PROFILE_COUNTDOWN;
00103 #endif
00104 
00105 
00106 /* ---------------------------------------------------------------------- *
00107  * Public Functions
00108  * ---------------------------------------------------------------------- */
00109 #if !defined (WIN32)
00110 int
00111 main (int argc, char *argv[])
00112 {
00113     return lincity_main (argc, argv);
00114 }
00115 #endif
00116 
00117 void
00118 lincity_set_locale (void)
00119 {
00120     char* locale = NULL;
00121     char* localem = NULL;
00122 #if defined (WIN32)
00123 #define MAX_LANG_BUF 1024
00124     char* language = NULL;
00125     char language_buf[MAX_LANG_BUF];
00126 #endif
00127 
00128 #if defined (ENABLE_NLS)
00129 #if defined (WIN32)
00130     /* Some special stoopid way of setting locale for microsoft gettext */
00131     language = getenv ("LANGUAGE");
00132     if (language) {
00133         debug_printf ("Environment variable LANGUAGE is %s\n", language);
00134         snprintf (language_buf, MAX_LANG_BUF, "LANGUAGE=%s", language);
00135         gettext_putenv(language_buf);
00136     } else {
00137         debug_printf ("Environment variable LANGUAGE not set.\n");
00138     }
00139 #else
00140     locale = setlocale (LC_ALL, "");
00141     debug_printf ("Setting entire locale to %s\n", locale);
00142     locale = setlocale (LC_MESSAGES, "");
00143     debug_printf ("Setting messages locale to %s\n", locale);
00144     localem = setlocale (LC_MESSAGES, NULL);
00145     debug_printf ("Query locale is %s\n", localem);
00146 #endif
00147 #endif /* ENABLE_NLS */
00148     return;
00149 }
00150 
00151 int
00152 lincity_main (int argc, char *argv[])
00153 {
00154 #if defined (LC_X11)
00155     char *geometry = NULL;
00156 #endif
00157 
00158 #if defined (SVGALIB)
00159     int q;
00160     vga_init ();
00161 #endif
00162 
00163 #if !defined (WIN32)
00164     signal (SIGPIPE, SIG_IGN);    /* broken pipes are ignored. */
00165 #endif
00166 
00167     /* Initialize some global variables */
00168     //make_dir_ok_flag = 1;
00169     main_screen_originx = 1;
00170     main_screen_originy = 1;
00171     given_scene[0] = 0;
00172     quit_flag = network_flag = load_flag = save_flag 
00173             = prefs_flag = cheat_flag = monument_bul_flag
00174             = river_bul_flag = shanty_bul_flag;
00175     prefs_drawn_flag = 0;
00176     kmouse_val = 8;
00177 
00178 #ifdef LC_X11
00179     borderx = 0;
00180     bordery = 0;
00181     parse_xargs (argc, argv, &geometry);
00182 #endif
00183 
00184     /* I18n */
00185     lincity_set_locale ();
00186 
00187     /* Set up the paths to certain files and directories */
00188     init_path_strings ();
00189 
00190     /* Make sure that things are installed where they should be */
00191     verify_package ();
00192 
00193     /* Make sure the save directory exists */
00194     check_savedir ();
00195 
00196     /* Load preferences */
00197     load_lincityrc ();
00198 
00199 #ifndef CS_PROFILE
00200 #ifdef SEED_RAND
00201     srand (time (0));
00202 #endif
00203 #endif
00204 
00205 #ifdef LC_X11
00206 #if defined (commentout)
00207     borderx = 0;
00208     bordery = 0;
00209     parse_xargs (argc, argv, &geometry);
00210 #endif
00211     Create_Window (geometry);
00212     pirate_cursor = XCreateFontCursor (display.dpy, XC_pirate);
00213 #elif defined (WIN32)
00214     /* Deal with all outstanding messages */
00215     ProcessPendingEvents ();
00216 #else
00217     parse_args (argc, argv);
00218     q = vga_setmode (G640x480x256);
00219     gl_setcontextvga (G640x480x256);
00220 #endif
00221 
00222 #if defined (WIN32) || defined (LC_X11)
00223     initialize_pixmap ();
00224 #endif
00225 
00226     init_fonts ();
00227 
00228 #if defined (SKIP_OPENING_SCENE)
00229     skip_splash_screen = 1;
00230 #endif
00231     if (!skip_splash_screen) {
00232         load_start_image ();
00233     }
00234 
00235 #ifdef LC_X11
00236     unlock_window_size ();
00237 #endif
00238 
00239     Fgl_setfont (8, 8, main_font);
00240     Fgl_setfontcolors (TEXT_BG_COLOUR, TEXT_FG_COLOUR);
00241 
00242     initialize_geometry (&scr);
00243 
00244 #if defined (SVGALIB)
00245     set_vga_mode ();
00246 #endif
00247 
00248     initialize_monthgraph ();
00249     init_mouse_registry ();
00250     init_mini_map_mouse ();
00251 
00252 #ifdef LC_X11
00253     x_key_value = 0;
00254 #elif defined (WIN32)
00255     RefreshScreen ();
00256 #endif
00257     setcustompalette ();
00258     draw_background ();
00259     prog_box (_("Loading the game"), 1);
00260     init_types ();
00261     init_modules();
00262     init_mappoint_array ();
00263     initialize_tax_rates ();
00264     prog_box ("", 95);
00265     mouse_hide_count = 0;
00266     suppress_ok_buttons = 0;
00267     prog_box ("", 100);
00268 #ifdef USE_PIXMAPS
00269     prog_box (_("Creating pixmaps"), 1);
00270     init_pixmaps ();
00271     prog_box ("", 100);
00272 #endif
00273     //draw_normal_mouse (1, 1);
00274 #if defined (LC_X11)
00275     init_x_mouse ();
00276 #endif
00277     init_timer_buttons();
00278     mouse_initialized = 1;
00279     //set_selected_module (CST_TRACK_LR);
00280     screen_setup ();
00281 
00282     /* Main loop! */
00283     client_main_loop ();
00284 
00285 #if defined (SVGALIB)
00286     mouse_close ();
00287     vga_setmode (TEXT);
00288 #endif
00289 
00290     print_results ();
00291 
00292 #if defined (WIN32) || defined (LC_X11)
00293     free_pixmap ();
00294 #endif
00295 
00296 #if defined (WIN32)
00297     return 0;
00298 #else
00299     exit (0);
00300 #endif
00301 }
00302 
00303 void
00304 client_main_loop (void)
00305 {
00306     int quit = 0;
00307     int engine_updated = 0;
00308 
00309     /* Set up the game */
00310     reset_start_time ();
00311 
00312     update_avail_modules (0);
00313 
00314     screen_full_refresh ();
00315 
00316     if (no_init_help == 0) {
00317         block_help_exit = 1;
00318         help_flag = 1;
00319 #if defined (commentout)
00320         if (make_dir_ok_flag) {
00321             activate_help ("ask-dir.hlp");
00322             make_dir_ok_flag = 0;
00323         } else {
00324             activate_help ("opening.hlp");
00325         }
00326 #endif
00327         activate_help ("opening.hlp");
00328     }
00329 
00330     /* Set speed */
00331 #if defined (CS_PROFILE) || defined (START_FAST_SPEED)
00332     select_fast ();
00333 #else
00334     select_medium ();
00335 #endif
00336     /* Main Loop */
00337     do {
00338         int key;
00339 
00340         /* Get timestamp for this iteration */
00341         get_real_time();
00342 
00343         /* Process events */
00344 #if defined (LC_X11)
00345         call_event ();
00346         key = x_key_value;
00347         x_key_value = 0;
00348 #elif defined (WIN32)
00349         call_event ();
00350         key = GetKeystroke ();
00351 #else
00352         mouse_update ();
00353         key = vga_getkey ();
00354 #endif
00355         /* nothing happened if key == 0 XXX: right? */
00356         /* GCS: I'm not sure */
00357         if (key != 0) {
00358             process_keystrokes (key);
00359         }
00360         /* Simulate the timestep */
00361         quit = execute_timestep ();
00362     } while (quit == 0);
00363 }
00364 
00365 void
00366 process_keystrokes (int key)
00367 {
00368 
00369 #if defined (commentout)        /* KBR 10/14/2002 - Cleanup MSVC warning */
00370     int retval;
00371 #endif
00372 
00373     switch (key)
00374     {
00375     case 0: printf("dead!"); return;
00376     case ' ':   /* Space */
00377     case 10:    /* Linefeed/Return */
00378     case 13:    /* Enter */
00379     case 127:   /* Backspace */
00380         if (key == 127) {
00381             cs_mouse_handler (LC_MOUSE_RIGHTBUTTON | LC_MOUSE_PRESS,
00382                               0, 0);
00383             cs_mouse_handler (LC_MOUSE_RIGHTBUTTON | LC_MOUSE_RELEASE,
00384                               0, 0);
00385         } else {
00386             cs_mouse_handler (LC_MOUSE_LEFTBUTTON | LC_MOUSE_PRESS,
00387                               0, 0);
00388             cs_mouse_handler (LC_MOUSE_LEFTBUTTON | LC_MOUSE_RELEASE,
00389                               0, 0);
00390         }
00391         if (help_flag) {
00392             draw_help_page ("return-2");
00393         }
00394         if (prefs_flag) {
00395             close_prefs_screen ();
00396             refresh_main_screen ();
00397         }
00398         break;
00399 
00400 #if defined (SVGALIB)
00401     case 91:
00402         {
00403             int w = vga_getkey ();
00404             switch (w)
00405             {
00406             case ('A'):
00407                 cs_mouse_handler (0, 0, -kmouse_val);
00408                 break;
00409             case ('B'):
00410                 cs_mouse_handler (0, 0, kmouse_val);
00411                 break;
00412             case ('C'):
00413                 cs_mouse_handler (0, kmouse_val, 0);
00414                 break;
00415             case ('D'):
00416                 cs_mouse_handler (0, -kmouse_val, 0);
00417                 break;
00418             }
00419         }
00420         break;
00421 #endif
00422 
00423 #if defined (WIN32) || defined (LC_X11)
00424     case 1:
00425         /* Scroll left */
00426         if (x_key_shifted) {
00427             adjust_main_origin (main_screen_originx - RIGHT_MOUSE_MOVE_VAL,
00428                                 main_screen_originy,
00429                                 TRUE);
00430         } else {
00431             adjust_main_origin (main_screen_originx - 1,
00432                                 main_screen_originy,
00433                                 TRUE);
00434         }
00435         break;
00436 
00437     case 2:
00438         /* Scroll down */
00439         if (x_key_shifted) {
00440             adjust_main_origin (main_screen_originx,
00441                                 main_screen_originy + RIGHT_MOUSE_MOVE_VAL,
00442                                 TRUE);
00443         } else {
00444             adjust_main_origin (main_screen_originx,
00445                                 main_screen_originy + 1,
00446                                 TRUE);
00447         }
00448         break;
00449 
00450     case 3:
00451         /* Scroll up */
00452         if (x_key_shifted) {
00453             adjust_main_origin (main_screen_originx,
00454                                 main_screen_originy - RIGHT_MOUSE_MOVE_VAL,
00455                                 TRUE);
00456         } else {
00457             adjust_main_origin (main_screen_originx,
00458                                 main_screen_originy - 1,
00459                                 TRUE);
00460         }
00461         break;
00462 
00463     case 4:
00464         /* Scroll right */
00465         if (x_key_shifted) {
00466             adjust_main_origin (main_screen_originx + RIGHT_MOUSE_MOVE_VAL,
00467                                 main_screen_originy,
00468                                 TRUE);
00469         } else {
00470             adjust_main_origin (main_screen_originx + 1,
00471                                 main_screen_originy,
00472                                 TRUE);
00473         }
00474         break;
00475 #endif
00476 
00477     case 'P':
00478     case 'p':
00479         select_pause ();
00480         break;
00481 
00482 #ifdef DEBUG_KEYS
00483     case 'e':
00484         if (cheat () != 0)
00485             people_pool += 100;
00486         break;
00487 
00488     case 'd':
00489         if (cheat () != 0)
00490             dump_screen ();
00491         break;
00492           
00493     case 'D':
00494         /*      dump_tcore (); */
00495         break;
00496 
00497     case 't':
00498         if (cheat () != 0)
00499             tech_level += 1000;
00500         break;
00501 
00502     case 'T':
00503         if (cheat () != 0)
00504             tech_level += 10000;
00505         break;
00506 
00507     case 'm':
00508         if (cheat () != 0) 
00509             adjust_money(1000000);
00510         break;
00511 #endif
00512 
00513     case 'f':
00514         do_random_fire (-1, -1, 1);
00515         break;
00516 
00517     case 'L':
00518     case 'l':
00519         load_flag = 1;
00520         break;
00521 
00522     case 'H':
00523     case 'h':
00524         activate_help ("index.hlp");
00525         break;
00526 
00527         /* Escape Key */
00528 #ifdef LC_X11
00529     case 27:
00530 #else
00531     case 5:
00532 #endif
00533         if (help_flag) {
00534             /* exit help */
00535             draw_help_page("return-2"); 
00536         } else if (prefs_flag) {
00537             close_prefs_screen();
00538             refresh_main_screen ();
00539         } else {
00540             activate_help ("menu.hlp");
00541         }
00542         break;
00543 
00544     case 'S':
00545     case 's':
00546         save_flag = 1;
00547         break;
00548 
00549     case 'v':
00550     case 'V':
00551         /* Toggle overlay */
00552         rotate_main_screen();
00553         break;
00554 
00555     case 'o':
00556     case 'O':
00557         prefs_flag = 1;
00558         break;
00559 
00560     case 'r':
00561         window_results();
00562         break;
00563 
00564     case 'q':
00565     case 'Q':
00566         quit_flag = 1;
00567         break;
00568 
00569     } /* end switch on keystroke */
00570 }
00571 
00572 /* The "guts" of main loop is here. */
00573 int 
00574 execute_timestep (void)
00575 {
00576     static int next_time_step = 0;
00577     int engine_updated = 0;
00578     int real_quit_flag = 0;
00579 
00580     if (market_cb_flag == 0 && help_flag == 0 
00581         && port_cb_flag == 0 && prefs_flag == 0)
00582     {
00583 
00584         if ((real_time < next_time_step || pause_flag || mt_flag)
00585             && save_flag == 0 && load_flag == 0)
00586         {
00587             if ((let_one_through == 0) || mt_flag)
00588             {
00589                 lc_usleep (1);
00590                 return 0;
00591             }
00592             else
00593                 let_one_through = 0;
00594         }
00595 
00596         if (slow_flag)
00597             next_time_step = real_time + (SLOW_TIME_FOR_YEAR
00598                                           * 1000 / NUMOF_DAYS_IN_YEAR);
00599         else if (fast_flag)
00600             next_time_step = real_time + (FAST_TIME_FOR_YEAR
00601                                           * 1000 / NUMOF_DAYS_IN_YEAR);
00602         else if (med_flag)
00603             next_time_step = real_time + (MED_TIME_FOR_YEAR
00604                                           * 1000 / NUMOF_DAYS_IN_YEAR);
00605 
00606         do_time_step ();
00607 
00608 #ifdef CS_PROFILE
00609         if (--prof_countdown <= 0)
00610             real_quit_flag = 1;
00611 #endif
00612 
00613         update_main_screen (0);
00614 
00615         /* XXX: Shouldn't the rest be handled in update_main_screen()? */
00616         /* GCS: No, I don't think so.  These remaining items are 
00617                 outside of the main screen */
00618 
00619         print_stats ();
00620 
00621         if (market_cb_flag)
00622             draw_market_cb ();
00623         else if (port_cb_flag)  /* else- can't have both */
00624             draw_port_cb ();
00625     }
00626     else /* if game is "stalled" */
00627     {
00628         if (market_cb_flag != 0 && market_cb_drawn_flag == 0)
00629             draw_market_cb ();
00630         if (port_cb_flag != 0 && port_cb_drawn_flag == 0)
00631             draw_port_cb ();
00632 #if defined (SVGALIB)
00633         mouse_update ();
00634 #endif
00635     }
00636 
00637 #if defined (NETWORK_ENABLE)
00638     if (network_flag != 0) {
00639         do_network_screen ();
00640         network_flag = 0;
00641         let_one_through = 1;    /* if we are paused we need */
00642     }                           /* this to redraw the screen */
00643 #endif
00644 
00645     if (prefs_flag != 0 && prefs_drawn_flag == 0) {
00646         do_prefs_screen ();
00647         let_one_through = 1;    /* if we are paused we need */
00648     }                           /* this to redraw the screen */
00649 
00650     if (load_flag != 0) {
00651 #if defined (WIN32)
00652         DisableWindowsMenuItems ();
00653 #endif
00654         if (help_flag == 0)     /* block loading when in help */
00655             do_load_city ();
00656         load_flag = 0;
00657         let_one_through = 1;    /* if we are paused we need */
00658     }                           /* this to redraw the screen */
00659 
00660     else if (save_flag != 0) {
00661 #if defined (WIN32)
00662         DisableWindowsMenuItems ();
00663 #endif
00664         if (help_flag == 0)
00665             do_save_city ();
00666         save_flag = 0;
00667         let_one_through = 1;
00668     }
00669 
00670     else if (quit_flag != 0) {
00671 #if defined (WIN32)
00672         DisableWindowsMenuItems ();
00673 #endif
00674         if (yn_dial_box (_("Quit The Game?")
00675                          ,_("Do you really want to quit?")
00676                          ,_("If you want to save the game select NO.")
00677                          ,""     /* GCS: This can't be translated!. */
00678                          ) != 0)
00679             real_quit_flag = 1;
00680         else
00681             quit_flag = 0;
00682     }
00683 
00684     if (help_flag != 0)
00685         lc_usleep (1);
00686 
00687 #if defined (commentout)
00688     if (make_dir_ok_flag)
00689         make_savedir ();        /* sorry a bit crude :( */
00690 #endif
00691     return real_quit_flag;
00692 }
00693 
00694 void
00695 do_error (char *s)
00696 {
00697 #if defined (LC_X11) || defined (WIN32)
00698     HandleError (s, FATAL);
00699 #else
00700     vga_setmode (TEXT);
00701     printf ("%s\n", s);
00702     exit (1);
00703 #endif
00704 }
00705 
00706 int
00707 cheat (void)
00708 {
00709     if (cheat_flag != 0)
00710         return (1);
00711     /* TRANSLATORS: Test mode is like using "cheat codes" */
00712     if (yn_dial_box (_("TEST"), _("You have pressed a test key"),
00713                      _("You will only see this message once"),
00714                      _("Do you really want to play in test mode..."))!= 0)
00715     {
00716         cheat_flag = 1;
00717         print_time_for_year(); /* Displays TEST MODE or not */
00718         return (1);
00719     }
00720     return (0);
00721 }
00722 
00723 int
00724 compile_results (void)
00725 {
00726     char *s;
00727     FILE *outf;
00728     int group_count[NUM_OF_GROUPS];
00729 
00730     if ((s = (char *) malloc (lc_save_dir_len + strlen (LC_SAVE_DIR)
00731                               + strlen (RESULTS_FILENAME) + 64)) == 0)
00732         malloc_failure ();
00733 
00734     sprintf (s, "%s%c%s", lc_save_dir, PATH_SLASH, RESULTS_FILENAME);
00735 
00736     count_all_groups (group_count);
00737     if ((outf = fopen (s, "w")) == 0)
00738     {
00739         printf (_("Unable to open %s\n"), RESULTS_FILENAME);
00740         free (s);
00741         return (0);
00742     }
00743     if (cheat_flag)
00744         fprintf (outf, _("----- IN TEST MODE -------\n"));
00745     fprintf (outf, _("Game statistics from LinCity Version %s\n"), VERSION);
00746     if (strlen (given_scene) > 3)
00747         fprintf (outf, _("Initial loaded scene - %s\n"), given_scene);
00748     if (sustain_flag)
00749         fprintf (outf, _("Economy is sustainable\n"));
00750     fprintf (outf, _("Population  %d  of which  %d  are not housed.\n")
00751              ,housed_population + people_pool, people_pool);
00752     fprintf (outf,
00753              _("Max population %d  Number evacuated %d Total births %d\n")
00754              ,max_pop_ever, total_evacuated, total_births);
00755     fprintf (outf,
00756              _(" Date  %s %04d   Money %8d   Tech-level %5.1f (%5.1f)\n"),
00757              current_month(total_time), current_year(total_time), total_money,
00758              (float) tech_level * 100.0 / MAX_TECH_LEVEL,
00759              (float) highest_tech_level * 100.0 / MAX_TECH_LEVEL);
00760     fprintf (outf,
00761              _(" Deaths by starvation %7d   History %8.3f\n"),
00762              total_starve_deaths, starve_deaths_history);
00763     fprintf (outf,
00764              _("Deaths from pollution %7d   History %8.3f\n"),
00765              total_pollution_deaths, pollution_deaths_history);
00766     fprintf (outf, _("Years of unemployment %7d   History %8.3f\n"),
00767              total_unemployed_years, unemployed_history);
00768     fprintf (outf, _("Rockets launched %2d  Successful launches %2d\n"),
00769              rockets_launched, rockets_launched_success);
00770     fprintf (outf, "\n");
00771     fprintf (outf, _("    Residences %4d         Markets %4d            Farms %4d\n"),
00772              group_count[GROUP_RESIDENCE_LL] + 
00773              group_count[GROUP_RESIDENCE_ML] + 
00774              group_count[GROUP_RESIDENCE_HL] + 
00775              group_count[GROUP_RESIDENCE_LH] + 
00776              group_count[GROUP_RESIDENCE_MH] + 
00777              group_count[GROUP_RESIDENCE_HH],
00778              group_count[GROUP_MARKET],
00779              group_count[GROUP_ORGANIC_FARM]);
00780     fprintf (outf, _("        Tracks %4d           Roads %4d             Rail %4d\n")
00781              ,group_count[GROUP_TRACK], group_count[GROUP_ROAD]
00782              ,group_count[GROUP_RAIL]);
00783     fprintf (outf, _("     Potteries %4d     Blacksmiths %4d            Mills %4d\n")
00784              ,group_count[GROUP_POTTERY], group_count[GROUP_BLACKSMITH]
00785              ,group_count[GROUP_MILL]);
00786     fprintf (outf, _("     Monuments %4d         Schools %4d     Universities %4d\n")
00787              ,group_count[GROUP_MONUMENT], group_count[GROUP_SCHOOL]
00788              ,group_count[GROUP_UNIVERSITY]);
00789     fprintf (outf, _(" Fire stations %4d           Parks %4d     Cricket gnds %4d\n")
00790              ,group_count[GROUP_FIRESTATION], group_count[GROUP_PARKLAND]
00791              ,group_count[GROUP_CRICKET]);
00792     fprintf (outf, _("    Coal mines %4d       Ore mines %4d         Communes %4d\n")
00793              ,group_count[GROUP_COALMINE], group_count[GROUP_OREMINE]
00794              ,group_count[GROUP_COMMUNE]);
00795     fprintf (outf, _("     Windmills %4d     Coal powers %4d     Solar powers %4d\n"),
00796              group_count[GROUP_WINDMILL],
00797              group_count[GROUP_COAL_POWER],
00798              group_count[GROUP_SOLAR_POWER]);
00799     fprintf (outf, _("   Substations %4d     Power lines %4d            Ports %4d\n")
00800              ,group_count[GROUP_SUBSTATION], group_count[GROUP_POWER_LINE]
00801              ,group_count[GROUP_PORT]);
00802     fprintf (outf, _("    Light inds %4d      Heavy inds %4d        Recyclers %4d\n")
00803              ,group_count[GROUP_INDUSTRY_L], group_count[GROUP_INDUSTRY_H]
00804              ,group_count[GROUP_RECYCLE]);
00805     fprintf (outf, _("Health centres %4d            Tips %4d         Shanties %4d\n"),
00806              group_count[GROUP_HEALTH], group_count[GROUP_TIP],
00807              group_count[GROUP_SHANTY]);
00808     fclose (outf);
00809     free (s);
00810     return (1);
00811 }
00812 
00813 
00814 void
00815 print_results (void)
00816 {
00817 #if !defined (WIN32)            /* GCS FIX: How should I do this? */
00818     char *s;
00819     if (compile_results () == 0)
00820         return;
00821     if ((s = (char *) malloc (lc_save_dir_len + strlen (LC_SAVE_DIR)
00822                               + strlen (RESULTS_FILENAME) + 64)) == 0)
00823         malloc_failure ();
00824 
00825     strcpy (s, "cat ");
00826     strcat (s, lc_save_dir);
00827     strcat (s, "/");
00828     strcat (s, RESULTS_FILENAME);
00829     printf ("\n");
00830     system (s);
00831     printf ("\n");
00832 #endif
00833 }
00834 
00835 #if defined (commentout)
00836 void mail_results(void)
00837 {
00838     char s[256];
00839     if (compile_results()==0)
00840         return;
00841     strcpy(s,"mail -s 'LinCity results' lc-results@floot.demon.co.uk < ");
00842     strcat(s,getenv("HOME"));
00843     strcat(s,"/");
00844     strcat(s,LC_SAVE_DIR);
00845     strcat(s,"/");
00846     strcat(s,RESULTS_FILENAME);
00847     system(s);
00848 }
00849 #endif
00850 
00851 void
00852 window_results (void)
00853 {
00854     char *s;
00855     if (compile_results () == 0)
00856         return;
00857     if ((s = (char *) malloc (lc_save_dir_len + strlen (LC_SAVE_DIR)
00858                               + strlen (RESULTS_FILENAME) + 64)) == 0)
00859         malloc_failure ();
00860     sprintf (s, "%s%c%s", lc_save_dir, PATH_SLASH, RESULTS_FILENAME);
00861     ok_dial_box (s, RESULTS, 0L);
00862 }
00863 

Generated on Sun Dec 26 11:23:25 2004 for lincity by  doxygen 1.3.9.1