void fire_area (int xx, int yy) { /* this happens when a rocket crashes or on random_fire. */ int x = xx; int y = yy; int size; if (MP_GROUP(x,y) == GROUP_WATER || MP_GROUP(x,y) == GROUP_FIRE) return; if (MP_TYPE(x,y) == CST_USED) { x = MP_INFO(xx,yy).int_1; y = MP_INFO(xx,yy).int_2; } size = MP_SIZE(x,y); /* Destroy the content of the building to prevent special management * when bulldozed. */ /* Kill 'only' half of the people (bulldoze item put them in people_pool) * lincity NG 1.1 and previous killed all the people! */ if ((MP_INFO(x,y).flags & FLAG_FIRE_COVER) !=0) MP_INFO(x,y).population = MP_INFO(x,y).population / 2; else MP_INFO(x,y).population = 0; MP_INFO(x,y).flags = 0; MP_INFO(x,y).int_1 = 0; MP_INFO(x,y).int_2 = 0; MP_INFO(x,y).int_3 = 0; MP_INFO(x,y).int_4 = 0; MP_INFO(x,y).int_5 = 0; MP_INFO(x,y).int_6 = 0; MP_INFO(x,y).int_7 = 0; /* Correctly remove buildings (substations...) and adjust count, * but don't count bulldoze cost * */ adjust_money(+main_groups[MP_GROUP(x,y)].bul_cost); bulldoze_item(x, y); /* put fire */ for (int i = 0; i < size; i++) for (int j = 0; j < size; j++) { bulldoze_mappoint (CST_FIRE_1, x + i, y + j); MP_GROUP(x + i, y + j) = GROUP_FIRE; } /* AL1: is it necessary ? It is the only place in lincity/. with such a call * all other are in lincity-ng/. */ refresh_main_screen (); /* // update transport or we get stuff put in // the area from connected tracks etc. // FIXME: AL1: NG 1.1: do the right thing and/or remove this comment */ }
int place_item(int x, int y) { int group = (userOperation->action == UserOperation::ACTION_BUILD)?userOperation->constructionGroup->group:-1; int size = 1; if (group < 0) { ok_dial_box("warning.mes", BAD, _ ("ERROR: group does not exist. This should not happen! Please consider filling a bug report to lincity-ng team, with the saved game and what you did :-) ")); return -1000; } assert(userOperation->constructionGroup->is_allowed_here(x,y,false)); if(userOperation->action == UserOperation::ACTION_BUILD) { userOperation->constructionGroup->placeItem(x, y); size = userOperation->constructionGroup->size; adjust_money(-userOperation->constructionGroup->getCosts()); } connect_transport(x - 2, y - 2, x + size + 1, y + size + 1); desert_water_frontiers(x - 1, y - 1, size + 2, size + 2); connect_rivers(x,y); return 0; }
/* Feature: coal survey should vary in price and accuracy with technology */ void do_coal_survey (void) { if (coal_survey_done == 0) { adjust_money(-1000000); coal_survey_done = 1; } }
void setup() { set_name("firework"); set_long( "Its a small long shaped thingy. The only reason you can tell its "+ "a firework is the large letters on the side in blue that say 'firework' "+ "gives it away a bit really. You might even be able to use it.\n"); set_read_mess("%^BLUE%^F I R E W O R K S%^RESET%^"); adjust_money(10, "platinum"); } /* setup() */
int bulldoze_item (int x, int y) { int g, size; if (MP_TYPE(x,y) == CST_USED) { /* This is considered "improper" input. Silently ignore. */ return -1; } size = MP_SIZE(x,y); g = MP_GROUP(x,y); if (g == GROUP_BARE) { /* Nothing to do. */ return -1; } else if (g == GROUP_SHANTY) { fire_area (x, y); adjust_money(-GROUP_SHANTY_BUL_COST); } else if (g == GROUP_FIRE) { if (MP_INFO(x,y).int_2 >= FIRE_LENGTH) return -1; /* Can't bulldoze ? */ MP_INFO(x,y).int_2 = FIRE_LENGTH + 1; MP_TYPE(x,y) = CST_FIRE_DONE1; MP_GROUP(x,y) = GROUP_BURNT; adjust_money(-GROUP_BURNT_BUL_COST); } else { adjust_money(-main_groups[g].bul_cost); do_bulldoze_area (CST_GREEN, x, y); if (g == GROUP_OREMINE) { int i, j; for (j = 0; j < 4; j++) for (i = 0; i < 4; i++) if (MP_INFO(x + i,y + j).ore_reserve < ORE_RESERVE / 2) do_bulldoze_area (CST_WATER, x + i, y + j); } } return size; /* No longer used... */ }
int place_item (int x, int y, short type) { int group; int size; group = get_group_of_type(type); if (group < 0) return -1; size = main_groups[group].size; /* You can't build because credit not available. */ if (no_credit_build (group) != 0) { return -1; } /* Not enough slots in the substation array */ switch (group) { case GROUP_SUBSTATION: case GROUP_WINDMILL: { if (add_a_substation (x, y) == 0) return -3; } break; case GROUP_PORT: { if (is_real_river (x + 4, y) != 1 || is_real_river (x + 4, y + 1) != 1 || is_real_river (x + 4, y + 2) != 1 || is_real_river (x + 4, y + 3) != 1) { return -2; } } break; case GROUP_COMMUNE: { numof_communes++; } break; case GROUP_MARKET: { /* Test for enough slots in the market array */ if (add_a_market (x, y) == 0) return -3; MP_INFO(x,y).flags += (FLAG_MB_FOOD | FLAG_MB_JOBS | FLAG_MB_COAL | FLAG_MB_ORE | FLAG_MB_STEEL | FLAG_MB_GOODS | FLAG_MS_FOOD | FLAG_MS_JOBS | FLAG_MS_COAL | FLAG_MS_GOODS | FLAG_MS_ORE | FLAG_MS_STEEL); } break; case GROUP_TIP: { /* Don't build a tip if there has already been one. If we succeed, mark the spot permanently by "doubling" the ore reserve */ int i,j; int prev_tip = 0; for (i=0;i<3;i++) { for (j=0;j<3;j++) { if (MP_INFO(x+i,y+j).ore_reserve > ORE_RESERVE) { prev_tip = 1; break; } } } if (prev_tip) { dialog_box(red(12),3, 0,0,_("You can't build a tip here"), 0,0,_("This area was once a landfill"), 2,' ',_("OK")); return -4; } else { for (i=0;i<3;i++) { for (j=0;j<3;j++) { MP_INFO(x+i,y+j).ore_reserve = ORE_RESERVE * 2; } } } } break; case GROUP_OREMINE: { /* Don't allow new mines on old mines or old tips */ /* GCS: mines over old mines is OK if there is enough remaining ore, as is the case when there is partial overlap. */ int i,j; int prev_tip = 0; int total_ore = 0; for (i=0;i<3;i++) { for (j=0;j<3;j++) { total_ore += MP_INFO(x+i,y+j).ore_reserve; if (MP_INFO(x+i,y+j).ore_reserve > ORE_RESERVE) { prev_tip = 1; break; } } } if (prev_tip) { dialog_box(red(12),3, 0,0,_("You can't build a mine here"), 0,0,_("This area was once a landfill"), 2,' ',_("OK")); return -4; } if (total_ore < MIN_ORE_RESERVE_FOR_MINE) { dialog_box(red(12),3, 0,0,_("You can't build a mine here"), 0,0,_("There is no ore left at this site"), 2,' ',_("OK")); return -4; } } } /* end case */ /* Store last_built for refund on "mistakes" */ last_built_x = x; last_built_y = y; /* Make sure that the correct windmill graphic shows up */ if (group == GROUP_WINDMILL) { if (tech_level > MODERN_WINDMILL_TECH) { type = CST_WINDMILL_1_R; } else { type = CST_WINDMILL_1_W; } } if (group == GROUP_SOLAR_POWER || group == GROUP_WINDMILL) { MP_INFO(x,y).int_2 = tech_level; let_one_through = 1; } else if (group == GROUP_RECYCLE || group == GROUP_COAL_POWER) MP_INFO(x,y).int_4 = tech_level; else if (group == GROUP_ORGANIC_FARM) MP_INFO(x,y).int_1 = tech_level; else if (group == GROUP_TRACK || group == GROUP_ROAD || group == GROUP_RAIL) MP_INFO(x,y).flags |= FLAG_IS_TRANSPORT; else if (group == GROUP_COALMINE || group == GROUP_OREMINE) let_one_through = 1; set_mappoint (x, y, type); update_tech_dep (x, y); if (group == GROUP_RIVER) connect_rivers (); connect_transport (x-2,y-2,x+size+1,y+size+1); adjust_money(-selected_module_cost); map_power_grid(); return 0; }
int bulldoze_item (int x, int y) { int g, size; if (MP_TYPE(x,y) == CST_USED) { /* This is considered "improper" input. Silently ignore. */ #ifdef DEBUG fprintf(stderr," try to improperly bulldoze_item CST_USED\n"); #endif return -1; } size = MP_SIZE(x,y); g = MP_GROUP(x,y); people_pool += MP_INFO(x,y).population; if (g == GROUP_DESERT) { /* Nothing to do. */ return -1; } else if (g == GROUP_SHANTY) { remove_a_shanty(x, y); adjust_money(-GROUP_SHANTY_BUL_COST); numof_shanties--; } else if (g == GROUP_FIRE) { if (MP_INFO(x,y).int_2 >= FIRE_LENGTH) return -1; /* Can't bulldoze ? */ MP_INFO(x,y).int_2 = FIRE_LENGTH + 1; MP_TYPE(x,y) = CST_FIRE_DONE1; MP_GROUP(x,y) = GROUP_BURNT; adjust_money(-GROUP_BURNT_BUL_COST); } else { adjust_money(-main_groups[g].bul_cost); if (g == GROUP_COMMUNE) numof_communes--; if (g == GROUP_MARKET) remove_a_market (x, y); if (g == GROUP_SUBSTATION || g == GROUP_WINDMILL) remove_a_substation (x, y); if (g == GROUP_OREMINE) { int i, j; for (j = 0; j < 4; j++) for (i = 0; i < 4; i++) if (MP_INFO(x + i,y + j).ore_reserve < ORE_RESERVE / 2) do_bulldoze_area (CST_WATER, x + i, y + j); } else { /* keep compatibility for saving pre_waterwell loaded game */ if (use_waterwell) do_bulldoze_area (CST_DESERT, x, y); else do_bulldoze_area (CST_GREEN, x, y); } } /* Tell mps about it, in case its selected */ mps_update(); return size; /* No longer used... */ }
int place_item (int x, int y, short type) { int i,j; int prev_tip = 0; int group; int size; group = get_group_of_type(type); if (group < 0) { #ifdef DEBUG fprintf(stderr,"Error: group does not exist %i\n", group); #endif ok_dial_box ("warning.mes", BAD, _("ERROR: group does not exist. This should not happen! Please consider filling a bug report to lincity-ng team, with the saved game and what you did :-) ")); return -1000; } size = main_groups[group].size; /* You can't build because credit not available. */ if (no_credit_build (group) != 0) { no_credit_build_msg_ng (group); return -1; } switch (group) { case GROUP_ORGANIC_FARM: MP_INFO(x,y).int_1 = tech_level; break; case GROUP_TRACK: case GROUP_ROAD: case GROUP_RAIL: MP_INFO(x,y).flags |= FLAG_IS_TRANSPORT; break; case GROUP_PORT: if (is_real_river (x + 4, y) != 1 || is_real_river (x + 4, y + 1) != 1 || is_real_river (x + 4, y + 2) != 1 || is_real_river (x + 4, y + 3) != 1) { if (last_warning_message_group != group) ok_dial_box ("warning.mes", BAD, _("Port must be connected to river all along right side.")); last_warning_message_group = group; return -2; } break; case GROUP_SUBSTATION: if (add_a_substation (x, y) == 0) { /* Not enough slots in the substation array */ if (last_warning_message_group != group) ok_dial_box ("warning.mes", BAD, _("Too many substations + windmills. You cannot build one more")); last_warning_message_group = group; return -3; } break; case GROUP_WINDMILL: if (add_a_substation (x, y) == 0) { /* Not enough slots in the substation array */ if (last_warning_message_group != group) ok_dial_box ("warning.mes", BAD, _("Too many substations + windmills. You cannot build one more")); last_warning_message_group = group; return -3; } MP_INFO(x,y).int_2 = tech_level; MP_INFO(x,y).int_1 = (int)(WINDMILL_POWER + (((double) MP_INFO(x,y).int_2 * WINDMILL_POWER) / MAX_TECH_LEVEL)); /* Make sure that the correct windmill graphic shows up */ if (tech_level > MODERN_WINDMILL_TECH) type = CST_WINDMILL_1_R; else type = CST_WINDMILL_1_W; break; case (GROUP_COAL_POWER): MP_INFO(x,y).int_4 = tech_level; 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_2 = tech_level; MP_INFO(x,y).int_1 = (int)(POWERS_SOLAR_OUTPUT + (((double) MP_INFO(x,y).int_2 * POWERS_SOLAR_OUTPUT) / MAX_TECH_LEVEL)); /* like other power sources */ MP_INFO(x,y).int_3 = MP_INFO(x,y).int_1; /* Int_3 is kept for compatibility */ break; case GROUP_COMMUNE: numof_communes++; break; case GROUP_MARKET: /* Test for enough slots in the market array */ if (add_a_market (x, y) == 0) { if (last_warning_message_group != group) ok_dial_box ("warning.mes", BAD, _("Too many markets. You cannot build one more")); last_warning_message_group = group; return -4; } MP_INFO(x,y).flags += (FLAG_MB_FOOD | FLAG_MB_JOBS | FLAG_MB_COAL | FLAG_MB_ORE | FLAG_MB_STEEL | FLAG_MB_GOODS | FLAG_MS_FOOD | FLAG_MS_JOBS | FLAG_MS_COAL | FLAG_MS_GOODS | FLAG_MS_ORE | FLAG_MS_STEEL); break; case GROUP_RECYCLE: MP_INFO(x,y).int_4 = tech_level; break; case GROUP_TIP: /* Don't build a tip if there has already been one. If we succeed, mark the spot permanently by "doubling" the ore reserve */ prev_tip = 0; for (i=0; i < size; i++) for (j=0; j < size; j++) if (MP_INFO(x+i,y+j).ore_reserve > ORE_RESERVE) { prev_tip = 1; break; } if (prev_tip) { ok_dial_box ("warning.mes", BAD, _("You can't build a tip here: this area was once a landfill")); return -5; } else { for (i=0; i < size; i++) for (j=0; j < size; j++) MP_INFO(x+i,y+j).ore_reserve = ORE_RESERVE * 2; } break; case GROUP_OREMINE: { /* Don't allow new mines on old mines or old tips */ /* GCS: mines over old mines is OK if there is enough remaining ore, as is the case when there is partial overlap. */ int total_ore = 0; prev_tip = 0; for (i=0;i<size;i++) { for (j=0;j<size;j++) { total_ore += MP_INFO(x+i,y+j).ore_reserve; if (MP_INFO(x+i,y+j).ore_reserve > ORE_RESERVE) { prev_tip = 1; break; } } } if (prev_tip) { ok_dial_box ("warning.mes", BAD, _("You can't build a mine here: This area was once a landfill")); return -6; } if (total_ore < MIN_ORE_RESERVE_FOR_MINE) { ok_dial_box("warning.mes", BAD, _("You can't build a mine here: there is no ore left at this site")); return -7; } break; } case GROUP_WATERWELL: numof_waterwell++; break; case GROUP_PARKLAND: if (use_waterwell) if (!HAS_UGWATER(x,y)) { ok_dial_box("warning.mes", BAD, _("You can't build a park here: it is a desert, parks need water")); return -8; } } /* end case */ last_warning_message_group = 0; /* Store last_built for refund on "mistakes" */ last_built_x = x; last_built_y = y; set_mappoint (x, y, type); if (group == GROUP_RIVER) connect_rivers (); connect_transport (x-2,y-2,x+size+1,y+size+1); adjust_money(-selected_module_cost); map_power_grid(); return 0; }
int bulldoze_item(int x, int y) { int g, size = 1; bool construction_found = false; if (!world(x, y)->is_visible()) { /* This is considered "improper" input. Silently ignore. */ #ifdef DEBUG fprintf(stderr, " try to improperly bulldoze_item CST_USED\n"); #endif return -1; } if (world(x, y)->reportingConstruction ) { construction_found = true; size = world(x, y)->reportingConstruction->constructionGroup->size; g = world(x, y)->reportingConstruction->constructionGroup->group; } else { size = 1; //all non-constructions are 1// MP_SIZE(x, y); g = world(x, y)->group; //size = main_groups[g].size; } if (g == GROUP_DESERT) { /* Nothing to do. */ return -1; } else if (g == GROUP_SHANTY) { ConstructionManager::executeRequest ( new BurnDownRequest(world(x,y)->reportingConstruction) ); adjust_money(-GROUP_SHANTY_BUL_COST); } else if (g == GROUP_FIRE) { return -1; /* Can't bulldoze ? */ } else { if (!construction_found) { adjust_money(-world(x,y)->getTileConstructionGroup()->bul_cost);} else { adjust_money(-world(x, y)->reportingConstruction->constructionGroup->bul_cost);} if (g == GROUP_OREMINE) { ConstructionManager::executeRequest ( new OreMineDeletionRequest(world(x, y)->reportingConstruction)); } else { do_bulldoze_area(x, y);} } /* Tell mps about it, in case its selected */ mps_update(); return size; /* No longer used... */ }
void process_keystrokes (int key) { #if defined (commentout) /* KBR 10/14/2002 - Cleanup MSVC warning */ int retval; #endif switch (key) { case 0: printf("dead!"); return; case ' ': /* Space */ case 10: /* Linefeed/Return */ case 13: /* Enter */ case 127: /* Backspace */ if (key == 127) { cs_mouse_handler (LC_MOUSE_RIGHTBUTTON | LC_MOUSE_PRESS, 0, 0); cs_mouse_handler (LC_MOUSE_RIGHTBUTTON | LC_MOUSE_RELEASE, 0, 0); } else { cs_mouse_handler (LC_MOUSE_LEFTBUTTON | LC_MOUSE_PRESS, 0, 0); cs_mouse_handler (LC_MOUSE_LEFTBUTTON | LC_MOUSE_RELEASE, 0, 0); } if (help_flag) { draw_help_page ("return-2"); } if (prefs_flag) { close_prefs_screen (); refresh_main_screen (); } break; #if defined (SVGALIB) case 91: { int w = vga_getkey (); switch (w) { case ('A'): cs_mouse_handler (0, 0, -kmouse_val); break; case ('B'): cs_mouse_handler (0, 0, kmouse_val); break; case ('C'): cs_mouse_handler (0, kmouse_val, 0); break; case ('D'): cs_mouse_handler (0, -kmouse_val, 0); break; } } break; #endif #if defined (WIN32) || defined (LC_X11) case 1: /* Scroll left */ if (x_key_shifted) { adjust_main_origin (main_screen_originx - RIGHT_MOUSE_MOVE_VAL, main_screen_originy, TRUE); } else { adjust_main_origin (main_screen_originx - 1, main_screen_originy, TRUE); } break; case 2: /* Scroll down */ if (x_key_shifted) { adjust_main_origin (main_screen_originx, main_screen_originy + RIGHT_MOUSE_MOVE_VAL, TRUE); } else { adjust_main_origin (main_screen_originx, main_screen_originy + 1, TRUE); } break; case 3: /* Scroll up */ if (x_key_shifted) { adjust_main_origin (main_screen_originx, main_screen_originy - RIGHT_MOUSE_MOVE_VAL, TRUE); } else { adjust_main_origin (main_screen_originx, main_screen_originy - 1, TRUE); } break; case 4: /* Scroll right */ if (x_key_shifted) { adjust_main_origin (main_screen_originx + RIGHT_MOUSE_MOVE_VAL, main_screen_originy, TRUE); } else { adjust_main_origin (main_screen_originx + 1, main_screen_originy, TRUE); } break; #endif case 'P': case 'p': select_pause (); break; #ifdef DEBUG_KEYS case 'e': if (cheat () != 0) people_pool += 100; break; case 'd': if (cheat () != 0) dump_screen (); break; case 'D': /* dump_tcore (); */ break; case 't': if (cheat () != 0) tech_level += 1000; break; case 'T': if (cheat () != 0) tech_level += 10000; break; case 'm': if (cheat () != 0) adjust_money(1000000); break; #endif case 'f': do_random_fire (-1, -1, 1); break; case 'L': case 'l': load_flag = 1; break; case 'H': case 'h': activate_help ("index.hlp"); break; /* Escape Key */ #ifdef LC_X11 case 27: #else case 5: #endif if (help_flag) { /* exit help */ draw_help_page("return-2"); } else if (prefs_flag) { close_prefs_screen(); refresh_main_screen (); } else { activate_help ("menu.hlp"); } break; case 'S': case 's': save_flag = 1; break; case 'v': case 'V': /* Toggle overlay */ rotate_main_screen(); break; case 'o': case 'O': prefs_flag = 1; break; case 'r': window_results(); break; case 'q': case 'Q': quit_flag = 1; break; } /* end switch on keystroke */ }