Exemplo n.º 1
0
static void
clear_game (void)
{
    int x, y;
    for (y = 0; y < WORLD_SIDE_LEN; y++) {
	for (x = 0; x < WORLD_SIDE_LEN; x++) {
	    clear_mappoint (CST_GREEN, x, y);
	    MP_POL(x,y) = 0;
	}
    }
    total_time = 0;
    coal_survey_done = 0;
    numof_shanties = 0;
    numof_communes = 0;
    numof_substations = 0;
    numof_health_centres = 0;
    numof_markets = 0;
    max_pop_ever = 0;
    total_evacuated = 0;
    total_births = 0;
    total_money = 0;
    tech_level = 0;
    init_inventory();
    update_avail_modules(0);
}
Exemplo n.º 2
0
void config_pc(dungeon_t *d)
{
  /* This should be in the PC constructor, now. */
  pc *the_pc;
  //One-Punch mode dice: pc_dice(0xFFFFFFFE, 1, 1)
  static dice pc_dice(0, 1, 4);

  the_pc = new pc;
  d->pc = (character *) the_pc;

  the_pc->symbol = '@';

  place_pc(d);

  the_pc->speed = PC_SPEED;
  the_pc->hp = PC_HP;
  the_pc->next_turn = 0;
  the_pc->alive = 1;
  the_pc->sequence_number = 0;
  the_pc->color.push_back(COLOR_WHITE);
  the_pc->damage = &pc_dice;
  the_pc->name = "Isabella Garcia-Shapiro";

  d->charmap[the_pc->position[dim_y]]
            [the_pc->position[dim_x]] = (character *) d->pc;

  dijkstra(d);
  dijkstra_tunnel(d);

  init_inventory(d);
}
Exemplo n.º 3
0
void	check_env_map7(t_data *data)
{
  if (data->map.end == 1)
    {
      init_main(data);
      init_text(data);
      init_map(data);
      init_inventory(data);
      bunny_delete_sound(&data->menu.menu_music->sound);
      init_menu(data);
      data->menu.menu_value = 1;
    }
  if ((data->mouse->x >= 13 && data->mouse->x <=  249) &&
      (data->mouse->y >= 182 && data->mouse->y <= 367))
    {
      if (data->player_pos != 0)
	position_handle(182, 330, data);
      else
	{
	  load_map6(data);
	}
    }
  else
    check_env_map7_2(data);
}
Exemplo n.º 4
0
int		init_player(t_game *game_data, t_player *player)
{
  (void) game_data;
  player->level = 1;
  player->inventory = NULL;
  player->cycles_to_die = BASE_FOOD * FOOD_CONSUMING_CYCLE;
  if (init_inventory(player) == -1)
    return (-1);
  if (init_player_exec_line(player) == -1)
    return (-1);
  player->orientation = UP;
  return (0);
}
Exemplo n.º 5
0
void load_test_assets()
{
	item_types = Arena_Push_Array(game->play_arena, Item_Info, Max_Item_Info_Count);
	_add_item(none, 0, 0, 0);
	_add_item(hooknife, 1, 0, 5);
	_add_item(rope, 8, 1, 5);
	_add_item(book, 64, 2, 5);
	_add_item(rock, 64, 3, 0);
	
	init_inventory(&inventory, 9, 6, game->play_arena);
	Item_Stack* stack = new_item_stack(item_types + 1, game->play_arena);
	printf("%0x \n", (usize)stack);
	inventory_add_item(&inventory, &stack);
	printf("%0x \n", (usize)stack);
}
Exemplo n.º 6
0
static int __init init_irix_binfmt(void)
{
	extern int init_inventory(void);
	extern asmlinkage unsigned long sys_call_table;
	extern asmlinkage unsigned long sys_call_table_irix5;

	init_inventory();

	/*
	 * Copy the IRIX5 syscall table (8000 bytes) into the main syscall
	 * table. The IRIX5 calls are located by an offset of 8000 bytes
	 * from the beginning of the main table.
	 */
	memcpy((void *) ((unsigned long) &sys_call_table + 8000),
		&sys_call_table_irix5, 8000);

	return register_binfmt(&irix_format);
}
Exemplo n.º 7
0
inv_t *load_inventory(FILE *f)
{
        char str[9];
        inv_t *i;
        int j;

        fread(str, sizeof(char), 9, f);
        if(strncmp(str, "INVENTORY", 9)) {
                fprintf(stderr, "DEBUG: %s:%d - Inventory not where I expected!\n", __FILE__, __LINE__);
                return false;
        }

        i = init_inventory();

        fread(&i->num_used, sizeof(short), 1, f);
        fread(&i->gold, sizeof(int), 1, f);

        for(j = 0; j < 52; j++)
                i->object[j] = load_object(f);

        return i;
}
Exemplo n.º 8
0
int parse_monsters()
{
        config_setting_t *cfg_monsters;
        int i, j, boolval, tmp, id;
        char sname[100];
        const char *value;
        char string[50];

        cfg_monsters = config_lookup(cf, "monsters");
        i = config_setting_length(cfg_monsters);
        game->monsterdefs = i;
        printf("Parsing monster file... We have %d monsters", i);

        /* 
         * main monster parsing loop 
         * goes through each possible setting, looks it up in the cfg file
         * and adds it to a monster structure which is then placed in the
         * linked list monsterdefs.
         */
        
        for(j=0;j<i;j++) {
                monster_t *m;

                m = (monster_t *) gtmalloc(sizeof(monster_t));
                id = j+1;

                sprintf(sname, "monsters.[%d].name", j);
                config_lookup_string(cf, sname, &value);
                strcpy(m->name, value);

                sprintf(sname, "monsters.[%d].str", j);
                config_lookup_int(cf, sname, &(m->attr.str));
                sprintf(sname, "monsters.[%d].phy", j);
                config_lookup_int(cf, sname, &(m->attr.phy));
                sprintf(sname, "monsters.[%d].intl", j);
                config_lookup_int(cf, sname, &(m->attr.intl));
                sprintf(sname, "monsters.[%d].wis", j);
                config_lookup_int(cf, sname, &(m->attr.wis));
                sprintf(sname, "monsters.[%d].dex", j);
                config_lookup_int(cf, sname, &(m->attr.dex));
                sprintf(sname, "monsters.[%d].cha", j);
                config_lookup_int(cf, sname, &(m->attr.cha));

                sprintf(sname, "monsters.[%d].appearance", j);
                config_lookup_string(cf, sname, &value);
                m->c = (char) *value;

                sprintf(sname, "monsters.[%d].level", j);
                config_lookup_int(cf, sname, &(m->level));

                sprintf(sname, "monsters.[%d].hp", j);
                config_lookup_int(cf, sname, &(m->hp));
                m->maxhp = m->hp;

                sprintf(sname, "monsters.[%d].speed", j);
                config_lookup_int(cf, sname, &(m->speed));

                sprintf(sname, "monsters.[%d].havegold", j);
                if(config_lookup_bool(cf, sname, &boolval))
                        if(boolval)
                                setbit(m->flags, MF_CANHAVEGOLD);

                sprintf(sname, "monsters.[%d].useweapon", j);
                if(config_lookup_bool(cf, sname, &boolval))
                        if(boolval)
                                setbit(m->flags, MF_CANUSEWEAPON);

                sprintf(sname, "monsters.[%d].usearmor", j);
                if(config_lookup_bool(cf, sname, &boolval))
                        if(boolval)
                                setbit(m->flags, MF_CANUSEARMOR);

                sprintf(sname, "monsters.[%d].aitype", j);
                config_lookup_int(cf, sname, &tmp);
                m->ai = aitable[tmp];
                m->mid = tmp;   // for monsterdefs, mid holds aitableindex
                m->id = id;

                m->viewradius = 12; // temporary solution?!

                // Let's give the monster a weapon!
                if(hasbit(m->flags, MF_CANUSEWEAPON)) {
                        int x;
                        obj_t *o;

                        sprintf(sname, "monsters.[%d].weapon", j);
                        config_lookup_string(cf, sname, &value);
                        strcpy(string, value);

                        x = get_objdef_by_name(string);

                        m->inventory = init_inventory();
                        o = spawn_object(x, 0);
                        m->inventory->object[0] = o;
                        m->weapon = o;
                }

                if(hasbit(m->flags, MF_CANHAVEGOLD)) {
                        if(!m->inventory)
                                m->inventory = init_inventory();

                        m->inventory->gold += ri(0, 15*m->level);
                        }

                
//if(m->weapon)
//fprintf(stderr, "DEBUG: %s:%d - %s has the weapon called a %s\n", __FILE__, __LINE__, m->name, m->weapon->basename);
                        

                /*
                 * the following was written in one go, it's beautiful and seems totally bugfree!!
                 */
                m->head = monsterdefs->head;
                monsterdefs->next = m;
                m->next = NULL;
                m->prev = monsterdefs;
                monsterdefs = m;

                printf("."); // "progress bar"
        }
        
        printf(" OK\n");

        monsterdefs->head->x = i; // store number of monsters in x of head.
        return 0;
}
Exemplo n.º 9
0
void load_city_2(char *cname)
{
    int i, x, y, p;
    int dumbint = 0;
    int num_pbars, pbar_data_size;
    int pbar_tmp;
    int dummy;
    gzFile gzfile;
    char s[512];

    clear_game();

    gzfile = gzopen(cname, "rb");
    if (gzfile == NULL) {
        printf(_("Can't open <%s> (gzipped)"), cname);
        do_error("Can't open it!");
    }

    sscanf(gzgets(gzfile, s, 256), "%d", &ldsv_version);
    if (ldsv_version < WATERWELL_V2) {
        gzclose(gzfile);
        load_city_old( cname );
        /* Fix desert frontier for old saved games and scenarios */
        desert_frontier(0, 0, WORLD_SIDE_LEN, WORLD_SIDE_LEN);
        return;
    }

    fprintf(stderr, " ldsv_version = %i \n", ldsv_version);
    use_waterwell = true;

    init_pbars();
    num_pbars = NUM_PBARS;
    pbar_data_size = PBAR_DATA_SIZE;

    init_inventory();
    print_time_for_year();

    // Easier debugging from saved game: #Line = 100 x + y + 1  (first line = ldsv_version)
    for (x = 0; x < WORLD_SIDE_LEN; x++) {
        for (y = 0; y < WORLD_SIDE_LEN; y++) {
            gzgets(gzfile, s, 512);
            //         TY  po fl cr  or  i1 i2 i3 i4 i5 i6 i7 PL al ec ws gp wa wp ww wn g1 g2 g3 g4 DA TK AN d4 d5 d6 d7 d8 d9
            sscanf(s, "%hi %d %i %hu %hu %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d"
                    , &MP_TYPE(x, y)
                    , &MP_INFO(x, y).population
                    , &MP_INFO(x, y).flags
                    , &MP_INFO(x, y).coal_reserve
                    , &MP_INFO(x, y).ore_reserve
                    , &MP_INFO(x, y).int_1
                    , &MP_INFO(x, y).int_2
                    , &MP_INFO(x, y).int_3
                    , &MP_INFO(x, y).int_4
                    , &MP_INFO(x, y).int_5
                    , &MP_INFO(x, y).int_6
                    , &MP_INFO(x, y).int_7
                    , &MP_POL(x, y)
                    , &ground[x][y].altitude
                    , &ground[x][y].ecotable
                    , &ground[x][y].wastes
                    , &ground[x][y].pollution
                    , &ground[x][y].water_alt
                    , &ground[x][y].water_pol
                    , &ground[x][y].water_wast
                    , &ground[x][y].water_next
                    , &ground[x][y].int1
                    , &ground[x][y].int2
                    , &ground[x][y].int3
                    , &ground[x][y].int4
                    , &MP_DATE(x,y)   // d1 = date of built
                    , &MP_TECH(x,y)   // d2 = tech at build time
                    , &MP_ANIM(x,y)   // d3 = animation_time (see reset_animation_time mess :)
                    , &dumbint        // d4  could be         image index for smooth animation, cf windmill anim_tile
                    , &dumbint        // d5                   percentage of activity to choose family of pic
                    , &dumbint        // d6
                    , &dumbint        // d7
                    , &dumbint        // d8
                    , &dumbint        // d9
                    );
            if (get_group_of_type(MP_TYPE(x, y)) == GROUP_MARKET)
                inventory(x, y);
        }
    }
    set_map_groups();

    sscanf(gzgets(gzfile, s, 256), "%d", &main_screen_originx);
    sscanf(gzgets(gzfile, s, 256), "%d", &main_screen_originy);

    sscanf(gzgets(gzfile, s, 256), "%d", &total_time);

    for (x = 0; x < MAX_NUMOF_SUBSTATIONS; x++) {
        sscanf(gzgets(gzfile, s, 256), "%d", &substationx[x]);
        sscanf(gzgets(gzfile, s, 256), "%d", &substationy[x]);
    }
    sscanf(gzgets(gzfile, s, 256), "%d", &numof_substations);

    for (x = 0; x < MAX_NUMOF_MARKETS; x++) {
        sscanf(gzgets(gzfile, s, 256), "%d", &marketx[x]);
        sscanf(gzgets(gzfile, s, 256), "%d", &markety[x]);
    }
    sscanf(gzgets(gzfile, s, 256), "%d", &numof_markets);
    sscanf(gzgets(gzfile, s, 256), "%d", &people_pool);
    sscanf(gzgets(gzfile, s, 256), "%o", &total_money);
    sscanf(gzgets(gzfile, s, 256), "%d", &income_tax_rate);
    sscanf(gzgets(gzfile, s, 256), "%d", &coal_tax_rate);
    sscanf(gzgets(gzfile, s, 256), "%d", &dole_rate);
    sscanf(gzgets(gzfile, s, 256), "%d", &transport_cost_rate);
    sscanf(gzgets(gzfile, s, 256), "%d", &goods_tax_rate);
    sscanf(gzgets(gzfile, s, 256), "%d", &export_tax);
    sscanf(gzgets(gzfile, s, 256), "%d", &export_tax_rate);
    sscanf(gzgets(gzfile, s, 256), "%d", &import_cost);
    sscanf(gzgets(gzfile, s, 256), "%d", &import_cost_rate);
    sscanf(gzgets(gzfile, s, 256), "%d", &tech_level);
    sscanf(gzgets(gzfile, s, 256), "%d", &tpopulation);
    sscanf(gzgets(gzfile, s, 256), "%d", &tstarving_population);
    sscanf(gzgets(gzfile, s, 256), "%d", &tunemployed_population);
    sscanf(gzgets(gzfile, s, 256), "%d", &x);   /* waste_goods obsolete */
    sscanf(gzgets(gzfile, s, 256), "%d", &power_made);
    sscanf(gzgets(gzfile, s, 256), "%d", &power_used);
    sscanf(gzgets(gzfile, s, 256), "%d", &coal_made);
    sscanf(gzgets(gzfile, s, 256), "%d", &coal_used);
    sscanf(gzgets(gzfile, s, 256), "%d", &goods_made);
    sscanf(gzgets(gzfile, s, 256), "%d", &goods_used);
    sscanf(gzgets(gzfile, s, 256), "%d", &ore_made);
    sscanf(gzgets(gzfile, s, 256), "%d", &ore_used);
    sscanf(gzgets(gzfile, s, 256), "%d", &dummy);       /* &diff_old_population */

    /* Update variables calculated from those above */
    housed_population = tpopulation / ((total_time % NUMOF_DAYS_IN_MONTH) + 1);

    /* Get size of monthgraph array */
    sscanf(gzgets(gzfile, s, 256), "%d", &i);
    for (x = 0; x < i; x++) {
        /* If more entries in file than will fit on screen, 
           then we need to skip past them. */
        if (x >= monthgraph_size) {
            sscanf(gzgets(gzfile, s, 256), "%d", &dummy);       /* &monthgraph_pop[x] */
            sscanf(gzgets(gzfile, s, 256), "%d", &dummy);       /* &monthgraph_starve[x] */
            sscanf(gzgets(gzfile, s, 256), "%d", &dummy);       /* &monthgraph_nojobs[x] */
            sscanf(gzgets(gzfile, s, 256), "%d", &dummy);       /* &monthgraph_ppool[x] */
        } else {
            sscanf(gzgets(gzfile, s, 256), "%d", &monthgraph_pop[x]);
            sscanf(gzgets(gzfile, s, 256), "%d", &monthgraph_starve[x]);
            sscanf(gzgets(gzfile, s, 256), "%d", &monthgraph_nojobs[x]);
            sscanf(gzgets(gzfile, s, 256), "%d", &monthgraph_ppool[x]);
        }
    }
    /* If screen bigger than number of entries in file, pad with zeroes */
    while (x < monthgraph_size) {
        monthgraph_pop[x] = 0;
        monthgraph_starve[x] = 0;
        monthgraph_nojobs[x] = 0;
        monthgraph_ppool[x] = 0;
        x++;
    }
    sscanf(gzgets(gzfile, s, 256), "%d", &rockets_launched);
    sscanf(gzgets(gzfile, s, 256), "%d", &rockets_launched_success);
    sscanf(gzgets(gzfile, s, 256), "%d", &coal_survey_done);

    for (x = 0; x < pbar_data_size; x++) {
        for (p = 0; p < num_pbars; p++) {
            sscanf(gzgets(gzfile, s, 256), "%d", &(pbar_tmp));
            update_pbar(p, pbar_tmp, 1);
        }
    }

    for (p = 0; p < num_pbars; p++)
        pbars[p].data_size = pbar_data_size;

    for (p = 0; p < num_pbars; p++) {
        sscanf(gzgets(gzfile, s, 256), "%d", &(pbars[p].oldtot));
        sscanf(gzgets(gzfile, s, 256), "%d", &(pbars[p].diff));
    }

    sscanf(gzgets(gzfile, s, 256), "%d", &cheat_flag);
    sscanf(gzgets(gzfile, s, 256), "%d", &total_pollution_deaths);
    sscanf(gzgets(gzfile, s, 256), "%f", &pollution_deaths_history);
    sscanf(gzgets(gzfile, s, 256), "%d", &total_starve_deaths);
    sscanf(gzgets(gzfile, s, 256), "%f", &starve_deaths_history);
    sscanf(gzgets(gzfile, s, 256), "%d", &total_unemployed_years);
    sscanf(gzgets(gzfile, s, 256), "%f", &unemployed_history);
    sscanf(gzgets(gzfile, s, 256), "%d", &max_pop_ever);
    sscanf(gzgets(gzfile, s, 256), "%d", &total_evacuated);
    sscanf(gzgets(gzfile, s, 256), "%d", &total_births);

    for (x = 0; x < NUMOF_MODULES; x++)
        sscanf(gzgets(gzfile, s, 256), "%d", &(module_help_flag[x]));

    sscanf(gzgets(gzfile, s, 256), "%128s", given_scene);
    if (strncmp(given_scene, "dummy", 5) == 0 || strlen(given_scene) < 3)
        given_scene[0] = 0;
    sscanf(gzgets(gzfile, s, 256), "%128s", s);
    if (strncmp(given_scene, "dummy", 5) != 0)
        sscanf(s, "%d", &highest_tech_level);
    else
        highest_tech_level = 0;

    gzgets(gzfile, s, 200);   
    if (sscanf
        (s, "sust %d %d %d %d %d %d %d %d %d %d", &sust_dig_ore_coal_count, &sust_port_count, &sust_old_money_count,
         &sust_old_population_count, &sust_old_tech_count, &sust_fire_count, &sust_old_money, &sust_old_population,
         &sust_old_tech, &sustain_flag) == 10) {
        sust_dig_ore_coal_tip_flag = sust_port_flag = 1;
    } else
        sustain_flag = sust_dig_ore_coal_count = sust_port_count
            = sust_old_money_count = sust_old_population_count
            = sust_old_tech_count = sust_fire_count = sust_old_money = sust_old_population = sust_old_tech = 0;

    gzgets(gzfile, s, 80);
    sscanf(s, "arid %d %d", &global_aridity, &global_mountainity);

    gzclose(gzfile);

    /* FIXME: AL1 this is initialisation stuff, should go elsewhere */

    // Engine stuff
    if (tech_level > MODERN_WINDMILL_TECH)
        modern_windmill_flag = 1;

    numof_shanties = count_groups(GROUP_SHANTY);
    numof_communes = count_groups(GROUP_COMMUNE);

    /* set up the university intake. */
    x = count_groups(GROUP_UNIVERSITY);
    if (x > 0) {
        university_intake_rate = (count_groups(GROUP_SCHOOL) * 20) / x;
        if (university_intake_rate > 100)
            university_intake_rate = 100;
    } else
        university_intake_rate = 50;

    print_total_money();

    //reset_animation_times
    //get alt_min, alt_max
    alt_min = 2000000000;
    alt_max = -alt_min;
    for ( y = 0; y < WORLD_SIDE_LEN; y++){
        for ( x = 0; x < WORLD_SIDE_LEN; x++) {
            MP_ANIM(x,y) = 0;
            if (MP_GROUP(x, y) == GROUP_FIRE){
                MP_INFO(x, y).int_3 = 0;
            }
            if (alt_min > ALT(x,y)){
                 alt_min = ALT(x,y);
            }
            if (alt_max < ALT(x,y)){
                 alt_max = ALT(x,y);
            }
        }
    }
    alt_step = (alt_max - alt_min) /10;

    map_power_grid(true);       /* WCK:  Is this safe to do here?
                                 * AL1: No, in NG_1.1
                                 * In case of error message with ok_dial_box
                                 *    the dialog cannot appear because the screen
                                 *    is not set up => crash.
                                 * FIXME: move all initialisation elsewhere, in 
                                 *    engine.cpp or simulate.cpp.
                                 */
    // UI stuff
    if (main_screen_originx > WORLD_SIDE_LEN - getMainWindowWidth() / 16 - 1)
        main_screen_originx = WORLD_SIDE_LEN - getMainWindowWidth() / 16 - 1;

    if (main_screen_originy > WORLD_SIDE_LEN - getMainWindowHeight() / 16 - 1)
        main_screen_originy = WORLD_SIDE_LEN - getMainWindowHeight() / 16 - 1;

    unhighlight_module_button(selected_module);
    selected_module = sbut[7];  /* 7 is track.  Watch out though! */
    highlight_module_button(selected_module);
    set_selected_module(CST_TRACK_LR);
    connect_transport(1, 1, WORLD_SIDE_LEN - 2, WORLD_SIDE_LEN - 2);
    /* Fix desert frontier for old saved games and scenarios */
    desert_frontier(0, 0, WORLD_SIDE_LEN, WORLD_SIDE_LEN);

}
Exemplo n.º 10
0
void
load_city (char *cname)
{
    unsigned long q;
    int i, x, y, z, n, p;
    int num_pbars, pbar_data_size;
    int pbar_tmp;
    int dummy;
    gzFile gzfile;
    char s[256];
    gzfile = gzopen( cname, "rb" ); 
    if ( gzfile == NULL) {
	    printf (_("Can't open <%s> (gzipped)"), cname);
	    do_error ("Can't open it!");
    }
    /* Add version to shared global variables for playing/saving games without waterwell */
    sscanf( gzgets( gzfile, s, 256 ), "%d", &ldsv_version);
    if (ldsv_version < MIN_LOAD_VERSION) {
	    ok_dial_box ("too-old.mes", BAD, 0L);
	    gzclose( gzfile );
	return;
    }

    fprintf(stderr," ldsv_version = %i \n", ldsv_version);
    if (ldsv_version < MIN_WATERWELL_VERSION) {
	/* ok_dial_box ("no-waterwell.mes", GOOD, 0L);*/
	use_waterwell=false;
    } else {
    	use_waterwell=true; 
	/* needed until it is written in the saved file
	 * in case of load after having played an old game
	 */
    }

    init_pbars();
    num_pbars = NUM_PBARS;
    pbar_data_size = PBAR_DATA_SIZE;

    init_inventory();
    
    print_time_for_year();
    q = (unsigned long) sizeof (Map_Point_Info);
    prog_box (_("Loading scene"), 0);

    for (x = 0; x < WORLD_SIDE_LEN; x++) {
	for (y = 0; y < WORLD_SIDE_LEN; y++) {
	    for (z = 0; z < sizeof(int); z++) {
		sscanf( gzgets( gzfile, s, 256 ), "%d", &n);
		*(((unsigned char *) &MP_INFO(x,y).population) + z) = n;
	    }
	    for (z = 0; z < sizeof(int); z++) {
		sscanf( gzgets( gzfile, s, 256 ), "%d", &n);
		*(((unsigned char *) &MP_INFO(x,y).flags) + z) = n;
	    }
	    for (z = 0; z < sizeof(unsigned short); z++) {
		sscanf( gzgets( gzfile, s, 256 ), "%d", &n);
		*(((unsigned char *) &MP_INFO(x,y).coal_reserve) + z) = n;
	    }
	    for (z = 0; z < sizeof(unsigned short); z++) {
		sscanf( gzgets( gzfile, s, 256 ), "%d", &n);
		*(((unsigned char *) &MP_INFO(x,y).ore_reserve) + z) = n;
	    }
	    for (z = 0; z < sizeof(int); z++) {
		sscanf( gzgets( gzfile, s, 256 ), "%d", &n);
		*(((unsigned char *) &MP_INFO(x,y).int_1) + z) = n;
	    }
	    for (z = 0; z < sizeof(int); z++) {
		sscanf( gzgets( gzfile, s, 256 ), "%d", &n);
		*(((unsigned char *) &MP_INFO(x,y).int_2) + z) = n;
	    }
	    for (z = 0; z < sizeof(int); z++) {
		sscanf( gzgets( gzfile, s, 256 ), "%d", &n);
		*(((unsigned char *) &MP_INFO(x,y).int_3) + z) = n;
	    }
	    for (z = 0; z < sizeof(int); z++) {
		sscanf( gzgets( gzfile, s, 256 ), "%d", &n);
		*(((unsigned char *) &MP_INFO(x,y).int_4) + z) = n;
	    }
	    for (z = 0; z < sizeof(int); z++) {
		sscanf( gzgets( gzfile, s, 256 ), "%d", &n);
		*(((unsigned char *) &MP_INFO(x,y).int_5) + z) = n;
	    }
	    for (z = 0; z < sizeof(int); z++) {
		sscanf( gzgets( gzfile, s, 256 ), "%d", &n);
		*(((unsigned char *) &MP_INFO(x,y).int_6) + z) = n;
	    }
	    for (z = 0; z < sizeof(int); z++) {
		sscanf( gzgets( gzfile, s, 256 ), "%d", &n);
		*(((unsigned char *) &MP_INFO(x,y).int_7) + z) = n;
	    }
	    sscanf( gzgets( gzfile, s, 256 ), "%d", &n);
	    MP_POL(x,y) = (unsigned short) n;
	    sscanf( gzgets( gzfile, s, 256 ), "%d", &n);
	    MP_TYPE(x,y) = (short) n;

	    if (get_group_of_type(MP_TYPE(x,y)) == GROUP_MARKET)
		inventory(x,y);
	}
	if (((93 * x) / WORLD_SIDE_LEN) % 3 == 0)
	    prog_box ("", (93 * x) / WORLD_SIDE_LEN);
    }
    check_endian ();
    set_map_groups ();

    sscanf( gzgets( gzfile, s, 256 ), "%d", &main_screen_originx);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &main_screen_originy);
    if (main_screen_originx > WORLD_SIDE_LEN - getMainWindowWidth() / 16 - 1)
	main_screen_originx = WORLD_SIDE_LEN - getMainWindowWidth() / 16 - 1;

    if (main_screen_originy > WORLD_SIDE_LEN - getMainWindowHeight() / 16 - 1)
	main_screen_originy = WORLD_SIDE_LEN - getMainWindowHeight() / 16 - 1;

    sscanf( gzgets( gzfile, s, 256 ), "%d", &total_time);
    if (ldsv_version <= MM_MS_C_VER)
	i = OLD_MAX_NUMOF_SUBSTATIONS;
    else
	i = MAX_NUMOF_SUBSTATIONS;
    for (x = 0; x < i; x++)
    {
	sscanf( gzgets( gzfile, s, 256 ), "%d", &substationx[x]);
	sscanf( gzgets( gzfile, s, 256 ), "%d", &substationy[x]);
    }
    prog_box ("", 92);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &numof_substations);
    if (ldsv_version <= MM_MS_C_VER)
	i = OLD_MAX_NUMOF_MARKETS;
    else
	i = MAX_NUMOF_MARKETS;
    for (x = 0; x < i; x++)
    {
	sscanf( gzgets( gzfile, s, 256 ), "%d", &marketx[x]);
	sscanf( gzgets( gzfile, s, 256 ), "%d", &markety[x]);
    }
    prog_box ("", 94);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &numof_markets);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &people_pool);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &total_money);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &income_tax_rate);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &coal_tax_rate);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &dole_rate);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &transport_cost_rate);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &goods_tax_rate);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &export_tax);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &export_tax_rate);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &import_cost);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &import_cost_rate);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &tech_level);
    if (tech_level > MODERN_WINDMILL_TECH)
	modern_windmill_flag = 1;
    sscanf( gzgets( gzfile, s, 256 ), "%d", &tpopulation);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &tstarving_population);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &tunemployed_population);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &x);  /* waste_goods obsolete */
    sscanf( gzgets( gzfile, s, 256 ), "%d", &power_made);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &power_used);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &coal_made);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &coal_used);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &goods_made);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &goods_used);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &ore_made);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &ore_used);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &dummy); /* &diff_old_population */

    /* Update variables calculated from those above */
    housed_population = tpopulation / NUMOF_DAYS_IN_MONTH;

    prog_box ("", 96);
    /* Get size of monthgraph array */
    if (ldsv_version <= MG_C_VER) {
	i = 120;
    } else {
	sscanf( gzgets( gzfile, s, 256 ), "%d", &i);
    }
    for (x = 0; x < i; x++) {
	/* If more entries in file than will fit on screen, 
	   then we need to skip past them. */
	if (x >= monthgraph_size) {
	    sscanf( gzgets( gzfile, s, 256 ), "%d", &dummy); /* &monthgraph_pop[x] */
	    sscanf( gzgets( gzfile, s, 256 ), "%d", &dummy); /* &monthgraph_starve[x] */
	    sscanf( gzgets( gzfile, s, 256 ), "%d", &dummy); /* &monthgraph_nojobs[x] */
	    sscanf( gzgets( gzfile, s, 256 ), "%d", &dummy); /* &monthgraph_ppool[x] */
	} else {
	    sscanf( gzgets( gzfile, s, 256 ), "%d", &monthgraph_pop[x]);
	    sscanf( gzgets( gzfile, s, 256 ), "%d", &monthgraph_starve[x]);
	    sscanf( gzgets( gzfile, s, 256 ), "%d", &monthgraph_nojobs[x]);
	    sscanf( gzgets( gzfile, s, 256 ), "%d", &monthgraph_ppool[x]);
	}
	/* If our save file is old, skip past obsolete diffgraph entries */
	if (ldsv_version <= MG_C_VER) {
	    sscanf( gzgets( gzfile, s, 256 ), "%d", &dummy); /* &diffgraph_power[x] */
	    sscanf( gzgets( gzfile, s, 256 ), "%d", &dummy); /* &diffgraph_coal[x] */
	    sscanf( gzgets( gzfile, s, 256 ), "%d", &dummy); /* &diffgraph_goods[x] */
	    sscanf( gzgets( gzfile, s, 256 ), "%d", &dummy); /* &diffgraph_ore[x] */
	    sscanf( gzgets( gzfile, s, 256 ), "%d", &dummy); /* &diffgraph_population[x] */
	}
    }
    /* If screen bigger than number of entries in file, pad with zeroes */
    while (x < monthgraph_size) {
	monthgraph_pop[x] = 0;
	monthgraph_starve[x] = 0;
	monthgraph_nojobs[x] = 0;
	monthgraph_ppool[x] = 0;
	x++;
    }
    prog_box ("", 98);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &rockets_launched);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &rockets_launched_success);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &coal_survey_done);
    
    for (x = 0; x < pbar_data_size; x++) {
	for (p = 0; p < num_pbars; p++) {
	    sscanf( gzgets( gzfile, s, 256 ), "%d", &(pbar_tmp));
	    update_pbar(p,pbar_tmp,1);
/*	    sscanf( gzgets( gzfile, s, 256 ), "%d", &(pbars[p].data[x])); */
	}
    }

    for (p = 0; p < num_pbars; p++)
	pbars[p].data_size = pbar_data_size;

    prog_box ("", 99);

    for (p = 0; p < num_pbars; p++) {
	sscanf( gzgets( gzfile, s, 256 ), "%d", &(pbars[p].oldtot));
	sscanf( gzgets( gzfile, s, 256 ), "%d", &(pbars[p].diff));
    }


    sscanf( gzgets( gzfile, s, 256 ), "%d", &cheat_flag);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &total_pollution_deaths);
    sscanf( gzgets( gzfile, s, 256 ), "%f", &pollution_deaths_history);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &total_starve_deaths);
    sscanf( gzgets( gzfile, s, 256 ), "%f", &starve_deaths_history);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &total_unemployed_years);
    sscanf( gzgets( gzfile, s, 256 ), "%f", &unemployed_history);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &max_pop_ever);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &total_evacuated);
    sscanf( gzgets( gzfile, s, 256 ), "%d", &total_births);
    for (x = 0; x < NUMOF_MODULES; x++)
	sscanf( gzgets( gzfile, s, 256 ), "%d", &(module_help_flag[x]));
    sscanf( gzgets( gzfile, s, 256 ), "%d", &x);	/* just dummy reads */
    sscanf( gzgets( gzfile, s, 256 ), "%d", &x);	/* for backwards compatibility. */

    /* 10 dummy strings, for missed out things, have been put in save. */
    /* Input from this point uses them. */
    /* XXX: WCK: Huh? Missed out things? */

    sscanf( gzgets( gzfile, s, 256 ), "%128s", given_scene);
    if (strncmp (given_scene, "dummy", 5) == 0 || strlen (given_scene) < 3)
	given_scene[0] = 0;
    sscanf( gzgets( gzfile, s, 256 ), "%128s", s);
    if (strncmp (given_scene, "dummy", 5) != 0)
	sscanf (s, "%d", &highest_tech_level);
    else
	highest_tech_level = 0;
    gzgets( gzfile, s, 80 );		/* this is the CR */

    if (sscanf (s, "sust %d %d %d %d %d %d %d %d %d %d"
		,&sust_dig_ore_coal_count, &sust_port_count
		,&sust_old_money_count, &sust_old_population_count
		,&sust_old_tech_count, &sust_fire_count
		,&sust_old_money, &sust_old_population, &sust_old_tech
		,&sustain_flag) == 10)
    {
	sust_dig_ore_coal_tip_flag = sust_port_flag = 1;
	/* GCS FIX: Check after loading file if screen is drawn OK */
	/* draw_sustainable_window (); */
    }
    else
	sustain_flag = sust_dig_ore_coal_count = sust_port_count
		= sust_old_money_count = sust_old_population_count
		= sust_old_tech_count = sust_fire_count
		= sust_old_money = sust_old_population = sust_old_tech = 0;
    if (use_waterwell == true) {
    }
    gzclose( gzfile );

    numof_shanties = count_groups (GROUP_SHANTY);
    numof_communes = count_groups (GROUP_COMMUNE);
    prog_box ("", 100);

    /* set up the university intake. */
    x = count_groups (GROUP_UNIVERSITY);
    if (x > 0) {
	university_intake_rate
		= (count_groups (GROUP_SCHOOL) * 20) / x;
	if (university_intake_rate > 100)
	    university_intake_rate = 100;
    }
    else
	university_intake_rate = 50;

    /*Al1 : What is this ? This does nothing, the value are saved in MP_INFO.int_ 
     * for (x = 0; x < WORLD_SIDE_LEN; x++)
     *   for (y = 0; y < WORLD_SIDE_LEN; y++)
     *     update_tech_dep (x, y);
     */

    unhighlight_module_button (selected_module);
    selected_module = sbut[7];	/* 7 is track.  Watch out though! */
    highlight_module_button (selected_module);
    set_selected_module (CST_TRACK_LR);

    print_total_money ();
    reset_animation_times ();
    /* update tech dep for compatibility with old games */
    for (x = 0; x < WORLD_SIDE_LEN; x++)
	for (y = 0; y < WORLD_SIDE_LEN; y++) {
            switch (MP_GROUP(x,y)) {
            case (GROUP_WINDMILL): 	 
                MP_INFO(x,y).int_1 = (int)(WINDMILL_POWER 	 
                        + (((double) MP_INFO(x,y).int_2 * WINDMILL_POWER)
                                / MAX_TECH_LEVEL));
                break;
            case (GROUP_COAL_POWER): 	 
                MP_INFO(x,y).int_1 = (int)(POWERS_COAL_OUTPUT 	 
                        + (((double) MP_INFO(x,y).int_4 * POWERS_COAL_OUTPUT) 
                                / MAX_TECH_LEVEL)); 	 
                break; 	 
            case (GROUP_SOLAR_POWER): 	 
                MP_INFO(x,y).int_1 = (int)(POWERS_SOLAR_OUTPUT 	 
                        + (((double) MP_INFO(x,y).int_2 * POWERS_SOLAR_OUTPUT) 	 
                                / MAX_TECH_LEVEL)); 	 
                break; 	 
            }
    }
 
    map_power_grid(true); /* WCK:  Is this safe to do here?
                           * AL1: No, in NG_1.1
                           * In case of error message with ok_dial_box
                           *    the dialog cannot appear because the screen
                           *    is not set up => crash.
                           * FIXME: move all initialisation elsewhere, in 
                           *    engine.cpp or simulate.cpp.
                           */
                                
}
Exemplo n.º 11
0
void
load_city (char *cname)
{
    unsigned long q;
    int i, x, y, z, n, p, ver;
    int num_pbars, pbar_data_size;
    int pbar_tmp;
    int dummy;
    FILE *ofile;
    char s[256];
    if ((ofile = fopen_read_gzipped (cname)) == NULL) {
	printf (_("Can't open <%s> (gzipped)"), cname);
	do_error ("Can't open it!");
    }
    fscanf (ofile, "%d", &ver);
    if (ver < MIN_LOAD_VERSION) {
	ok_dial_box ("too-old.mes", BAD, 0L);
	fclose_read_gzipped (ofile);
	return;
    }

    init_pbars();
    num_pbars = NUM_PBARS;
    pbar_data_size = PBAR_DATA_SIZE;

    init_inventory();
    
    print_time_for_year();
    q = (unsigned long) sizeof (Map_Point_Info);
    prog_box (_("Loading scene"), 0);

    for (x = 0; x < WORLD_SIDE_LEN; x++) {
	for (y = 0; y < WORLD_SIDE_LEN; y++) {
	    for (z = 0; z < sizeof(int); z++) {
		fscanf (ofile, "%d", &n);
		*(((unsigned char *) &MP_INFO(x,y).population) + z) = n;
	    }
	    for (z = 0; z < sizeof(int); z++) {
		fscanf (ofile, "%d", &n);
		*(((unsigned char *) &MP_INFO(x,y).flags) + z) = n;
	    }
	    for (z = 0; z < sizeof(unsigned short); z++) {
		fscanf (ofile, "%d", &n);
		*(((unsigned char *) &MP_INFO(x,y).coal_reserve) + z) = n;
	    }
	    for (z = 0; z < sizeof(unsigned short); z++) {
		fscanf (ofile, "%d", &n);
		*(((unsigned char *) &MP_INFO(x,y).ore_reserve) + z) = n;
	    }
	    for (z = 0; z < sizeof(int); z++) {
		fscanf (ofile, "%d", &n);
		*(((unsigned char *) &MP_INFO(x,y).int_1) + z) = n;
	    }
	    for (z = 0; z < sizeof(int); z++) {
		fscanf (ofile, "%d", &n);
		*(((unsigned char *) &MP_INFO(x,y).int_2) + z) = n;
	    }
	    for (z = 0; z < sizeof(int); z++) {
		fscanf (ofile, "%d", &n);
		*(((unsigned char *) &MP_INFO(x,y).int_3) + z) = n;
	    }
	    for (z = 0; z < sizeof(int); z++) {
		fscanf (ofile, "%d", &n);
		*(((unsigned char *) &MP_INFO(x,y).int_4) + z) = n;
	    }
	    for (z = 0; z < sizeof(int); z++) {
		fscanf (ofile, "%d", &n);
		*(((unsigned char *) &MP_INFO(x,y).int_5) + z) = n;
	    }
	    for (z = 0; z < sizeof(int); z++) {
		fscanf (ofile, "%d", &n);
		*(((unsigned char *) &MP_INFO(x,y).int_6) + z) = n;
	    }
	    for (z = 0; z < sizeof(int); z++) {
		fscanf (ofile, "%d", &n);
		*(((unsigned char *) &MP_INFO(x,y).int_7) + z) = n;
	    }
	    fscanf (ofile, "%d", &n);
	    MP_POL(x,y) = (unsigned short) n;
	    fscanf (ofile, "%d", &n);
	    MP_TYPE(x,y) = (short) n;

	    if (get_group_of_type(MP_TYPE(x,y)) == GROUP_MARKET)
		inventory(x,y);
	}
	if (((93 * x) / WORLD_SIDE_LEN) % 3 == 0)
	    prog_box ("", (93 * x) / WORLD_SIDE_LEN);
    }
    check_endian ();
    set_map_groups ();

    fscanf (ofile, "%d", &main_screen_originx);
    fscanf (ofile, "%d", &main_screen_originy);
    if (main_screen_originx > WORLD_SIDE_LEN - scr.main_win.w / 16 - 1)
	main_screen_originx = WORLD_SIDE_LEN - scr.main_win.w / 16 - 1;

    if (main_screen_originy > WORLD_SIDE_LEN - scr.main_win.h / 16 - 1)
	main_screen_originy = WORLD_SIDE_LEN - scr.main_win.h / 16 - 1;

    fscanf (ofile, "%d", &total_time);
    if (ver <= MM_MS_C_VER)
	i = OLD_MAX_NUMOF_SUBSTATIONS;
    else
	i = MAX_NUMOF_SUBSTATIONS;
    for (x = 0; x < i; x++)
    {
	fscanf (ofile, "%d", &substationx[x]);
	fscanf (ofile, "%d", &substationy[x]);
    }
    prog_box ("", 92);
    fscanf (ofile, "%d", &numof_substations);
    if (ver <= MM_MS_C_VER)
	i = OLD_MAX_NUMOF_MARKETS;
    else
	i = MAX_NUMOF_MARKETS;
    for (x = 0; x < i; x++)
    {
	fscanf (ofile, "%d", &marketx[x]);
	fscanf (ofile, "%d", &markety[x]);
    }
    prog_box ("", 94);
    fscanf (ofile, "%d", &numof_markets);
    fscanf (ofile, "%d", &people_pool);
    fscanf (ofile, "%d", &total_money);
    fscanf (ofile, "%d", &income_tax_rate);
    fscanf (ofile, "%d", &coal_tax_rate);
    fscanf (ofile, "%d", &dole_rate);
    fscanf (ofile, "%d", &transport_cost_rate);
    fscanf (ofile, "%d", &goods_tax_rate);
    fscanf (ofile, "%d", &export_tax);
    fscanf (ofile, "%d", &export_tax_rate);
    fscanf (ofile, "%d", &import_cost);
    fscanf (ofile, "%d", &import_cost_rate);
    fscanf (ofile, "%d", &tech_level);
    if (tech_level > MODERN_WINDMILL_TECH)
	modern_windmill_flag = 1;
    fscanf (ofile, "%d", &tpopulation);
    fscanf (ofile, "%d", &tstarving_population);
    fscanf (ofile, "%d", &tunemployed_population);
    fscanf (ofile, "%d", &x);  /* waste_goods obsolete */
    fscanf (ofile, "%d", &power_made);
    fscanf (ofile, "%d", &power_used);
    fscanf (ofile, "%d", &coal_made);
    fscanf (ofile, "%d", &coal_used);
    fscanf (ofile, "%d", &goods_made);
    fscanf (ofile, "%d", &goods_used);
    fscanf (ofile, "%d", &ore_made);
    fscanf (ofile, "%d", &ore_used);
    fscanf (ofile, "%d", &dummy); /* &diff_old_population */

    /* Update variables calculated from those above */
    housed_population = tpopulation / NUMOF_DAYS_IN_MONTH;

    prog_box ("", 96);
    /* Get size of monthgraph array */
    if (ver <= MG_C_VER) {
	i = 120;
    } else {
	fscanf (ofile, "%d", &i);
    }
    for (x = 0; x < i; x++) {
	/* If more entries in file than will fit on screen, 
	   then we need to skip past them. */
	if (x >= monthgraph_size) {
	    fscanf (ofile, "%d", &dummy); /* &monthgraph_pop[x] */
	    fscanf (ofile, "%d", &dummy); /* &monthgraph_starve[x] */
	    fscanf (ofile, "%d", &dummy); /* &monthgraph_nojobs[x] */
	    fscanf (ofile, "%d", &dummy); /* &monthgraph_ppool[x] */
	} else {
	    fscanf (ofile, "%d", &monthgraph_pop[x]);
	    fscanf (ofile, "%d", &monthgraph_starve[x]);
	    fscanf (ofile, "%d", &monthgraph_nojobs[x]);
	    fscanf (ofile, "%d", &monthgraph_ppool[x]);
	}
	/* If our save file is old, skip past obsolete diffgraph entries */
	if (ver <= MG_C_VER) {
	    fscanf (ofile, "%d", &dummy); /* &diffgraph_power[x] */
	    fscanf (ofile, "%d", &dummy); /* &diffgraph_coal[x] */
	    fscanf (ofile, "%d", &dummy); /* &diffgraph_goods[x] */
	    fscanf (ofile, "%d", &dummy); /* &diffgraph_ore[x] */
	    fscanf (ofile, "%d", &dummy); /* &diffgraph_population[x] */
	}
    }
    /* If screen bigger than number of entries in file, pad with zeroes */
    while (x < monthgraph_size) {
	monthgraph_pop[x] = 0;
	monthgraph_starve[x] = 0;
	monthgraph_nojobs[x] = 0;
	monthgraph_ppool[x] = 0;
	x++;
    }
    prog_box ("", 98);
    fscanf (ofile, "%d", &rockets_launched);
    fscanf (ofile, "%d", &rockets_launched_success);
    fscanf (ofile, "%d", &coal_survey_done);
    
    for (x = 0; x < pbar_data_size; x++) {
	for (p = 0; p < num_pbars; p++) {
	    fscanf (ofile, "%d", &(pbar_tmp));
	    update_pbar(p,pbar_tmp,1);
/*	    fscanf (ofile, "%d", &(pbars[p].data[x])); */
	}
    }

    for (p = 0; p < num_pbars; p++)
	pbars[p].data_size = pbar_data_size;

    prog_box ("", 99);

    for (p = 0; p < num_pbars; p++) {
	fscanf (ofile, "%d", &(pbars[p].oldtot));
	fscanf (ofile, "%d", &(pbars[p].diff));
    }


    fscanf (ofile, "%d", &cheat_flag);
    fscanf (ofile, "%d", &total_pollution_deaths);
    fscanf (ofile, "%f", &pollution_deaths_history);
    fscanf (ofile, "%d", &total_starve_deaths);
    fscanf (ofile, "%f", &starve_deaths_history);
    fscanf (ofile, "%d", &total_unemployed_years);
    fscanf (ofile, "%f", &unemployed_history);
    fscanf (ofile, "%d", &max_pop_ever);
    fscanf (ofile, "%d", &total_evacuated);
    fscanf (ofile, "%d", &total_births);
    for (x = 0; x < NUMOF_MODULES; x++)
	fscanf (ofile, "%d", &(module_help_flag[x]));
    fscanf (ofile, "%d", &x);	/* just dummy reads */
    fscanf (ofile, "%d", &x);	/* for backwards compatibility. */

    /* 10 dummy strings, for missed out things, have been put in save. */
    /* Input from this point uses them. */
    /* XXX: WCK: Huh? Missed out things? */

    fscanf (ofile, "%128s", given_scene);
    if (strncmp (given_scene, "dummy", 5) == 0 || strlen (given_scene) < 3)
	given_scene[0] = 0;
    fscanf (ofile, "%128s", s);
    if (strncmp (given_scene, "dummy", 5) != 0)
	sscanf (s, "%d", &highest_tech_level);
    else
	highest_tech_level = 0;
    fgets (s, 80, ofile);		/* this is the CR */

    fgets (s, 80, ofile);
    if (sscanf (s, "sust %d %d %d %d %d %d %d %d %d %d"
		,&sust_dig_ore_coal_count, &sust_port_count
		,&sust_old_money_count, &sust_old_population_count
		,&sust_old_tech_count, &sust_fire_count
		,&sust_old_money, &sust_old_population, &sust_old_tech
		,&sustain_flag) == 10)
    {
	sust_dig_ore_coal_tip_flag = sust_port_flag = 1;
	/* GCS FIX: Check after loading file if screen is drawn OK */
	/* draw_sustainable_window (); */
    }
    else
	sustain_flag = sust_dig_ore_coal_count = sust_port_count
		= sust_old_money_count = sust_old_population_count
		= sust_old_tech_count = sust_fire_count
		= sust_old_money = sust_old_population = sust_old_tech = 0;
    fclose_read_gzipped (ofile);

    numof_shanties = count_groups (GROUP_SHANTY);
    numof_communes = count_groups (GROUP_COMMUNE);
    prog_box ("", 100);

    /* set up the university intake. */
    x = count_groups (GROUP_UNIVERSITY);
    if (x > 0) {
	university_intake_rate
		= (count_groups (GROUP_SCHOOL) * 20) / x;
	if (university_intake_rate > 100)
	    university_intake_rate = 100;
    }
    else
	university_intake_rate = 50;
    for (x = 0; x < WORLD_SIDE_LEN; x++)
    {
	for (y = 0; y < WORLD_SIDE_LEN; y++)
	{
	    update_tech_dep (x, y);
	}
    }

    unhighlight_module_button (selected_module);
    selected_module = sbut[7];	/* 7 is track.  Watch out though! */
    highlight_module_button (selected_module);
    set_selected_module (CST_TRACK_LR);

    print_total_money ();
    reset_animation_times ();
    map_power_grid (); /* WCK:  Is this safe to do here? */
}
Exemplo n.º 12
0
asmlinkage void __init start_kernel(void)
{
	char * command_line;

#ifdef __SMP__
	static int boot_cpu = 1;
	/* "current" has been set up, we need to load it now */
	if (!boot_cpu)
		initialize_secondary();
	boot_cpu = 0;
#endif

/*
 * Interrupts are still disabled. Do necessary setups, then
 * enable them
 */
	printk(linux_banner);
	setup_arch(&command_line, &memory_start, &memory_end);
	memory_start = paging_init(memory_start,memory_end);
	trap_init();
	init_IRQ();
	sched_init();
	time_init();
	parse_options(command_line);

	/*
	 * HACK ALERT! This is early. We're enabling the console before
	 * we've done PCI setups etc, and console_init() must be aware of
	 * this. But we do want output early, in case something goes wrong.
	 */
	memory_start = console_init(memory_start,memory_end);
#ifdef CONFIG_MODULES
	init_modules();
#endif
	if (prof_shift) {
		prof_buffer = (unsigned int *) memory_start;
		/* only text is profiled */
		prof_len = (unsigned long) &_etext - (unsigned long) &_stext;
		prof_len >>= prof_shift;
		memory_start += prof_len * sizeof(unsigned int);
		memset(prof_buffer, 0, prof_len * sizeof(unsigned int));
	}

#ifdef CONFIG_REMOTE_DEBUG
	set_debug_traps();
	/* breakpoint(); */	/* execute a BREAK insn */
#endif
	memory_start = kmem_cache_init(memory_start, memory_end);
	sti();
	calibrate_delay();
#ifdef CONFIG_CPU_R5900
	r5900_init();
#endif
#ifdef CONFIG_BLK_DEV_INITRD
	if (initrd_start && !initrd_below_start_ok && initrd_start < memory_start) {
		printk(KERN_CRIT "initrd overwritten (0x%08lx < 0x%08lx) - "
		    "disabling it.\n",initrd_start,memory_start);
		initrd_start = 0;
	}
#endif
#ifdef CONFIG_BINFMT_IRIX
	init_inventory ();
#endif
	mem_init(memory_start,memory_end);
	kmem_cache_sizes_init();
#ifdef CONFIG_PROC_FS
	proc_root_init();
#endif
	uidcache_init();
	filescache_init();
	dcache_init();
	vma_init();
	buffer_init();
	signals_init();
	inode_init();
	file_table_init();
#if defined(CONFIG_SYSVIPC)
	ipc_init();
#endif
#if defined(CONFIG_QUOTA)
	dquot_init_hash();
#endif
	check_bugs();
	printk("POSIX conformance testing by UNIFIX\n");

	/* 
	 *	We count on the initial thread going ok 
	 *	Like idlers init is an unlocked kernel thread, which will
	 *	make syscalls (and thus be locked).
	 */
	smp_init();
	kernel_thread(init, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
	current->need_resched = 1;
 	cpu_idle(NULL);
}