Go to the source code of this file.
Functions | |
| int | place_item (int x, int y, short type) |
| int | bulldoze_item (int x, int y) |
| void | do_coal_survey (void) |
| void | do_bulldoze_area (short fill, int xx, int yy) |
| void | launch_rocket (int x, int y) |
| void | connect_rivers (void) |
| int | adjust_money (int value) |
|
|
Definition at line 29 of file engine.c. 00030 {
00031 total_money += value;
00032 print_total_money();
00033 mappoint_stats(-3,-3,-3);
00034 update_pbar (PMONEY, total_money, 0);
00035 refresh_pbars(); /* This could be more specific */
00036 return total_money;
00037 }
|
|
||||||||||||
|
Definition at line 254 of file engine.c. 00255 {
00256 int g, size;
00257
00258 if (MP_TYPE(x,y) == CST_USED) {
00259 /* This is considered "improper" input. Silently ignore. */
00260 return -1;
00261 }
00262
00263 size = MP_SIZE(x,y);
00264 g = MP_GROUP(x,y);
00265
00266 if (g == GROUP_BARE) {
00267 /* Nothing to do. */
00268 return -1;
00269 }
00270 else if (g == GROUP_SHANTY) {
00271 fire_area (x, y);
00272 adjust_money(-GROUP_SHANTY_BUL_COST);
00273 }
00274 else if (g == GROUP_FIRE) {
00275 if (MP_INFO(x,y).int_2 >= FIRE_LENGTH)
00276 return -1; /* Can't bulldoze ? */
00277 MP_INFO(x,y).int_2 = FIRE_LENGTH + 1;
00278 MP_TYPE(x,y) = CST_FIRE_DONE1;
00279 MP_GROUP(x,y) = GROUP_BURNT;
00280 adjust_money(-GROUP_BURNT_BUL_COST);
00281 }
00282 else {
00283 adjust_money(-main_groups[g].bul_cost);
00284 do_bulldoze_area (CST_GREEN, x, y);
00285 if (g == GROUP_OREMINE)
00286 {
00287 int i, j;
00288 for (j = 0; j < 4; j++)
00289 for (i = 0; i < 4; i++)
00290 if (MP_INFO(x + i,y + j).ore_reserve < ORE_RESERVE / 2)
00291 do_bulldoze_area (CST_WATER, x + i, y + j);
00292 }
00293 }
00294 /* Tell mps to check that we selected a valid module; if the previously
00295 selected module just got bulldozed, this will ensure that mps doesn't
00296 try to display it */
00297 mappoint_stats(-1,-1,-1);
00298
00299 return size; /* No longer used... */
00300 }
|
|
|
Definition at line 3805 of file engine.c. 03806 {
03807 int x, y, count;
03808 count = 1;
03809 while (count > 0)
03810 {
03811 count = 0;
03812 for (y = 0; y < WORLD_SIDE_LEN; y++)
03813 for (x = 0; x < WORLD_SIDE_LEN; x++)
03814 {
03815 if (is_real_river (x, y) == 1)
03816 {
03817 if (is_real_river (x - 1, y) == -1)
03818 {
03819 MP_INFO(x - 1,y).flags |= FLAG_IS_RIVER;
03820 count++;
03821 }
03822 if (is_real_river (x, y - 1) == -1)
03823 {
03824 MP_INFO(x,y - 1).flags |= FLAG_IS_RIVER;
03825 count++;
03826 }
03827 if (is_real_river (x + 1, y) == -1)
03828 {
03829 MP_INFO(x + 1,y).flags |= FLAG_IS_RIVER;
03830 count++;
03831 }
03832 if (is_real_river (x, y + 1) == -1)
03833 {
03834 MP_INFO(x,y + 1).flags |= FLAG_IS_RIVER;
03835 count++;
03836 }
03837 }
03838 }
03839 }
03840 }
|
|
||||||||||||||||
|
Definition at line 3717 of file engine.c. 03718 {
03719 int size, x, y;
03720 if (MP_TYPE(xx,yy) == CST_USED)
03721 {
03722 x = MP_INFO(xx,yy).int_1;
03723 y = MP_INFO(xx,yy).int_2;
03724 }
03725 else
03726 {
03727 x = xx;
03728 y = yy;
03729 }
03730 size = MP_SIZE(x,y);
03731 if (MP_GROUP(x,y) == GROUP_SUBSTATION
03732 || MP_GROUP(x,y) == GROUP_WINDMILL)
03733 remove_a_substation (x, y);
03734 else if (MP_GROUP(x,y) == GROUP_MARKET)
03735 remove_a_market (x, y);
03736 else if (MP_GROUP(x,y) == GROUP_SHANTY)
03737 numof_shanties--;
03738 else if (MP_GROUP(x,y) == GROUP_COMMUNE)
03739 numof_communes--;
03740
03741 people_pool += MP_INFO(x,y).population;
03742 clear_mappoint (fill, x, y);
03743 if (size > 1) /* do size 2 */
03744 {
03745 clear_mappoint (fill, x + 1, y);
03746 clear_mappoint (fill, x, y + 1);
03747 clear_mappoint (fill, x + 1, y + 1);
03748 }
03749 if (size > 2) /* do size 3 */
03750 {
03751 clear_mappoint (fill, x + 2, y);
03752 clear_mappoint (fill, x + 2, y + 1);
03753 clear_mappoint (fill, x + 2, y + 2);
03754 clear_mappoint (fill, x, y + 2);
03755 clear_mappoint (fill, x + 1, y + 2);
03756 }
03757 if (size > 3) /* do size 4 */
03758 {
03759 clear_mappoint (fill, x + 3, y);
03760 clear_mappoint (fill, x + 3, y + 1);
03761 clear_mappoint (fill, x + 3, y + 2);
03762 clear_mappoint (fill, x + 3, y + 3);
03763 clear_mappoint (fill, x, y + 3);
03764 clear_mappoint (fill, x + 1, y + 3);
03765 clear_mappoint (fill, x + 2, y + 3);
03766 }
03767 }
|
|
|
Definition at line 3857 of file engine.c. 03858 {
03859 if (coal_survey_done == 0) {
03860 adjust_money(-1000000);
03861 coal_survey_done = 1;
03862 }
03863 }
|
|
||||||||||||
|
Definition at line 2548 of file engine.c. 02549 {
02550 int i, r, xx, yy, xxx, yyy;
02551 rockets_launched++;
02552 MP_TYPE(x,y) = CST_ROCKET_FLOWN;
02553 update_main_screen (0);
02554 r = rand () % MAX_TECH_LEVEL;
02555 if (r > tech_level || rand () % 100 > (rockets_launched * 15 + 25)) {
02556 /* the launch failed */
02557 display_rocket_result_dialog (ROCKET_LAUNCH_BAD);
02558 rockets_launched_success = 0;
02559 xx = ((rand () % 40) - 20) + x;
02560 yy = ((rand () % 40) - 20) + y;
02561 for (i = 0; i < 20; i++) {
02562 xxx = ((rand () % 20) - 10) + xx;
02563 yyy = ((rand () % 20) - 10) + yy;
02564 if (xxx > 0 && xxx < WORLD_SIDE_LEN
02565 && yyy > 0 && yyy < WORLD_SIDE_LEN) {
02566 /* don't crash on it's own area */
02567 if (xxx >= x && xxx < (x + 4) && yyy >= y && yyy < (y + 4))
02568 continue;
02569 fire_area (xxx, yyy);
02570 /* make a sound perhaps */
02571 }
02572 }
02573 } else {
02574 rockets_launched_success++;
02575 if (rockets_launched_success > 5) {
02576 remove_people (1000);
02577 if (people_pool || housed_population)
02578 display_rocket_result_dialog (ROCKET_LAUNCH_EVAC);
02579 } else {
02580 display_rocket_result_dialog (ROCKET_LAUNCH_GOOD);
02581 }
02582 }
02583 }
|
|
||||||||||||||||
|
Definition at line 80 of file engine.c. 00081 {
00082 int group;
00083 int size;
00084
00085 group = get_group_of_type(type);
00086 if (group < 0) return -1;
00087
00088 size = main_groups[group].size;
00089
00090 /* You can't build because credit not available. */
00091 if (no_credit_build (group) != 0) {
00092 return -1;
00093 }
00094
00095 /* Not enough slots in the substation array */
00096
00097 switch (group) {
00098 case GROUP_SUBSTATION:
00099 case GROUP_WINDMILL:
00100 {
00101 if (add_a_substation (x, y) == 0)
00102 return -3;
00103 } break;
00104 case GROUP_PORT:
00105 {
00106 if (is_real_river (x + 4, y) != 1
00107 || is_real_river (x + 4, y + 1) != 1
00108 || is_real_river (x + 4, y + 2) != 1
00109 || is_real_river (x + 4, y + 3) != 1) {
00110 return -2;
00111 }
00112 } break;
00113 case GROUP_COMMUNE:
00114 {
00115 numof_communes++;
00116 } break;
00117 case GROUP_MARKET:
00118 {
00119 /* Test for enough slots in the market array */
00120 if (add_a_market (x, y) == 0)
00121 return -3;
00122 MP_INFO(x,y).flags += (FLAG_MB_FOOD | FLAG_MB_JOBS
00123 | FLAG_MB_COAL | FLAG_MB_ORE | FLAG_MB_STEEL
00124 | FLAG_MB_GOODS | FLAG_MS_FOOD | FLAG_MS_JOBS
00125 | FLAG_MS_COAL | FLAG_MS_GOODS | FLAG_MS_ORE
00126 | FLAG_MS_STEEL);
00127 } break;
00128 case GROUP_TIP:
00129 {
00130 /* Don't build a tip if there has already been one. If we succeed,
00131 mark the spot permanently by "doubling" the ore reserve */
00132 int i,j;
00133 int prev_tip = 0;
00134 for (i=0;i<3;i++) {
00135 for (j=0;j<3;j++) {
00136 if (MP_INFO(x+i,y+j).ore_reserve > ORE_RESERVE) {
00137 prev_tip = 1;
00138 break;
00139 }
00140 }
00141 }
00142 if (prev_tip) {
00143 dialog_box(red(12),3,
00144 0,0,_("You can't build a tip here"),
00145 0,0,_("This area was once a landfill"),
00146 2,' ',_("OK"));
00147 return -4;
00148 } else {
00149 for (i=0;i<3;i++) {
00150 for (j=0;j<3;j++) {
00151 MP_INFO(x+i,y+j).ore_reserve = ORE_RESERVE * 2;
00152 }
00153 }
00154 }
00155 #if defined (commentout)
00156 if (MP_INFO(x,y).ore_reserve > ORE_RESERVE) {
00157 dialog_box(red(12),3,
00158 0,0,_("You can't build a tip here"),
00159 0,0,_("This is already landfill"),
00160 2,' ',_("OK"));
00161 return -4;
00162 } else {
00163 MP_INFO(x,y).ore_reserve = ORE_RESERVE * 2;
00164 }
00165 #endif
00166 } break;
00167 case GROUP_OREMINE:
00168 {
00169 /* Don't allow new mines on old mines or old tips */
00170 /* GCS: mines over old mines is OK if there is enough remaining
00171 ore, as is the case when there is parital overlap. */
00172 int i,j;
00173 int prev_tip = 0;
00174 int total_ore = 0;
00175 for (i=0;i<3;i++) {
00176 for (j=0;j<3;j++) {
00177 total_ore += MP_INFO(x+i,y+j).ore_reserve;
00178 if (MP_INFO(x+i,y+j).ore_reserve > ORE_RESERVE) {
00179 prev_tip = 1;
00180 break;
00181 }
00182 }
00183 }
00184 if (prev_tip) {
00185 dialog_box(red(12),3,
00186 0,0,_("You can't build a mine here"),
00187 0,0,_("This area was once a landfill"),
00188 2,' ',_("OK"));
00189 return -4;
00190 }
00191 if (total_ore < MIN_ORE_RESERVE_FOR_MINE) {
00192 dialog_box(red(12),3,
00193 0,0,_("You can't build a mine here"),
00194 0,0,_("There is no ore left at this site"),
00195 2,' ',_("OK"));
00196 return -4;
00197 }
00198 #if defined (commentout)
00199 if (MP_INFO(x,y).ore_reserve != ORE_RESERVE) {
00200 dialog_box(red(12),3,
00201 0,0,_("You can't build a mine here"),
00202 0,0,_("This was already a mine or tip"),
00203 2,' ',_("OK"));
00204 return -4;
00205 }
00206 #endif
00207 }
00208 } /* end case */
00209
00210 /* Store last_built for refund on "mistakes" */
00211 last_built_x = x;
00212 last_built_y = y;
00213
00214 /* Make sure that the correct windmill graphic shows up */
00215 if (group == GROUP_WINDMILL) {
00216 if (tech_level > MODERN_WINDMILL_TECH) {
00217 type = CST_WINDMILL_1_R;
00218 } else {
00219 type = CST_WINDMILL_1_W;
00220 }
00221 }
00222
00223 if (group == GROUP_SOLAR_POWER || group == GROUP_WINDMILL) {
00224 MP_INFO(x,y).int_2 = tech_level;
00225 let_one_through = 1;
00226 }
00227 else if (group == GROUP_RECYCLE || group == GROUP_COAL_POWER)
00228 MP_INFO(x,y).int_4 = tech_level;
00229 else if (group == GROUP_ORGANIC_FARM)
00230 MP_INFO(x,y).int_1 = tech_level;
00231 else if (group == GROUP_TRACK
00232 || group == GROUP_ROAD
00233 || group == GROUP_RAIL)
00234 MP_INFO(x,y).flags |= FLAG_IS_TRANSPORT;
00235 else if (group == GROUP_COALMINE
00236 || group == GROUP_OREMINE)
00237 let_one_through = 1;
00238
00239 set_mappoint (x, y, type);
00240
00241 update_tech_dep (x, y);
00242
00243 if (group == GROUP_RIVER)
00244 connect_rivers ();
00245
00246 connect_transport (x-2,y-2,x+size+1,y+size+1);
00247
00248 adjust_money(-selected_module_cost);
00249 map_power_grid();
00250 return 0;
00251 }
|
1.3.9.1