#include <stdio.h>#include <stdlib.h>#include <time.h>#include "common.h"#include "lctypes.h"#include "lin-city.h"#include "engine.h"#include "engglobs.h"#include "cliglobs.h"#include "simulate.h"#include "lcintl.h"#include "power.h"#include "mouse.h"#include "module_buttons.h"#include "pbar.h"#include "stats.h"#include "mps.h"#include "screen.h"#include "dialbox.h"Go to the source code of this file.
Functions | |
| int | adjust_money (int value) |
| int | is_real_river (int x, int y) |
| int | no_credit_build (int selected_group) |
| int | place_item (int x, int y, short type) |
| int | bulldoze_item (int x, int y) |
| void | do_residence (int x, int y) |
| void | do_industry_l (int x, int y) |
| void | do_industry_h (int x, int y) |
| void | do_organic_farm (int x, int y) |
| void | init_mappoint_array (void) |
| void | shuffle_mappoint_array (void) |
| void | do_coalmine (int x, int y) |
| void | do_oremine (int x, int y) |
| void | do_commune (int x, int y) |
| void | do_port (int x, int y) |
| int | buy_food (int xt, int yt) |
| int | buy_coal (int xt, int yt) |
| int | buy_ore (int xt, int yt) |
| int | buy_goods (int xt, int yt) |
| int | buy_steel (int xt, int yt) |
| int | sell_food (int xt, int yt) |
| int | sell_coal (int xt, int yt) |
| int | sell_ore (int xt, int yt) |
| int | sell_goods (int xt, int yt) |
| int | sell_steel (int xt, int yt) |
| void | do_pollution () |
| void | do_parkland (int x, int y) |
| void | do_university (int x, int y) |
| void | do_recycle (int x, int y) |
| void | do_health_centre (int x, int y) |
| void | do_rocket_pad (int x, int y) |
| void | launch_rocket (int x, int y) |
| void | remove_people (int num) |
| void | do_monument (int x, int y) |
| void | do_school (int x, int y) |
| void | do_blacksmith (int x, int y) |
| void | do_mill (int x, int y) |
| void | do_pottery (int x, int y) |
| void | do_firestation (int x, int y) |
| void | do_cricket (int x, int y) |
| void | clear_fire_health_and_cricket_cover (void) |
| void | do_fire_health_and_cricket_cover (void) |
| void | do_fire_cover (int x, int y) |
| void | do_health_cover (int x, int y) |
| void | do_cricket_cover (int x, int y) |
| void | do_random_fire (int x, int y, int pwarning) |
| void | do_fire (int x, int y) |
| int | spiral_find_group (int startx, int starty, int group) |
| int | spiral_find_2x2 (int startx, int starty) |
| void | add_a_shanty (void) |
| void | remove_a_shanty (void) |
| void | update_shanty (void) |
| void | do_shanty (int x, int y) |
| void | do_tip (int x, int y) |
| void | do_bulldoze_area (short fill, int xx, int yy) |
| void | update_tech_dep (int x, int y) |
| void | connect_rivers (void) |
| void | do_coal_survey (void) |
Variables | |
| int | selected_type_cost |
|
|
Definition at line 3513 of file engine.c. 03514 {
03515 int r, x, y;
03516 x = rand () % WORLD_SIDE_LEN;
03517 y = rand () % WORLD_SIDE_LEN;
03518 if (numof_shanties > 0 && rand () % 8 != 0)
03519 {
03520 r = spiral_find_group (x, y, GROUP_SHANTY);
03521 if (r == -1)
03522 {
03523 printf ("Looked for a shanty, without any! x=%d y=%d\n", x, y);
03524 return;
03525 }
03526 y = r / WORLD_SIDE_LEN;
03527 x = r % WORLD_SIDE_LEN;
03528 r = spiral_find_2x2 (x, y);
03529 if (r == -1)
03530 {
03531 #ifdef commentout /* wck: These are annoying when the map is full */
03532 printf ("Adding a shanty (s), no space for it?!\n");
03533 #endif
03534 return;
03535 }
03536 y = r / WORLD_SIDE_LEN;
03537 x = r % WORLD_SIDE_LEN;
03538 }
03539 else
03540 {
03541 r = spiral_find_group (x, y, GROUP_MARKET);
03542 if (r == -1)
03543 return; /* silently return, we havn't started yet. */
03544
03545 y = r / WORLD_SIDE_LEN;
03546 x = r % WORLD_SIDE_LEN;
03547 r = spiral_find_2x2 (x, y);
03548 if (r == -1)
03549 {
03550 #ifdef commentout /* see above */
03551 printf ("Adding a shanty (r), no space for it?!\n");
03552 #endif
03553 return;
03554 }
03555 y = r / WORLD_SIDE_LEN;
03556 x = r % WORLD_SIDE_LEN;
03557 }
03558 set_mappoint (x, y, CST_SHANTY);
03559 numof_shanties++;
03560 }
|
|
|
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 2009 of file engine.c. 02010 {
02011 int i = 0;
02012 if (MP_GROUP(xt,yt) == GROUP_TRACK)
02013 {
02014 if (MP_INFO(xt,yt).int_3 < MAX_COAL_ON_TRACK)
02015 i = MAX_COAL_ON_TRACK - MP_INFO(xt,yt).int_3;
02016 }
02017 else if (MP_GROUP(xt,yt) == GROUP_ROAD)
02018 {
02019 if (MP_INFO(xt,yt).int_3 < MAX_COAL_ON_ROAD)
02020 i = MAX_COAL_ON_ROAD - MP_INFO(xt,yt).int_3;
02021 }
02022 else if (MP_GROUP(xt,yt) == GROUP_RAIL)
02023 {
02024 if (MP_INFO(xt,yt).int_3 < MAX_COAL_ON_RAIL)
02025 i = MAX_COAL_ON_RAIL - MP_INFO(xt,yt).int_3;
02026 }
02027 i = (i * PORT_IMPORT_RATE) / 1000;
02028 MP_INFO(xt,yt).int_3 += i;
02029 return (i * PORT_COAL_RATE);
02030 }
|
|
||||||||||||
|
Definition at line 1985 of file engine.c. 01986 {
01987 int i = 0;
01988 if (MP_GROUP(xt,yt) == GROUP_TRACK)
01989 {
01990 if (MP_INFO(xt,yt).int_1 < MAX_FOOD_ON_TRACK)
01991 i = MAX_FOOD_ON_TRACK - MP_INFO(xt,yt).int_1;
01992 }
01993 else if (MP_GROUP(xt,yt) == GROUP_ROAD)
01994 {
01995 if (MP_INFO(xt,yt).int_1 < MAX_FOOD_ON_ROAD)
01996 i = MAX_FOOD_ON_ROAD - MP_INFO(xt,yt).int_1;
01997 }
01998 else if (MP_GROUP(xt,yt) == GROUP_RAIL)
01999 {
02000 if (MP_INFO(xt,yt).int_1 < MAX_FOOD_ON_RAIL)
02001 i = MAX_FOOD_ON_RAIL - MP_INFO(xt,yt).int_1;
02002 }
02003 i = (i * PORT_IMPORT_RATE) / 1000;
02004 MP_INFO(xt,yt).int_1 += i;
02005 return (i * PORT_FOOD_RATE);
02006 }
|
|
||||||||||||
|
Definition at line 2057 of file engine.c. 02058 {
02059 int i = 0;
02060 if (MP_GROUP(xt,yt) == GROUP_TRACK)
02061 {
02062 if (MP_INFO(xt,yt).int_4 < MAX_GOODS_ON_TRACK)
02063 i = MAX_GOODS_ON_TRACK - MP_INFO(xt,yt).int_4;
02064 }
02065 else if (MP_GROUP(xt,yt) == GROUP_ROAD)
02066 {
02067 if (MP_INFO(xt,yt).int_4 < MAX_GOODS_ON_ROAD)
02068 i = MAX_GOODS_ON_ROAD - MP_INFO(xt,yt).int_4;
02069 }
02070 else if (MP_GROUP(xt,yt) == GROUP_RAIL)
02071 {
02072 if (MP_INFO(xt,yt).int_4 < MAX_GOODS_ON_RAIL)
02073 i = MAX_GOODS_ON_RAIL - MP_INFO(xt,yt).int_4;
02074 }
02075 i = (i * PORT_IMPORT_RATE) / 1000;
02076 MP_INFO(xt,yt).int_4 += i;
02077 return (i * PORT_GOODS_RATE);
02078 }
|
|
||||||||||||
|
Definition at line 2033 of file engine.c. 02034 {
02035 int i = 0;
02036 if (MP_GROUP(xt,yt) == GROUP_TRACK)
02037 {
02038 if (MP_INFO(xt,yt).int_5 < MAX_ORE_ON_TRACK)
02039 i = MAX_ORE_ON_TRACK - MP_INFO(xt,yt).int_5;
02040 }
02041 else if (MP_GROUP(xt,yt) == GROUP_ROAD)
02042 {
02043 if (MP_INFO(xt,yt).int_5 < MAX_ORE_ON_ROAD)
02044 i = MAX_ORE_ON_ROAD - MP_INFO(xt,yt).int_5;
02045 }
02046 else if (MP_GROUP(xt,yt) == GROUP_RAIL)
02047 {
02048 if (MP_INFO(xt,yt).int_5 < MAX_ORE_ON_RAIL)
02049 i = MAX_ORE_ON_RAIL - MP_INFO(xt,yt).int_5;
02050 }
02051 i = (i * PORT_IMPORT_RATE) / 1000;
02052 MP_INFO(xt,yt).int_5 += i;
02053 return (i * PORT_ORE_RATE);
02054 }
|
|
||||||||||||
|
Definition at line 2082 of file engine.c. 02083 {
02084 int i = 0;
02085 if (MP_GROUP(xt,yt) == GROUP_TRACK)
02086 {
02087 if (MP_INFO(xt,yt).int_6 < MAX_STEEL_ON_TRACK)
02088 i = MAX_STEEL_ON_TRACK - MP_INFO(xt,yt).int_6;
02089 }
02090 else if (MP_GROUP(xt,yt) == GROUP_ROAD)
02091 {
02092 if (MP_INFO(xt,yt).int_6 < MAX_STEEL_ON_ROAD)
02093 i = MAX_STEEL_ON_ROAD - MP_INFO(xt,yt).int_6;
02094 }
02095 else if (MP_GROUP(xt,yt) == GROUP_RAIL)
02096 {
02097 if (MP_INFO(xt,yt).int_6 < MAX_STEEL_ON_RAIL)
02098 i = MAX_STEEL_ON_RAIL - MP_INFO(xt,yt).int_6;
02099 }
02100 i = (i * PORT_IMPORT_RATE) / 1000;
02101 MP_INFO(xt,yt).int_6 += i;
02102 return (i * PORT_STEEL_RATE);
02103 }
|
|
|
Definition at line 3123 of file engine.c. 03124 {
03125 int x, y, m;
03126 m = 0xffffffff - (FLAG_FIRE_COVER | FLAG_HEALTH_COVER
03127 | FLAG_CRICKET_COVER);
03128 for (y = 0; y < WORLD_SIDE_LEN; y++)
03129 for (x = 0; x < WORLD_SIDE_LEN; x++)
03130 MP_INFO(x,y).flags &= m;
03131 /* Wow... chache misses or what! */
03132 }
|
|
|
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 2728 of file engine.c. 02729 {
02730 /*
02731 // int_1 contains the goods at the blacksmith
02732 // int_2 contains the goods made - for the animation
02733 // int_3 contains the coal store
02734 // int_4 is the animation trigger time
02735 // int_5 is the % made so far this month
02736 // int_6 is the % capacity last month
02737 */
02738 if (MP_INFO(x,y).int_3 < MAX_COAL_AT_BLACKSMITH)
02739 if (get_coal (x, y, BLACKSMITH_GET_COAL) != 0)
02740 MP_INFO(x,y).int_3 += BLACKSMITH_GET_COAL;
02741 if (MP_INFO(x,y).int_1 < MAX_GOODS_AT_BLACKSMITH
02742 && MP_INFO(x,y).int_3 >= BLACKSMITH_COAL_USED)
02743 {
02744 if (get_steel (x, y, BLACKSMITH_STEEL_USED) != 0)
02745 {
02746 MP_INFO(x,y).int_1 += GOODS_MADE_BY_BLACKSMITH;
02747 MP_INFO(x,y).int_3 -= BLACKSMITH_COAL_USED;
02748 }
02749 }
02750 if (get_jobs (x, y, BLACKSMITH_JOBS) != 0)
02751 {
02752 if (MP_INFO(x,y).int_1 > GOODS_MADE_BY_BLACKSMITH)
02753 {
02754 if (put_goods (x, y, GOODS_MADE_BY_BLACKSMITH - 1) != 0)
02755 {
02756 MP_INFO(x,y).int_1 -= (GOODS_MADE_BY_BLACKSMITH - 1);
02757 MP_INFO(x,y).int_2 += (GOODS_MADE_BY_BLACKSMITH - 1);
02758 MP_INFO(x,y).int_5++;
02759 }
02760 else
02761 put_jobs (x, y, BLACKSMITH_JOBS);
02762 }
02763 else
02764 put_jobs (x, y, BLACKSMITH_JOBS);
02765 }
02766 else
02767 MP_TYPE(x,y) = CST_BLACKSMITH_0;
02768 if (MP_INFO(x,y).int_2 > BLACKSMITH_BATCH
02769 && real_time >= MP_INFO(x,y).int_4)
02770 {
02771 MP_INFO(x,y).int_4 = real_time + BLACKSMITH_ANIM_SPEED;
02772 switch (MP_TYPE(x,y))
02773 {
02774 case (CST_BLACKSMITH_0):
02775 MP_TYPE(x,y) = CST_BLACKSMITH_1;
02776 break;
02777 case (CST_BLACKSMITH_1):
02778 MP_TYPE(x,y) = CST_BLACKSMITH_2;
02779 break;
02780 case (CST_BLACKSMITH_2):
02781 MP_TYPE(x,y) = CST_BLACKSMITH_3;
02782 break;
02783 case (CST_BLACKSMITH_3):
02784 MP_TYPE(x,y) = CST_BLACKSMITH_4;
02785 break;
02786 case (CST_BLACKSMITH_4):
02787 MP_TYPE(x,y) = CST_BLACKSMITH_5;
02788 break;
02789 case (CST_BLACKSMITH_5):
02790 MP_TYPE(x,y) = CST_BLACKSMITH_6;
02791 break;
02792 case (CST_BLACKSMITH_6):
02793 MP_TYPE(x,y) = CST_BLACKSMITH_1;
02794 MP_INFO(x,y).int_2 = 0;
02795 MP_POL(x,y)++;
02796 break;
02797 }
02798 }
02799 if (total_time % 100 == 0)
02800 {
02801 MP_INFO(x,y).int_6 = MP_INFO(x,y).int_5;
02802 MP_INFO(x,y).int_5 = 0;
02803 }
02804 }
|
|
||||||||||||||||
|
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 1359 of file engine.c. 01360 {
01361 /*
01362 // int_1 is the coal at the surface
01363 // int_2 is the coal reserve under the ground. More than one mine can
01364 // int_3 is the jobs collected.
01365 */
01366 /* claim the coal under ground! */
01367 int xx, yy, xs, ys, xe, ye, cr;
01368 if (MP_INFO(x,y).int_1 < (DIG_MORE_COAL_TRIGGER - 1000))
01369 {
01370 if (MP_INFO(x,y).int_2 < 0)
01371 return; /* run out of reserves */
01372
01373 xs = x - COAL_RESERVE_SEARCH_LEN;
01374 if (xs < 0)
01375 xs = 0;
01376 ys = y - COAL_RESERVE_SEARCH_LEN;
01377 if (ys < 0)
01378 ys = 0;
01379 xe = x + COAL_RESERVE_SEARCH_LEN;
01380 if (xe > WORLD_SIDE_LEN)
01381 xe = WORLD_SIDE_LEN;
01382 ye = y + COAL_RESERVE_SEARCH_LEN;
01383 if (ye > WORLD_SIDE_LEN)
01384 ye = WORLD_SIDE_LEN;
01385 cr = 0;
01386 for (yy = ys; yy < ye; yy++)
01387 for (xx = xs; xx < xe; xx++)
01388 cr += MP_INFO(xx,yy).coal_reserve;
01389 MP_INFO(x,y).int_2 = cr;
01390 if (cr > 0)
01391 {
01392 if (get_jobs (x, y, JOBS_DIG_COAL
01393 - MP_INFO(x,y).int_3) != 0)
01394 {
01395 MP_INFO(x,y).int_3 = 0;
01396 for (yy = ys; yy < ye; yy++)
01397 for (xx = xs; xx < xe; xx++)
01398 if (MP_INFO(xx,yy).coal_reserve > 0)
01399 {
01400 MP_INFO(xx,yy).coal_reserve--;
01401 MP_INFO(x,y).int_1 += 1000;
01402 coal_made += 1000;
01403 coal_tax += 1000;
01404 sust_dig_ore_coal_tip_flag = 0;
01405 MP_POL(x,y) += COALMINE_POLLUTION;
01406 yy = ye;
01407 xx = xe; /* break out */
01408
01409 }
01410 }
01411 else if (get_jobs (x, y, JOBS_DIG_COAL / 10) != 0)
01412 MP_INFO(x,y).int_3 += JOBS_DIG_COAL / 10;
01413 else if (get_jobs (x, y, JOBS_DIG_COAL / 50) != 0)
01414 MP_INFO(x,y).int_3 += JOBS_DIG_COAL / 50;
01415 }
01416 else
01417 {
01418 MP_INFO(x,y).int_1 = 0;
01419 MP_INFO(x,y).int_2 = -1;
01420 }
01421 }
01422 /* put it on the railway */
01423 if (MP_GROUP(x - 1,y) == GROUP_RAIL
01424 && MP_INFO(x - 1,y).int_3 < MAX_COAL_ON_RAIL
01425 && MP_INFO(x,y).int_1 >= (MAX_COAL_ON_RAIL
01426 - MP_INFO(x - 1,y).int_3))
01427 {
01428 if (get_jobs (x, y, JOBS_LOAD_COAL) != 0)
01429 {
01430 MP_INFO(x,y).int_1
01431 -= (MAX_COAL_ON_RAIL - MP_INFO(x - 1,y).int_3);
01432 MP_INFO(x - 1,y).int_3 = MAX_COAL_ON_RAIL;
01433 }
01434 }
01435 if (MP_GROUP(x,y-1) == GROUP_RAIL
01436 && MP_INFO(x,y - 1).int_3 < MAX_COAL_ON_RAIL
01437 && MP_INFO(x,y).int_1 >= (MAX_COAL_ON_RAIL
01438 - MP_INFO(x,y - 1).int_3))
01439 {
01440 if (get_jobs (x, y, JOBS_LOAD_COAL) != 0)
01441 {
01442 MP_INFO(x,y).int_1
01443 -= (MAX_COAL_ON_RAIL - MP_INFO(x,y - 1).int_3);
01444 MP_INFO(x,y - 1).int_3 = MAX_COAL_ON_RAIL;
01445 }
01446 }
01447 /* put it on the road */
01448 if (MP_GROUP(x-1,y) == GROUP_ROAD
01449 && MP_INFO(x - 1,y).int_3 < MAX_COAL_ON_ROAD
01450 && MP_INFO(x,y).int_1 >= (MAX_COAL_ON_ROAD
01451 - MP_INFO(x - 1,y).int_3))
01452 {
01453 if (get_jobs (x, y, JOBS_LOAD_COAL) != 0)
01454 {
01455 MP_INFO(x,y).int_1
01456 -= (MAX_COAL_ON_ROAD - MP_INFO(x - 1,y).int_3);
01457 MP_INFO(x - 1,y).int_3 = MAX_COAL_ON_ROAD;
01458 }
01459 }
01460 if (MP_GROUP(x,y-1) == GROUP_ROAD
01461 && MP_INFO(x,y - 1).int_3 < MAX_COAL_ON_ROAD
01462 && MP_INFO(x,y).int_1 >= (MAX_COAL_ON_ROAD
01463 - MP_INFO(x,y - 1).int_3))
01464 {
01465 if (get_jobs (x, y, JOBS_LOAD_COAL) != 0)
01466 {
01467 MP_INFO(x,y).int_1
01468 -= (MAX_COAL_ON_ROAD - MP_INFO(x,y - 1).int_3);
01469 MP_INFO(x,y - 1).int_3 = MAX_COAL_ON_ROAD;
01470 }
01471 }
01472 /* put it on the tracks */
01473 if (MP_GROUP(x-1,y) == GROUP_TRACK
01474 && MP_INFO(x - 1,y).int_3 < MAX_COAL_ON_TRACK
01475 && MP_INFO(x,y).int_1 >= (MAX_COAL_ON_TRACK
01476 - MP_INFO(x - 1,y).int_3))
01477 {
01478 if (get_jobs (x, y, JOBS_LOAD_COAL) != 0)
01479 {
01480 MP_INFO(x,y).int_1
01481 -= (MAX_COAL_ON_TRACK - MP_INFO(x - 1,y).int_3);
01482 MP_INFO(x - 1,y).int_3 = MAX_COAL_ON_TRACK;
01483 }
01484 }
01485 if (MP_GROUP(x,y-1) == GROUP_TRACK
01486 && MP_INFO(x,y - 1).int_3 < MAX_COAL_ON_TRACK
01487 && MP_INFO(x,y).int_1 >= (MAX_COAL_ON_TRACK
01488 - MP_INFO(x,y - 1).int_3))
01489 {
01490 if (get_jobs (x, y, JOBS_LOAD_COAL) != 0)
01491 {
01492 MP_INFO(x,y).int_1
01493 -= (MAX_COAL_ON_TRACK - MP_INFO(x,y - 1).int_3);
01494 MP_INFO(x,y - 1).int_3 = MAX_COAL_ON_TRACK;
01495 }
01496 }
01497
01498 /* choose a graphic */
01499 if (MP_INFO(x,y).int_1 > (MAX_COAL_AT_MINE - (MAX_COAL_AT_MINE / 5)))
01500 MP_TYPE(x,y) = CST_COALMINE_FULL;
01501 else if (MP_INFO(x,y).int_1 > (MAX_COAL_AT_MINE / 2))
01502 MP_TYPE(x,y) = CST_COALMINE_MED;
01503 else if (MP_INFO(x,y).int_1 > 0)
01504 MP_TYPE(x,y) = CST_COALMINE_LOW;
01505 else
01506 MP_TYPE(x,y) = CST_COALMINE_EMPTY;
01507 }
|
|
||||||||||||
|
Definition at line 1677 of file engine.c. 01678 {
01679 /*
01680 // int_1 is the animation trigger time
01681 // int_2 is the steelflag/trackflag
01682 // int_3 is the coal sold in the last 100 days 200 units is 100%
01683 // steel adds more.
01684 // int_4 is the months without selling much coal,steel,ore
01685 // int_5 is the coal, ore, steel waste flags for last month
01686 // int_6 is the coal, ore, steel waste flags so far this month
01687 */
01688 /* GCS -- I folded the trackflag into int_2, changing the logic slightly.
01689 This change only affects the animation. */
01690 int trackflag = 0;
01691 /* stick coal and ore on tracks, in SMALL doses. */
01692 if (put_coal (x, y, 2) != 0)
01693 {
01694 trackflag = 1;
01695 MP_INFO(x,y).int_3++;
01696 MP_INFO(x,y).int_6 |= 1;
01697 }
01698 if (put_ore (x, y, 6) != 0)
01699 {
01700 trackflag = 1;
01701 MP_INFO(x,y).int_3++;
01702 MP_INFO(x,y).int_6 |= 2;
01703 }
01704 /* recycle a bit of waste */
01705 if (get_waste (x, y, 20) != 0)
01706 {
01707 trackflag = 1;
01708 MP_INFO(x,y).int_3++;
01709 MP_INFO(x,y).int_6 |= 8;
01710 }
01711 if (total_time % 10 == 0)
01712 {
01713 MP_INFO(x,y).int_2 = 1;
01714 if (put_steel (x, y, 2) != 0) {
01715 MP_INFO(x,y).int_3++;
01716 MP_INFO(x,y).int_6 |= 4;
01717 } else {
01718 MP_INFO(x,y).int_2 = 0;
01719 }
01720 if (trackflag) {
01721 MP_INFO(x,y).int_2 = 0;
01722 }
01723 }
01724 if (total_time % 100 == 48)
01725 {
01726 MP_INFO(x,y).int_5 = MP_INFO(x,y).int_6;
01727 MP_INFO(x,y).int_6 = 0;
01728 if (MP_INFO(x,y).int_2 == 0 || trackflag == 0)
01729 {
01730 if (MP_TYPE(x,y) > CST_COMMUNE_7)
01731 MP_TYPE(x,y) -= 7;
01732 }
01733 else if (MP_TYPE(x,y) <= CST_COMMUNE_7)
01734 MP_TYPE(x,y) += 7;
01735 if (MP_INFO(x,y).int_3 > 0) /* >0% */
01736 {
01737 MP_INFO(x,y).int_3 = 0;
01738 if (--MP_INFO(x,y).int_4 < 0)
01739 MP_INFO(x,y).int_4 = 0;
01740 }
01741 else
01742 {
01743 MP_INFO(x,y).int_3 = 0;
01744 MP_INFO(x,y).int_4++;
01745 if (MP_INFO(x,y).int_4 > 120) /* 10 years */
01746 {
01747 do_bulldoze_area (CST_PARKLAND_PLANE, x, y);
01748 return;
01749 }
01750 }
01751 }
01752 /* animate */
01753 if (real_time >= MP_INFO(x,y).int_1)
01754 {
01755 MP_INFO(x,y).int_1 = real_time + COMMUNE_ANIM_SPEED;
01756 switch (MP_TYPE(x,y))
01757 {
01758 case (CST_COMMUNE_1):
01759 MP_TYPE(x,y) = CST_COMMUNE_2;
01760 break;
01761 case (CST_COMMUNE_2):
01762 MP_TYPE(x,y) = CST_COMMUNE_3;
01763 break;
01764 case (CST_COMMUNE_3):
01765 MP_TYPE(x,y) = CST_COMMUNE_4;
01766 break;
01767 case (CST_COMMUNE_4):
01768 MP_TYPE(x,y) = CST_COMMUNE_5;
01769 break;
01770 case (CST_COMMUNE_5):
01771 MP_TYPE(x,y) = CST_COMMUNE_6;
01772 break;
01773 case (CST_COMMUNE_6):
01774 MP_TYPE(x,y) = CST_COMMUNE_1;
01775 break;
01776 case (CST_COMMUNE_8):
01777 MP_TYPE(x,y) = CST_COMMUNE_9;
01778 break;
01779 case (CST_COMMUNE_9):
01780 MP_TYPE(x,y) = CST_COMMUNE_10;
01781 break;
01782 case (CST_COMMUNE_10):
01783 MP_TYPE(x,y) = CST_COMMUNE_11;
01784 break;
01785 case (CST_COMMUNE_11):
01786 MP_TYPE(x,y) = CST_COMMUNE_12;
01787 break;
01788 case (CST_COMMUNE_12):
01789 MP_TYPE(x,y) = CST_COMMUNE_13;
01790 break;
01791 case (CST_COMMUNE_13):
01792 MP_TYPE(x,y) = CST_COMMUNE_8;
01793 break;
01794
01795 }
01796 }
01797
01798 }
|
|
||||||||||||
|
Definition at line 3068 of file engine.c. 03069 {
03070 /*
03071 // int_1 is the jobs stored at the pavillion
03072 // int_2 is the goods stored at the pavillion
03073 // int_3 is the animation flag
03074 // int_4 is the time of the next frame
03075 */
03076 if (MP_INFO(x,y).int_1
03077 < (MAX_JOBS_AT_CRICKET - CRICKET_GET_JOBS))
03078 if (get_jobs (x, y, CRICKET_GET_JOBS) != 0)
03079 MP_INFO(x,y).int_1 += CRICKET_GET_JOBS;
03080 if (MP_INFO(x,y).int_2
03081 < (MAX_GOODS_AT_CRICKET - CRICKET_GET_GOODS))
03082 if (get_goods (x, y, CRICKET_GET_GOODS) != 0)
03083 MP_INFO(x,y).int_2 += CRICKET_GET_GOODS;
03084 /* animate */
03085 if (MP_INFO(x,y).int_3 && real_time > MP_INFO(x,y).int_4)
03086 {
03087 MP_INFO(x,y).int_4 = real_time + CRICKET_ANIMATION_SPEED;
03088 switch (MP_TYPE(x,y))
03089 {
03090 case (CST_CRICKET_1):
03091 MP_TYPE(x,y) = CST_CRICKET_2;
03092 break;
03093 case (CST_CRICKET_2):
03094 MP_TYPE(x,y) = CST_CRICKET_3;
03095 break;
03096 case (CST_CRICKET_3):
03097 MP_TYPE(x,y) = CST_CRICKET_4;
03098 break;
03099 case (CST_CRICKET_4):
03100 MP_TYPE(x,y) = CST_CRICKET_5;
03101 break;
03102 case (CST_CRICKET_5):
03103 MP_TYPE(x,y) = CST_CRICKET_6;
03104 break;
03105 case (CST_CRICKET_6):
03106 MP_TYPE(x,y) = CST_CRICKET_7;
03107 break;
03108 case (CST_CRICKET_7):
03109 MP_TYPE(x,y) = CST_CRICKET_1;
03110 MP_INFO(x,y).int_3 = 0; /* disable anim */
03111
03112 break;
03113 }
03114 }
03115
03116 /* That's all. Cover is done by different functions every 3 months or so. */
03117
03118 cricket_cost += CRICKET_RUNNING_COST;
03119 }
|
|
||||||||||||
|
Definition at line 3208 of file engine.c. 03209 {
03210 int xx, x1, x2, y1, y2;
03211 if (MP_INFO(x,y).int_1 < (CRICKET_JOBS * DAYS_BETWEEN_COVER) ||
03212 MP_INFO(x,y).int_2 < (CRICKET_GOODS * DAYS_BETWEEN_COVER))
03213 return;
03214 MP_INFO(x,y).int_1 -= (CRICKET_JOBS * DAYS_BETWEEN_COVER);
03215 MP_INFO(x,y).int_2 -= (CRICKET_GOODS * DAYS_BETWEEN_COVER);
03216 MP_INFO(x,y).int_3 = 1; /* turn on animation */
03217
03218 x1 = x - CRICKET_RANGE;
03219 if (x1 < 0)
03220 x1 = 0;
03221 x2 = x + CRICKET_RANGE;
03222 if (x2 > WORLD_SIDE_LEN)
03223 x2 = WORLD_SIDE_LEN;
03224 y1 = y - CRICKET_RANGE;
03225 if (y1 < 0)
03226 y1 = 0;
03227 y2 = y + CRICKET_RANGE;
03228 if (y2 > WORLD_SIDE_LEN)
03229 y2 = WORLD_SIDE_LEN;
03230 for (; y1 < y2; y1++)
03231 for (xx = x1; xx < x2; xx++)
03232 MP_INFO(xx,y1).flags |= FLAG_CRICKET_COVER;
03233 }
|
|
||||||||||||
|
Definition at line 3327 of file engine.c. 03328 {
03329 /*
03330 // int_1 is the next animation frame time
03331 // int_2 is the fire length
03332 // int_3 is the real_time before the fire can spread or -1 if triggered
03333 // int_4 is the idle land length
03334 */
03335 int i;
03336 /* this so we don't get whole blocks changing in one go. */
03337 if (MP_INFO(x,y).int_2 == 0)
03338
03339 MP_INFO(x,y).int_2 = rand () % (FIRE_LENGTH / 5);
03340 if (MP_INFO(x,y).int_2 > FIRE_LENGTH)
03341 {
03342 int old_type = MP_TYPE(x,y);
03343 if (MP_INFO(x,y).int_4 == 0) /* rand length here also */
03344 MP_INFO(x,y).int_4 = rand () % (AFTER_FIRE_LENGTH / 6);
03345 MP_INFO(x,y).int_4++;
03346 if (MP_INFO(x,y).int_4 > AFTER_FIRE_LENGTH)
03347 do_bulldoze_area (CST_GREEN, x, y);
03348 else if (MP_INFO(x,y).int_4 > (3 * AFTER_FIRE_LENGTH) / 4)
03349 MP_TYPE(x,y) = CST_FIRE_DONE4;
03350 else if (MP_INFO(x,y).int_4 > (2 * AFTER_FIRE_LENGTH) / 4)
03351 MP_TYPE(x,y) = CST_FIRE_DONE3;
03352 else if (MP_INFO(x,y).int_4 > (AFTER_FIRE_LENGTH) / 4)
03353 MP_TYPE(x,y) = CST_FIRE_DONE2;
03354 else
03355 MP_TYPE(x,y) = CST_FIRE_DONE1;
03356 return;
03357 }
03358 MP_INFO(x,y).int_2++;
03359 if (real_time > MP_INFO(x,y).int_1)
03360 {
03361 MP_INFO(x,y).int_1 = real_time + FIRE_ANIMATION_SPEED;
03362 if (MP_TYPE(x,y) == CST_FIRE_1)
03363 MP_TYPE(x,y) = CST_FIRE_2;
03364 else if (MP_TYPE(x,y) == CST_FIRE_2)
03365 MP_TYPE(x,y) = CST_FIRE_3;
03366 else if (MP_TYPE(x,y) == CST_FIRE_3)
03367 MP_TYPE(x,y) = CST_FIRE_4;
03368 else if (MP_TYPE(x,y) == CST_FIRE_4)
03369 MP_TYPE(x,y) = CST_FIRE_5;
03370 else if (MP_TYPE(x,y) == CST_FIRE_5)
03371 MP_TYPE(x,y) = CST_FIRE_1;
03372 }
03373 if (MP_INFO(x,y).int_3 == -1)
03374 {
03375 if ((rand () % FIRE_DAYS_PER_SPREAD) == 1)
03376 {
03377 i = rand () % 4;
03378 switch (i)
03379 {
03380 case (0):
03381 do_random_fire (x - 1, y, 0);
03382 break;
03383 case (1):
03384 do_random_fire (x, y - 1, 0);
03385 break;
03386 case (2):
03387 do_random_fire (x + 1, y, 0);
03388 break;
03389 case (3):
03390 do_random_fire (x, y + 1, 0);
03391 break;
03392 }
03393 }
03394 }
03395 /* check here 'cos we can wait in the ok box for ever. */
03396 else if (MP_INFO(x,y).int_3 == 0)
03397 MP_INFO(x,y).int_3 = real_time + 15000; /* 15 secs seem fair */
03398 else if (real_time >= MP_INFO(x,y).int_3)
03399 MP_INFO(x,y).int_3 = -1;
03400 }
|
|
||||||||||||
|
Definition at line 3154 of file engine.c. 03155 {
03156 int xx, x1, x2, y1, y2;
03157 if (MP_INFO(x,y).int_1 < (FIRESTATION_JOBS * DAYS_BETWEEN_COVER) ||
03158 MP_INFO(x,y).int_2 < (FIRESTATION_GOODS * DAYS_BETWEEN_COVER))
03159 return;
03160 MP_INFO(x,y).int_1 -= (FIRESTATION_JOBS * DAYS_BETWEEN_COVER);
03161 MP_INFO(x,y).int_2 -= (FIRESTATION_GOODS * DAYS_BETWEEN_COVER);
03162 MP_INFO(x,y).int_3 = 1; /* turn on animation */
03163
03164 x1 = x - FIRESTATION_RANGE;
03165 if (x1 < 0)
03166 x1 = 0;
03167 x2 = x + FIRESTATION_RANGE;
03168 if (x2 > WORLD_SIDE_LEN)
03169 x2 = WORLD_SIDE_LEN;
03170 y1 = y - FIRESTATION_RANGE;
03171 if (y1 < 0)
03172 y1 = 0;
03173 y2 = y + FIRESTATION_RANGE;
03174 if (y2 > WORLD_SIDE_LEN)
03175 y2 = WORLD_SIDE_LEN;
03176 for (; y1 < y2; y1++)
03177 for (xx = x1; xx < x2; xx++)
03178 MP_INFO(xx,y1).flags |= FLAG_FIRE_COVER;
03179 }
|
|
|
Definition at line 3135 of file engine.c. 03136 {
03137 int x, y;
03138 for (y = 0; y < WORLD_SIDE_LEN; y++)
03139 for (x = 0; x < WORLD_SIDE_LEN; x++)
03140 {
03141 /* The next few lines need changing to test for */
03142 /* the group if these areas are animated. */
03143
03144 if (MP_GROUP(x,y) == GROUP_FIRESTATION)
03145 do_fire_cover (x, y);
03146 else if (MP_TYPE(x,y) == CST_HEALTH)
03147 do_health_cover (x, y);
03148 else if (MP_GROUP(x,y) == GROUP_CRICKET)
03149 do_cricket_cover (x, y);
03150 }
03151 }
|
|
||||||||||||
|
Definition at line 2996 of file engine.c. 02997 {
02998 /*
02999 // int_1 is the jobs stored at the fire station
03000 // int_2 is the goods stored at the fire station
03001 // int_3 is the animation flag
03002 // int_4 is the time of the next frame
03003 // int_5 is the pause counter
03004 */
03005 if (MP_INFO(x,y).int_1
03006 < (MAX_JOBS_AT_FIRESTATION - FIRESTATION_GET_JOBS))
03007 if (get_jobs (x, y, FIRESTATION_GET_JOBS) != 0)
03008 MP_INFO(x,y).int_1 += FIRESTATION_GET_JOBS;
03009 if (MP_INFO(x,y).int_2
03010 < (MAX_GOODS_AT_FIRESTATION - FIRESTATION_GET_GOODS))
03011 if (get_goods (x, y, FIRESTATION_GET_GOODS) != 0)
03012 MP_INFO(x,y).int_2 += FIRESTATION_GET_GOODS;
03013 /* animate */
03014 if (MP_INFO(x,y).int_3 && real_time > MP_INFO(x,y).int_4)
03015 {
03016 MP_INFO(x,y).int_4 = real_time + FIRESTATION_ANIMATION_SPEED;
03017 if (MP_INFO(x,y).int_5 > 0)
03018 MP_INFO(x,y).int_5--;
03019 else
03020 {
03021 switch (MP_TYPE(x,y))
03022 {
03023 case (CST_FIRESTATION_1):
03024 MP_TYPE(x,y) = CST_FIRESTATION_2;
03025 break;
03026 case (CST_FIRESTATION_2):
03027 MP_TYPE(x,y) = CST_FIRESTATION_3;
03028 break;
03029 case (CST_FIRESTATION_3):
03030 MP_TYPE(x,y) = CST_FIRESTATION_4;
03031 break;
03032 case (CST_FIRESTATION_4):
03033 MP_TYPE(x,y) = CST_FIRESTATION_5;
03034 break;
03035 case (CST_FIRESTATION_5):
03036 MP_TYPE(x,y) = CST_FIRESTATION_6;
03037 break;
03038 case (CST_FIRESTATION_6):
03039 MP_TYPE(x,y) = CST_FIRESTATION_7;
03040 MP_INFO(x,y).int_5 = 10; /* pause */
03041
03042 break;
03043 case (CST_FIRESTATION_7):
03044 MP_TYPE(x,y) = CST_FIRESTATION_8;
03045 break;
03046 case (CST_FIRESTATION_8):
03047 MP_TYPE(x,y) = CST_FIRESTATION_9;
03048 break;
03049 case (CST_FIRESTATION_9):
03050 MP_TYPE(x,y) = CST_FIRESTATION_10;
03051 break;
03052 case (CST_FIRESTATION_10):
03053 MP_TYPE(x,y) = CST_FIRESTATION_1;
03054 MP_INFO(x,y).int_3 = 0; /* stop */
03055
03056 break;
03057
03058
03059 }
03060 }
03061 }
03062 /* That's all. Cover is done by different functions every 3 months or so. */
03063
03064 fire_cost += FIRESTATION_RUNNING_COST;
03065 }
|
|
||||||||||||
|
Definition at line 2423 of file engine.c. 02424 {
02425 /*
02426 // int_1 is the jobs stored at the health centre
02427 // int_2 is the goods stored at the health centre
02428 */
02429 if (MP_INFO(x,y).int_1
02430 < (MAX_JOBS_AT_HEALTH_CENTRE - HEALTH_CENTRE_GET_JOBS))
02431 if (get_jobs (x, y, HEALTH_CENTRE_GET_JOBS) != 0)
02432 MP_INFO(x,y).int_1 += HEALTH_CENTRE_GET_JOBS;
02433 if (MP_INFO(x,y).int_2
02434 < (MAX_GOODS_AT_HEALTH_CENTRE - HEALTH_CENTRE_GET_GOODS))
02435 if (get_goods (x, y, HEALTH_CENTRE_GET_GOODS) != 0)
02436 MP_INFO(x,y).int_2 += HEALTH_CENTRE_GET_GOODS;
02437
02438 /* That's all. Cover is done by different functions every 3 months or so. */
02439
02440 health_cost += HEALTH_RUNNING_COST;
02441 }
|
|
||||||||||||
|
Definition at line 3182 of file engine.c. 03183 {
03184 int xx, x1, x2, y1, y2;
03185 if (MP_INFO(x,y).int_1 < (HEALTH_CENTRE_JOBS * DAYS_BETWEEN_COVER) ||
03186 MP_INFO(x,y).int_2 < (HEALTH_CENTRE_GOODS * DAYS_BETWEEN_COVER))
03187 return;
03188 MP_INFO(x,y).int_1 -= (HEALTH_CENTRE_JOBS * DAYS_BETWEEN_COVER);
03189 MP_INFO(x,y).int_2 -= (HEALTH_CENTRE_GOODS * DAYS_BETWEEN_COVER);
03190 x1 = x - HEALTH_CENTRE_RANGE;
03191 if (x1 < 0)
03192 x1 = 0;
03193 x2 = x + HEALTH_CENTRE_RANGE;
03194 if (x2 > WORLD_SIDE_LEN)
03195 x2 = WORLD_SIDE_LEN;
03196 y1 = y - HEALTH_CENTRE_RANGE;
03197 if (y1 < 0)
03198 y1 = 0;
03199 y2 = y + HEALTH_CENTRE_RANGE;
03200 if (y2 > WORLD_SIDE_LEN)
03201 y2 = WORLD_SIDE_LEN;
03202 for (; y1 < y2; y1++)
03203 for (xx = x1; xx < x2; xx++)
03204 MP_INFO(xx,y1).flags |= FLAG_HEALTH_COVER;
03205 }
|
|
||||||||||||
|
Definition at line 870 of file engine.c. 00871 {
00872 int rawm, steel = 0;
00873 /*
00874 // int_1 is the steel produced this month so far
00875 // int_2 is the amount of steel in store
00876 // int_3 is the amount of raw materials in store (ore)
00877 // int_4 is the coal in store
00878 // int_5 is the percent max production last month
00879 // int_6 is the time of the next animation frame.
00880 // int_7 is whether we get power from coal (1) or elsewhere (0)
00881 */
00882
00883 /* See if there's any raw materials (ore) on the road/rail. If so, use some
00884 jobs to get it. First get some ore...
00885 */
00886 if (MP_INFO(x,y).int_3 < MAX_ORE_AT_INDUSTRY_H
00887 && ((MP_INFO(x - 1,y).flags & FLAG_IS_TRANSPORT)
00888 != 0) && MP_INFO(x - 1,y).int_5 > 0)
00889 if (get_jobs (x, y, JOBS_LOAD_ORE) != 0)
00890 {
00891 MP_INFO(x,y).int_3 += (MP_INFO(x - 1,y).int_5 / 2
00892 + ((MP_INFO(x - 1,y).int_5) % 2));
00893 MP_INFO(x - 1,y).int_5 /= 2;
00894 }
00895 if (MP_INFO(x,y).int_3 < MAX_ORE_AT_INDUSTRY_H
00896 && ((MP_INFO(x,y - 1).flags & FLAG_IS_TRANSPORT)
00897 != 0) && MP_INFO(x,y - 1).int_5 > 0)
00898 if (get_jobs (x, y, JOBS_LOAD_ORE) != 0)
00899 {
00900 MP_INFO(x,y).int_3 += (MP_INFO(x,y - 1).int_5 / 2
00901 + ((MP_INFO(x,y - 1).int_5) % 2));
00902 MP_INFO(x,y - 1).int_5 /= 2;
00903 }
00904 /* then get some coal if needed */
00905 if (MP_INFO(x,y).int_4 < MAX_COAL_AT_INDUSTRY_H
00906 && ((MP_INFO(x - 1,y).flags & FLAG_IS_TRANSPORT)
00907 != 0) && MP_INFO(x - 1,y).int_3 > 0)
00908 if (get_jobs (x, y, JOBS_LOAD_COAL) != 0)
00909 {
00910 MP_INFO(x,y).int_4 += (MP_INFO(x - 1,y).int_3 / 2
00911 + ((MP_INFO(x - 1,y).int_3) % 2));
00912 MP_INFO(x - 1,y).int_3 /= 2;
00913 }
00914 if (MP_INFO(x,y).int_4 < MAX_ORE_AT_INDUSTRY_H
00915 && ((MP_INFO(x,y - 1).flags & FLAG_IS_TRANSPORT)
00916 != 0) && MP_INFO(x,y - 1).int_3 > 0)
00917 if (get_jobs (x, y, JOBS_LOAD_COAL) != 0)
00918 {
00919 MP_INFO(x,y).int_4 += (MP_INFO(x,y - 1).int_3 / 2
00920 + ((MP_INFO(x,y - 1).int_3) % 2));
00921 MP_INFO(x,y - 1).int_3 /= 2;
00922 }
00923
00924 rawm = MP_INFO(x,y).int_3;
00925 if (rawm > MAX_MADE_AT_INDUSTRY_H)
00926 rawm = MAX_MADE_AT_INDUSTRY_H;
00927 /* turn it into steel */
00928 if (rawm > 0 && MP_INFO(x,y).int_2 < (MAX_STEEL_ON_RAIL * 10))
00929 {
00930 if (get_jobs (x, y, ((rawm / 2) / JOBS_MAKE_STEEL) + 1) != 0)
00931 {
00932 steel = (rawm) / ORE_MAKE_STEEL;
00933 MP_POL(x,y) += INDUSTRY_H_POLLUTION / 2;
00934 }
00935 else if (get_jobs (x, y, ((rawm / 4) / JOBS_MAKE_STEEL) + 1) != 0)
00936 {
00937 steel = (rawm / 2) / ORE_MAKE_STEEL;
00938 MP_POL(x,y) += INDUSTRY_H_POLLUTION / 4;
00939 }
00940 else if (get_jobs (x, y, ((rawm / 10) / JOBS_MAKE_STEEL) + 1) != 0)
00941 {
00942 steel = (rawm / 5) / ORE_MAKE_STEEL;
00943 MP_POL(x,y) += INDUSTRY_H_POLLUTION / 10;
00944 }
00945 }
00946 /* do this here rather than later 'cos maybe steel/=5 */
00947 MP_INFO(x,y).int_3 -= steel * ORE_MAKE_STEEL;
00948 ore_used += steel * ORE_MAKE_STEEL;
00949 /* check there was enough electricity, or back up to 1/10 of the
00950 production. ie same work and material useage for less production.
00951 If no real power, see if we have enough coal to generate electricity.
00952 */
00953 if (get_power (x, y, steel * POWER_MAKE_STEEL, 1) == 0)
00954 {
00955 if (MP_INFO(x,y).int_4 < (steel * 2))
00956 {
00957 MP_INFO(x,y).flags &= (0xffffffff - FLAG_POWERED);
00958 steel /= 5;
00959 }
00960 else
00961 {
00962 MP_INFO(x,y).int_4 -= (steel * 2);
00963 coal_used += (steel * 2);
00964 MP_INFO(x,y).flags |= FLAG_POWERED;
00965 MP_INFO(x,y).int_7 = 1;
00966 }
00967 }
00968 else
00969 {
00970 MP_INFO(x,y).flags |= FLAG_POWERED;
00971 MP_INFO(x,y).int_7 = 0;
00972 }
00973 MP_INFO(x,y).int_1 += steel;
00974 MP_INFO(x,y).int_2 += steel;
00975 /* now sell the steel to the road/rail */
00976 if (MP_GROUP(x,y-1) == GROUP_ROAD
00977 && (MAX_STEEL_ON_ROAD - MP_INFO(x,y - 1).int_6)
00978 <= MP_INFO(x,y).int_2)
00979 {
00980 MP_INFO(x,y).int_2 -= (MAX_STEEL_ON_ROAD
00981 - MP_INFO(x,y - 1).int_6);
00982 MP_INFO(x,y - 1).int_6 = MAX_STEEL_ON_ROAD;
00983 }
00984 else if (MP_GROUP(x,y - 1) == GROUP_RAIL
00985 && (MAX_STEEL_ON_RAIL - MP_INFO(x,y - 1).int_6)
00986 <= MP_INFO(x,y).int_2)
00987 {
00988 MP_INFO(x,y).int_2 -= (MAX_STEEL_ON_RAIL
00989 - MP_INFO(x,y - 1).int_6);
00990 MP_INFO(x,y - 1).int_6 = MAX_STEEL_ON_RAIL;
00991 }
00992 else if (MP_GROUP(x,y-1) == GROUP_TRACK
00993 && (MAX_STEEL_ON_TRACK - MP_INFO(x,y - 1).int_6)
00994 <= MP_INFO(x,y).int_2)
00995 {
00996 MP_INFO(x,y).int_2 -= (MAX_STEEL_ON_TRACK
00997 - MP_INFO(x,y - 1).int_6);
00998 MP_INFO(x,y - 1).int_6 = MAX_STEEL_ON_TRACK;
00999 }
01000
01001 if (MP_GROUP(x-1,y) == GROUP_ROAD
01002 && (MAX_STEEL_ON_ROAD - MP_INFO(x - 1,y).int_6)
01003 <= MP_INFO(x,y).int_2)
01004 {
01005 MP_INFO(x,y).int_2 -= (MAX_STEEL_ON_ROAD
01006 - MP_INFO(x - 1,y).int_6);
01007 MP_INFO(x - 1,y).int_6 = MAX_STEEL_ON_ROAD;
01008 }
01009 else if (MP_GROUP(x-1,y) == GROUP_RAIL
01010 && (MAX_STEEL_ON_RAIL - MP_INFO(x - 1,y).int_6)
01011 <= MP_INFO(x,y).int_2)
01012 {
01013 MP_INFO(x,y).int_2 -= (MAX_STEEL_ON_RAIL
01014 - MP_INFO(x - 1,y).int_6);
01015 MP_INFO(x - 1,y).int_6 = MAX_STEEL_ON_RAIL;
01016 }
01017 else if (MP_GROUP(x - 1,y) == GROUP_TRACK
01018 && (MAX_STEEL_ON_TRACK - MP_INFO(x - 1,y).int_6)
01019 <= MP_INFO(x,y).int_2)
01020 {
01021 MP_INFO(x,y).int_2 -= (MAX_STEEL_ON_TRACK
01022 - MP_INFO(x - 1,y).int_6);
01023 MP_INFO(x - 1,y).int_6 = MAX_STEEL_ON_TRACK;
01024 }
01025
01026
01027 /* now choose a graphic every month */
01028 if ((total_time % NUMOF_DAYS_IN_MONTH) == NUMOF_DAYS_IN_MONTH - 1)
01029 {
01030 MP_INFO(x,y).int_5 = MP_INFO(x,y).int_1
01031 / (MAX_MADE_AT_INDUSTRY_H / ORE_MAKE_STEEL);
01032 MP_INFO(x,y).int_1 = 0;
01033 if (MP_INFO(x,y).int_5 > 80)
01034 {
01035 switch (MP_TYPE(x,y))
01036 {
01037 case (CST_INDUSTRY_H_H1):
01038 case (CST_INDUSTRY_H_H2):
01039 case (CST_INDUSTRY_H_H3):
01040 case (CST_INDUSTRY_H_H4):
01041 case (CST_INDUSTRY_H_H5):
01042 case (CST_INDUSTRY_H_H6):
01043 case (CST_INDUSTRY_H_H7):
01044 case (CST_INDUSTRY_H_H8):
01045 break;
01046 default:
01047 MP_TYPE(x,y) = CST_INDUSTRY_H_H1;
01048 }
01049 }
01050 else if (MP_INFO(x,y).int_5 > 30)
01051 {
01052 switch (MP_TYPE(x,y))
01053 {
01054 case (CST_INDUSTRY_H_M1):
01055 case (CST_INDUSTRY_H_M2):
01056 case (CST_INDUSTRY_H_M3):
01057 case (CST_INDUSTRY_H_M4):
01058 case (CST_INDUSTRY_H_M5):
01059 case (CST_INDUSTRY_H_M6):
01060 case (CST_INDUSTRY_H_M7):
01061 case (CST_INDUSTRY_H_M8):
01062 break;
01063 default:
01064 MP_TYPE(x,y) = CST_INDUSTRY_H_M1;
01065 }
01066 }
01067 else if (MP_INFO(x,y).int_5 > 0)
01068 {
01069 switch (MP_TYPE(x,y))
01070 {
01071 case (CST_INDUSTRY_H_L1):
01072 case (CST_INDUSTRY_H_L2):
01073 case (CST_INDUSTRY_H_L3):
01074 case (CST_INDUSTRY_H_L4):
01075 case (CST_INDUSTRY_H_L5):
01076 case (CST_INDUSTRY_H_L6):
01077 case (CST_INDUSTRY_H_L7):
01078 case (CST_INDUSTRY_H_L8):
01079 break;
01080 default:
01081 MP_TYPE(x,y) = CST_INDUSTRY_H_L1;
01082 }
01083 }
01084 else
01085 MP_TYPE(x,y) = CST_INDUSTRY_H_C;
01086 }
01087 /* now animate */
01088 if (real_time >= MP_INFO(x,y).int_6)
01089 {
01090 MP_INFO(x,y).int_6 = real_time + INDUSTRY_H_ANIM_SPEED;
01091 switch (MP_TYPE(x,y))
01092 {
01093 case (CST_INDUSTRY_H_L1):
01094 MP_TYPE(x,y) = CST_INDUSTRY_H_L2;
01095 break;
01096 case (CST_INDUSTRY_H_L2):
01097 MP_TYPE(x,y) = CST_INDUSTRY_H_L3;
01098 break;
01099 case (CST_INDUSTRY_H_L3):
01100 MP_TYPE(x,y) = CST_INDUSTRY_H_L4;
01101 break;
01102 case (CST_INDUSTRY_H_L4):
01103 MP_TYPE(x,y) = CST_INDUSTRY_H_L5;
01104 break;
01105 case (CST_INDUSTRY_H_L5):
01106 MP_TYPE(x,y) = CST_INDUSTRY_H_L6;
01107 break;
01108 case (CST_INDUSTRY_H_L6):
01109 MP_TYPE(x,y) = CST_INDUSTRY_H_L7;
01110 break;
01111 case (CST_INDUSTRY_H_L7):
01112 MP_TYPE(x,y) = CST_INDUSTRY_H_L8;
01113 break;
01114 case (CST_INDUSTRY_H_L8):
01115 MP_TYPE(x,y) = CST_INDUSTRY_H_L1;
01116 break;
01117
01118 case (CST_INDUSTRY_H_M1):
01119 MP_TYPE(x,y) = CST_INDUSTRY_H_M2;
01120 break;
01121 case (CST_INDUSTRY_H_M2):
01122 MP_TYPE(x,y) = CST_INDUSTRY_H_M3;
01123 break;
01124 case (CST_INDUSTRY_H_M3):
01125 MP_TYPE(x,y) = CST_INDUSTRY_H_M4;
01126 break;
01127 case (CST_INDUSTRY_H_M4):
01128 MP_TYPE(x,y) = CST_INDUSTRY_H_M5;
01129 break;
01130 case (CST_INDUSTRY_H_M5):
01131 MP_TYPE(x,y) = CST_INDUSTRY_H_M6;
01132 break;
01133 case (CST_INDUSTRY_H_M6):
01134 MP_TYPE(x,y) = CST_INDUSTRY_H_M7;
01135 break;
01136 case (CST_INDUSTRY_H_M7):
01137 MP_TYPE(x,y) = CST_INDUSTRY_H_M8;
01138 break;
01139 case (CST_INDUSTRY_H_M8):
01140 MP_TYPE(x,y) = CST_INDUSTRY_H_M1;
01141 break;
01142
01143 case (CST_INDUSTRY_H_H1):
01144 MP_TYPE(x,y) = CST_INDUSTRY_H_H2;
01145 break;
01146 case (CST_INDUSTRY_H_H2):
01147 MP_TYPE(x,y) = CST_INDUSTRY_H_H3;
01148 break;
01149 case (CST_INDUSTRY_H_H3):
01150 MP_TYPE(x,y) = CST_INDUSTRY_H_H4;
01151 break;
01152 case (CST_INDUSTRY_H_H4):
01153 MP_TYPE(x,y) = CST_INDUSTRY_H_H5;
01154 break;
01155 case (CST_INDUSTRY_H_H5):
01156 MP_TYPE(x,y) = CST_INDUSTRY_H_H6;
01157 break;
01158 case (CST_INDUSTRY_H_H6):
01159 MP_TYPE(x,y) = CST_INDUSTRY_H_H7;
01160 break;
01161 case (CST_INDUSTRY_H_H7):
01162 MP_TYPE(x,y) = CST_INDUSTRY_H_H8;
01163 break;
01164 case (CST_INDUSTRY_H_H8):
01165 MP_TYPE(x,y) = CST_INDUSTRY_H_H1;
01166 break;
01167
01168 }
01169 }
01170 }
|
|
||||||||||||
|
Definition at line 559 of file engine.c. 00560 {
00561 int goods = 0;
00562 /*
00563 // int_1 is the goods produced this month so far
00564 // int_2 is the amount of goods in store.
00565 // int_3 is the amount of ore in store.
00566 // int_4 is the amount of steel in store.
00567 // int_5 is the jobs stored.
00568 // int_6 is the percent of capacity last month.
00569 // int 7 is the next animation frame time.
00570 */
00571 /* first get some jobs */
00572 if (MP_INFO(x,y).int_5 < MAX_JOBS_AT_INDUSTRY_L - INDUSTRY_L_GET_JOBS)
00573 {
00574 if (get_jobs (x, y, INDUSTRY_L_GET_JOBS) != 0)
00575 MP_INFO(x,y).int_5 += INDUSTRY_L_GET_JOBS;
00576 else if (get_jobs (x, y, INDUSTRY_L_GET_JOBS / 10) != 0)
00577 MP_INFO(x,y).int_5 += INDUSTRY_L_GET_JOBS / 10;
00578 }
00579 /* if we don't have enough jobs we can't do anything */
00580 if (MP_INFO(x,y).int_5 < MIN_JOBS_AT_INDUSTRY_L)
00581 return;
00582 /* get some ore */
00583 if (MP_INFO(x,y).int_3 < (MAX_ORE_AT_INDUSTRY_L
00584 - INDUSTRY_L_GET_ORE))
00585 {
00586 if ((MP_INFO(x - 1,y).flags & FLAG_IS_TRANSPORT) != 0
00587 && MP_INFO(x - 1,y).int_5 > 0)
00588 {
00589 if (MP_INFO(x - 1,y).int_5 >= INDUSTRY_L_GET_ORE)
00590 {
00591 MP_INFO(x,y).int_3 += INDUSTRY_L_GET_ORE;
00592 MP_INFO(x - 1,y).int_5 -= INDUSTRY_L_GET_ORE;
00593 }
00594 else
00595 {
00596 MP_INFO(x,y).int_3 += MP_INFO(x - 1,y).int_5;
00597 MP_INFO(x - 1,y).int_5 = 0;
00598 }
00599 MP_INFO(x,y).int_5 -= INDUSTRY_L_JOBS_LOAD_ORE;
00600 }
00601 }
00602 /* do we still need some ore? */
00603 if (MP_INFO(x,y).int_3 < (MAX_ORE_AT_INDUSTRY_L
00604 - INDUSTRY_L_GET_ORE))
00605 {
00606 if ((MP_INFO(x,y - 1).flags & FLAG_IS_TRANSPORT) != 0
00607 && MP_INFO(x,y - 1).int_5 > 0)
00608 {
00609 if (MP_INFO(x,y - 1).int_5 >= INDUSTRY_L_GET_ORE)
00610 {
00611 MP_INFO(x,y).int_3 += INDUSTRY_L_GET_ORE;
00612 MP_INFO(x,y - 1).int_5 -= INDUSTRY_L_GET_ORE;
00613 }
00614 else
00615 {
00616 MP_INFO(x,y).int_3 += MP_INFO(x,y - 1).int_5;
00617 MP_INFO(x,y - 1).int_5 = 0;
00618 }
00619 MP_INFO(x,y).int_5 -= INDUSTRY_L_JOBS_LOAD_ORE;
00620 }
00621 }
00622 /* then get some steel */
00623 if (MP_INFO(x,y).int_4 < (MAX_STEEL_AT_INDUSTRY_L
00624 - INDUSTRY_L_GET_STEEL))
00625 {
00626 if ((MP_INFO(x - 1,y).flags & FLAG_IS_TRANSPORT) != 0
00627 && MP_INFO(x - 1,y).int_6 > 0)
00628 {
00629 if (MP_INFO(x - 1,y).int_6 >= INDUSTRY_L_GET_STEEL)
00630 {
00631 MP_INFO(x,y).int_4 += INDUSTRY_L_GET_STEEL;
00632 MP_INFO(x - 1,y).int_6 -= INDUSTRY_L_GET_STEEL;
00633 }
00634 else
00635 {
00636 MP_INFO(x,y).int_4
00637 += MP_INFO(x - 1,y).int_6;
00638 MP_INFO(x - 1,y).int_6 = 0;
00639 }
00640 MP_INFO(x,y).int_5 -= INDUSTRY_L_JOBS_LOAD_STEEL;
00641 }
00642 }
00643 /* do we still need some steel? */
00644 if (MP_INFO(x,y).int_4 < (MAX_STEEL_AT_INDUSTRY_L
00645 - INDUSTRY_L_GET_STEEL))
00646 {
00647 if ((MP_INFO(x,y - 1).flags & FLAG_IS_TRANSPORT) != 0
00648 && MP_INFO(x,y - 1).int_6 > 0)
00649 {
00650 if (MP_INFO(x,y - 1).int_6 >= INDUSTRY_L_GET_STEEL)
00651 {
00652 MP_INFO(x,y).int_4 += INDUSTRY_L_GET_STEEL;
00653 MP_INFO(x,y - 1).int_6 -= INDUSTRY_L_GET_STEEL;
00654 }
00655 else
00656 {
00657 MP_INFO(x,y).int_4
00658 += MP_INFO(x,y - 1).int_6;
00659 MP_INFO(x,y - 1).int_6 = 0;
00660 }
00661 MP_INFO(x,y).int_5 -= INDUSTRY_L_JOBS_LOAD_STEEL;
00662 }
00663 }
00664 /* now make some goods */
00665 if (MP_INFO(x,y).int_2 < (MAX_GOODS_AT_INDUSTRY_L
00666 - (INDUSTRY_L_MAKE_GOODS * 8)) && MP_INFO(x,y).int_3
00667 >= INDUSTRY_L_ORE_USED)
00668 {
00669 goods += INDUSTRY_L_MAKE_GOODS;
00670 MP_INFO(x,y).int_3 -= INDUSTRY_L_ORE_USED;
00671 ore_used += INDUSTRY_L_ORE_USED;
00672 MP_INFO(x,y).int_5 -= INDUSTRY_L_JOBS_USED;
00673 MP_POL(x,y) += INDUSTRY_L_POLLUTION;
00674
00675 /* multiply by 2 if we have steel. */
00676 if (MP_INFO(x,y).int_4 >= INDUSTRY_L_STEEL_USED)
00677 {
00678 MP_INFO(x,y).int_4 -= INDUSTRY_L_STEEL_USED;
00679 goods += goods;
00680 }
00681 /* multipy by 4 if we can get power. */
00682
00683 if (MP_INFO(x,y).int_3 >= INDUSTRY_L_ORE_USED
00684 && get_power (x, y, goods * 10, 1) != 0)
00685 {
00686 goods *= 4;
00687 MP_INFO(x,y).flags |= FLAG_POWERED;
00688 /* and use more ore */
00689 MP_INFO(x,y).int_3 -= INDUSTRY_L_ORE_USED;
00690 ore_used += INDUSTRY_L_ORE_USED;
00691 }
00692 else
00693 MP_INFO(x,y).flags &= (0xffffffff - FLAG_POWERED);
00694 }
00695
00696 MP_INFO(x,y).int_1 += goods;
00697 MP_INFO(x,y).int_2 += goods;
00698 goods_made += goods;
00699
00700 /* now sell the goods to the road/rail/track */
00701 if (MP_GROUP(x,y - 1) == GROUP_ROAD
00702 && (MAX_GOODS_ON_ROAD - MP_INFO(x,y - 1).int_4) <= MP_INFO(x,y).int_2)
00703 {
00704 MP_INFO(x,y).int_2 -= (MAX_GOODS_ON_ROAD - MP_INFO(x,y - 1).int_4);
00705 MP_INFO(x,y - 1).int_4 = MAX_GOODS_ON_ROAD;
00706 }
00707 else if (MP_GROUP(x,y - 1) == GROUP_RAIL
00708 && (MAX_GOODS_ON_RAIL - MP_INFO(x,y - 1).int_4)
00709 <= MP_INFO(x,y).int_2)
00710 {
00711 MP_INFO(x,y).int_2 -= (MAX_GOODS_ON_RAIL
00712 - MP_INFO(x,y - 1).int_4);
00713 MP_INFO(x,y - 1).int_4 = MAX_GOODS_ON_RAIL;
00714 }
00715 else if (MP_GROUP(x,y - 1) == GROUP_TRACK
00716 && (MAX_GOODS_ON_TRACK - MP_INFO(x,y - 1).int_4)
00717 <= MP_INFO(x,y).int_2)
00718 {
00719 MP_INFO(x,y).int_2 -= (MAX_GOODS_ON_TRACK
00720 - MP_INFO(x,y - 1).int_4);
00721 MP_INFO(x,y - 1).int_4 = MAX_GOODS_ON_TRACK;
00722 }
00723
00724
00725 if (MP_GROUP(x - 1,y) == GROUP_ROAD
00726 && (MAX_GOODS_ON_ROAD - MP_INFO(x - 1,y).int_4)
00727 <= MP_INFO(x,y).int_2)
00728 {
00729 MP_INFO(x,y).int_2 -= (MAX_GOODS_ON_ROAD
00730 - MP_INFO(x - 1,y).int_4);
00731 MP_INFO(x - 1,y).int_4 = MAX_GOODS_ON_ROAD;
00732 }
00733 else if (MP_GROUP(x - 1,y) == GROUP_RAIL
00734 && (MAX_GOODS_ON_RAIL - MP_INFO(x - 1,y).int_4)
00735 <= MP_INFO(x,y).int_2)
00736 {
00737 MP_INFO(x,y).int_2 -= (MAX_GOODS_ON_RAIL
00738 - MP_INFO(x - 1,y).int_4);
00739 MP_INFO(x - 1,y).int_4 = MAX_GOODS_ON_RAIL;
00740 }
00741 else if (MP_GROUP(x-1,y) == GROUP_TRACK
00742 && (MAX_GOODS_ON_TRACK - MP_INFO(x - 1,y).int_4)
00743 <= MP_INFO(x,y).int_2)
00744 {
00745 MP_INFO(x,y).int_2 -= (MAX_GOODS_ON_TRACK
00746 - MP_INFO(x - 1,y).int_4);
00747 MP_INFO(x - 1,y).int_4 = MAX_GOODS_ON_TRACK;
00748 }
00749
00750 /* now choose a graphic every month */
00751 if ((total_time % NUMOF_DAYS_IN_MONTH) == NUMOF_DAYS_IN_MONTH - 1)
00752 {
00753 MP_INFO(x,y).int_6 = (MP_INFO(x,y).int_1)
00754 / (INDUSTRY_L_MAKE_GOODS * 8);
00755 MP_INFO(x,y).int_1 = 0;
00756 if (MP_INFO(x,y).int_6 > 80)
00757 {
00758 switch (MP_TYPE(x,y))
00759 {
00760 case (CST_INDUSTRY_L_H1):
00761 case (CST_INDUSTRY_L_H2):
00762 case (CST_INDUSTRY_L_H3):
00763 case (CST_INDUSTRY_L_H4):
00764 break;
00765 default:
00766 MP_TYPE(x,y) = CST_INDUSTRY_L_H1;
00767 }
00768 }
00769 else if (MP_INFO(x,y).int_6 > 55)
00770 {
00771 switch (MP_TYPE(x,y))
00772 {
00773 case (CST_INDUSTRY_L_M1):
00774 case (CST_INDUSTRY_L_M2):
00775 case (CST_INDUSTRY_L_M3):
00776 case (CST_INDUSTRY_L_M4):
00777 break;
00778 default:
00779 MP_TYPE(x,y) = CST_INDUSTRY_L_M1;
00780 }
00781 }
00782 else if (MP_INFO(x,y).int_6 > 25)
00783 {
00784 switch (MP_TYPE(x,y))
00785 {
00786 case (CST_INDUSTRY_L_L1):
00787 case (CST_INDUSTRY_L_L2):
00788 case (CST_INDUSTRY_L_L3):
00789 case (CST_INDUSTRY_L_L4):
00790 break;
00791 default:
00792 MP_TYPE(x,y) = CST_INDUSTRY_L_L1;
00793 }
00794 }
00795 else if (MP_INFO(x,y).int_6 > 0)
00796 {
00797 switch (MP_TYPE(x,y))
00798 {
00799 case (CST_INDUSTRY_L_Q1):
00800 case (CST_INDUSTRY_L_Q2):
00801 case (CST_INDUSTRY_L_Q3):
00802 case (CST_INDUSTRY_L_Q4):
00803 break;
00804 default:
00805 MP_TYPE(x,y) = CST_INDUSTRY_L_Q1;
00806 }
00807 }
00808 else
00809 MP_TYPE(x,y) = CST_INDUSTRY_L_C;
00810 }
00811 /* now animate */
00812 if (real_time >= MP_INFO(x,y).int_7)
00813 {
00814 MP_INFO(x,y).int_7 = real_time + INDUSTRY_L_ANIM_SPEED;
00815 switch (MP_TYPE(x,y))
00816 {
00817 case (CST_INDUSTRY_L_Q1):
00818 MP_TYPE(x,y) = CST_INDUSTRY_L_Q2;
00819 break;
00820 case (CST_INDUSTRY_L_Q2):
00821 MP_TYPE(x,y) = CST_INDUSTRY_L_Q3;
00822 break;
00823 case (CST_INDUSTRY_L_Q3):
00824 MP_TYPE(x,y) = CST_INDUSTRY_L_Q4;
00825 break;
00826 case (CST_INDUSTRY_L_Q4):
00827 MP_TYPE(x,y) = CST_INDUSTRY_L_Q1;
00828 break;
00829 case (CST_INDUSTRY_L_L1):
00830 MP_TYPE(x,y) = CST_INDUSTRY_L_L2;
00831 break;
00832 case (CST_INDUSTRY_L_L2):
00833 MP_TYPE(x,y) = CST_INDUSTRY_L_L3;
00834 break;
00835 case (CST_INDUSTRY_L_L3):
00836 MP_TYPE(x,y) = CST_INDUSTRY_L_L4;
00837 break;
00838 case (CST_INDUSTRY_L_L4):
00839 MP_TYPE(x,y) = CST_INDUSTRY_L_L1;
00840 break;
00841 case (CST_INDUSTRY_L_M1):
00842 MP_TYPE(x,y) = CST_INDUSTRY_L_M2;
00843 break;
00844 case (CST_INDUSTRY_L_M2):
00845 MP_TYPE(x,y) = CST_INDUSTRY_L_M3;
00846 break;
00847 case (CST_INDUSTRY_L_M3):
00848 MP_TYPE(x,y) = CST_INDUSTRY_L_M4;
00849 break;
00850 case (CST_INDUSTRY_L_M4):
00851 MP_TYPE(x,y) = CST_INDUSTRY_L_M1;
00852 break;
00853 case (CST_INDUSTRY_L_H1):
00854 MP_TYPE(x,y) = CST_INDUSTRY_L_H2;
00855 break;
00856 case (CST_INDUSTRY_L_H2):
00857 MP_TYPE(x,y) = CST_INDUSTRY_L_H3;
00858 break;
00859 case (CST_INDUSTRY_L_H3):
00860 MP_TYPE(x,y) = CST_INDUSTRY_L_H4;
00861 break;
00862 case (CST_INDUSTRY_L_H4):
00863 MP_TYPE(x,y) = CST_INDUSTRY_L_H1;
00864 break;
00865 }
00866 }
00867 }
|
|
||||||||||||
|
Definition at line 2807 of file engine.c. 02808 {
02809 /*
02810 // int_1 contains the goods at the mill
02811 // int_2 contains the food store
02812 // int_3 contains the coal store
02813 // int_4 contains the animation trigger time
02814 // int_5 is the % count so far this month
02815 // int_6 is the % capacity last month
02816 */
02817 /* get food */
02818 int block_anim = 0;
02819 if (MP_INFO(x,y).int_2 < MAX_FOOD_AT_MILL)
02820 if (get_food (x, y, MILL_GET_FOOD) != 0)
02821 MP_INFO(x,y).int_2 += MILL_GET_FOOD;
02822 /* get coal */
02823 if (MP_INFO(x,y).int_3 < MAX_COAL_AT_MILL)
02824 {
02825 if (get_coal (x, y, MILL_GET_COAL) != 0)
02826 MP_INFO(x,y).int_3 += MILL_GET_COAL;
02827 else if (get_power (x, y, MILL_GET_COAL
02828 * MILL_POWER_PER_COAL, 0) != 0)
02829 MP_INFO(x,y).int_3 += MILL_GET_COAL;
02830 }
02831 if (MP_INFO(x,y).int_1 < MAX_GOODS_AT_MILL)
02832 {
02833 if (MP_INFO(x,y).int_2 > FOOD_USED_BY_MILL
02834 && MP_INFO(x,y).int_3 > COAL_USED_BY_MILL)
02835 {
02836 if (get_jobs (x, y, MILL_JOBS) != 0)
02837 {
02838 MP_INFO(x,y).int_2 -= FOOD_USED_BY_MILL;
02839 MP_INFO(x,y).int_3 -= COAL_USED_BY_MILL;
02840 MP_INFO(x,y).int_1 += GOODS_MADE_BY_MILL;
02841 MP_INFO(x,y).int_5++;
02842 }
02843 else
02844 {
02845 MP_TYPE(x,y) = CST_MILL_0;
02846 block_anim = 1;
02847 }
02848 }
02849 else
02850 block_anim = 1;
02851 }
02852
02853 if (MP_INFO(x,y).int_1 > 0)
02854 if (put_goods (x, y, MP_INFO(x,y).int_1) != 0)
02855 MP_INFO(x,y).int_1 = 0;
02856
02857 if (total_time % 100 == 0)
02858 {
02859 MP_INFO(x,y).int_6 = MP_INFO(x,y).int_5;
02860 MP_INFO(x,y).int_5 = 0;
02861 }
02862 if (real_time >= MP_INFO(x,y).int_4 && block_anim == 0)
02863 {
02864 MP_INFO(x,y).int_4 = real_time + MILL_ANIM_SPEED;
02865 switch (MP_TYPE(x,y))
02866 {
02867 case (CST_MILL_0):
02868 MP_TYPE(x,y) = CST_MILL_1;
02869 break;
02870 case (CST_MILL_1):
02871 MP_TYPE(x,y) = CST_MILL_2;
02872 break;
02873 case (CST_MILL_2):
02874 MP_TYPE(x,y) = CST_MILL_3;
02875 break;
02876 case (CST_MILL_3):
02877 MP_TYPE(x,y) = CST_MILL_4;
02878 break;
02879 case (CST_MILL_4):
02880 MP_TYPE(x,y) = CST_MILL_5;
02881 break;
02882 case (CST_MILL_5):
02883 MP_TYPE(x,y) = CST_MILL_6;
02884 break;
02885 case (CST_MILL_6):
02886 MP_TYPE(x,y) = CST_MILL_1;
02887 MP_POL(x,y)++;
02888 break;
02889 }
02890 }
02891 }
|
|
||||||||||||
|
Definition at line 2654 of file engine.c. 02655 {
02656 /*
02657 // int_1 holds the jobs used
02658 // int_2 holds the tech points made
02659 // int_3 holds the tail off count
02660 */
02661 if (MP_INFO(x,y).int_1 < BUILD_MONUMENT_JOBS)
02662 if (get_jobs (x, y, MONUMENT_GET_JOBS) != 0)
02663 MP_INFO(x,y).int_1 += MONUMENT_GET_JOBS;
02664
02665 /* now choose a graphic */
02666 if (MP_INFO(x,y).int_1 >= BUILD_MONUMENT_JOBS)
02667 {
02668 MP_TYPE(x,y) = CST_MONUMENT_5;
02669 /* inc tech level only if fully built and tech less
02670 than MONUMENT_TECH_EXPIRE */
02671 if (tech_level < (MONUMENT_TECH_EXPIRE * 1000)
02672 && (total_time % MONUMENT_DAYS_PER_TECH) == 1)
02673 {
02674 if (MP_INFO(x,y).int_3++ > (tech_level / 10000) - 2)
02675 {
02676 tech_level++;
02677 MP_INFO(x,y).int_2++;
02678 MP_INFO(x,y).int_3 = 0;
02679 }
02680 }
02681 }
02682 else if (MP_INFO(x,y).int_1 >= ((BUILD_MONUMENT_JOBS * 4) / 5))
02683 MP_TYPE(x,y) = CST_MONUMENT_4;
02684 else if (MP_INFO(x,y).int_1 >= ((BUILD_MONUMENT_JOBS * 3) / 5))
02685 MP_TYPE(x,y) = CST_MONUMENT_3;
02686 else if (MP_INFO(x,y).int_1 >= ((BUILD_MONUMENT_JOBS * 2) / 5))
02687 MP_TYPE(x,y) = CST_MONUMENT_2;
02688 else if (MP_INFO(x,y).int_1 >= (BUILD_MONUMENT_JOBS / 20))
02689 MP_TYPE(x,y) = CST_MONUMENT_1;
02690 else
02691 MP_TYPE(x,y) = CST_MONUMENT_0;
02692 }
|
|
||||||||||||
|
Definition at line 1510 of file engine.c. 01511 {
01512 /*
01513 // int_1 is the ore at in stock
01514 // int_2 is the ore reserve under the ground or at the surface really.
01515 */
01516 int xx, yy, xs, ys, xe, ye, cr;
01517 if (MP_INFO(x,y).int_1 < DIG_MORE_ORE_TRIGGER - 5000)
01518 {
01519 xs = x;
01520 ys = y;
01521 xe = x + 4;
01522 ye = y + 4;
01523 cr = 0;
01524 for (yy = ys; yy < ye; yy++)
01525 for (xx = xs; xx < xe; xx++)
01526 cr += MP_INFO(xx,yy).ore_reserve;
01527 MP_INFO(x,y).int_2 = cr;
01528 if (cr > 0)
01529 if (get_jobs (x, y, JOBS_DIG_ORE) != 0)
01530 for (yy = ys; yy < ye; yy++)
01531 for (xx = xs; xx < xe; xx++)
01532 if (MP_INFO(xx,yy).ore_reserve > 0)
01533 {
01534 MP_INFO(xx,yy).ore_reserve--;
01535 MP_INFO(x,y).int_1 += 5000;
01536 ore_made += 5000;
01537 sust_dig_ore_coal_tip_flag = 0;
01538 /* maybe want an ore tax? */
01539 yy = ye;
01540 xx = xe; /* break out */
01541 }
01542 }
01543
01544 if ((MP_INFO(x - 1,y).flags & FLAG_IS_TRANSPORT) != 0)
01545 {
01546 if (MP_GROUP(x-1,y) == GROUP_RAIL
01547 && MP_INFO(x - 1,y).int_5 < MAX_ORE_ON_RAIL
01548 && MP_INFO(x,y).int_1 >= (MAX_ORE_ON_RAIL
01549 - MP_INFO(x - 1,y).int_5))
01550 {
01551 if (get_jobs (x, y, JOBS_LOAD_ORE) != 0)
01552 {
01553 MP_INFO(x,y).int_1
01554 -= (MAX_ORE_ON_RAIL - MP_INFO(x - 1,y).int_5);
01555 MP_INFO(x - 1,y).int_5 = MAX_ORE_ON_RAIL;
01556 }
01557 }
01558 else if (MP_GROUP(x-1,y) == GROUP_ROAD
01559 && MP_INFO(x - 1,y).int_5 < MAX_ORE_ON_ROAD
01560 && MP_INFO(x,y).int_1 >= (MAX_ORE_ON_ROAD
01561 - MP_INFO(x - 1,y).int_5))
01562 {
01563 if (get_jobs (x, y, JOBS_LOAD_ORE) != 0)
01564 {
01565 MP_INFO(x,y).int_1
01566 -= (MAX_ORE_ON_ROAD - MP_INFO(x - 1,y).int_5);
01567 MP_INFO(x - 1,y).int_5 = MAX_ORE_ON_ROAD;
01568 }
01569 }
01570 else if (MP_GROUP(x - 1,y) == GROUP_TRACK
01571 && MP_INFO(x - 1,y).int_5 < MAX_ORE_ON_TRACK
01572 && MP_INFO(x,y).int_1 >= (MAX_ORE_ON_TRACK
01573 - MP_INFO(x - 1,y).int_5))
01574 {
01575 if (get_jobs (x, y, JOBS_LOAD_ORE) != 0)
01576 {
01577 MP_INFO(x,y).int_1
01578 -= (MAX_ORE_ON_TRACK - MP_INFO(x - 1,y).int_5);
01579 MP_INFO(x - 1,y).int_5 = MAX_ORE_ON_TRACK;
01580 }
01581 }
01582 }
01583
01584 if ((MP_INFO(x,y - 1).flags & FLAG_IS_TRANSPORT) != 0)
01585 {
01586 if (MP_GROUP(x,y-1) == GROUP_RAIL
01587 && MP_INFO(x,y - 1).int_5 < MAX_ORE_ON_RAIL
01588 && MP_INFO(x,y).int_1 >= (MAX_ORE_ON_RAIL
01589 - MP_INFO(x,y - 1).int_5))
01590 {
01591 if (get_jobs (x, y, JOBS_LOAD_ORE) != 0)
01592 {
01593 MP_INFO(x,y).int_1
01594 -= (MAX_ORE_ON_RAIL - MP_INFO(x,y - 1).int_5);
01595 MP_INFO(x,y - 1).int_5 = MAX_ORE_ON_RAIL;
01596 }
01597 }
01598 else if (MP_GROUP(x,y-1) == GROUP_ROAD
01599 && MP_INFO(x,y - 1).int_5 < MAX_ORE_ON_ROAD
01600 && MP_INFO(x,y).int_1 >= (MAX_ORE_ON_ROAD
01601 - MP_INFO(x,y - 1).int_5))
01602 {
01603 if (get_jobs (x, y, JOBS_LOAD_ORE) != 0)
01604 {
01605 MP_INFO(x,y).int_1
01606 -= (MAX_ORE_ON_ROAD - MP_INFO(x,y - 1).int_5);
01607 MP_INFO(x,y - 1).int_5 = MAX_ORE_ON_ROAD;
01608 }
01609 }
01610 else if (MP_GROUP(x,y-1) == GROUP_TRACK
01611 && MP_INFO(x,y - 1).int_5 < MAX_ORE_ON_TRACK
01612 && MP_INFO(x,y).int_1 >= (MAX_ORE_ON_TRACK
01613 - MP_INFO(x,y - 1).int_5))
01614 {
01615 if (get_jobs (x, y, JOBS_LOAD_ORE) != 0)
01616 {
01617 MP_INFO(x,y).int_1
01618 -= (MAX_ORE_ON_TRACK - MP_INFO(x,y - 1).int_5);
01619 MP_INFO(x,y - 1).int_5 = MAX_ORE_ON_TRACK;
01620 }
01621 }
01622 }
01623
01624
01625 /* choose a graphic */
01626 if ((total_time & 0x7f) == 0)
01627 {
01628 xx = 7 * (MP_INFO(x,y).int_2 + (3 * ORE_RESERVE / 2))
01629 / (16 * ORE_RESERVE);
01630 switch (xx)
01631 {
01632 case (0):
01633 MP_TYPE(x,y) = CST_OREMINE_8;
01634 break;
01635 case (1):
01636 MP_TYPE(x,y) = CST_OREMINE_7;
01637 break;
01638 case (2):
01639 MP_TYPE(x,y) = CST_OREMINE_6;
01640 break;
01641 case (3):
01642 MP_TYPE(x,y) = CST_OREMINE_5;
01643 break;
01644 case (4):
01645 MP_TYPE(x,y) = CST_OREMINE_4;
01646 break;
01647 case (5):
01648 MP_TYPE(x,y) = CST_OREMINE_3;
01649 break;
01650 case (6):
01651 MP_TYPE(x,y) = CST_OREMINE_2;
01652 break;
01653 case (7):
01654 MP_TYPE(x,y) = CST_OREMINE_1;
01655 break;
01656 }
01657 if (MP_INFO(x,y).int_2 <= 0) {
01658 #if defined (commentout)
01659 do_bulldoze_area (CST_GREEN, x, y);
01660 place_item(x,y,CST_TIP_0);
01661 #endif
01662 int i,j;
01663 for (j = 0; j < 4; j++) {
01664 for (i = 0; i < 4; i++) {
01665 do_bulldoze_area (CST_WATER, x+i, y+j);
01666 }
01667 }
01668 connect_rivers ();
01669 refresh_main_screen ();
01670 }
01671 }
01672 }
|
|
||||||||||||
|
Definition at line 1176 of file engine.c. 01177 {
01178 /*
01179 // int_1 is the tech level of the farm when built
01180 // int_2 is a flag so we don't create a farm with nearly ripe crops.
01181 // int_3 is the food sold count so far this year.
01182 // int_4 is the food made last year.
01183 // int_5 is the random crop rotation key.
01184 // int_6 is the random month stagger, so they don't all flash at once
01185 // int_7 is the tech-level dependent output of a powered farm with a full
01186 // workforce.
01187 */
01188 int i;
01189 if (MP_INFO(x,y).int_5 == 0) /* this should be done when we create */
01190
01191 { /* the area! */
01192
01193 MP_INFO(x,y).int_5 = (rand () % 4) + 1;
01194 MP_INFO(x,y).int_6 = rand () % 300;
01195 }
01196 MP_INFO(x,y).flags &= (0xffffffff - FLAG_POWERED);
01197 if (get_jobs (x, y, 1) == 0)
01198 put_food (x, y, 30);
01199 else if (get_jobs (x, y, FARM_JOBS_USED) != 0)
01200 {
01201 if (get_power (x, y, ORG_FARM_POWER_REC, 0) != 0)
01202 {
01203 if (put_food (x, y, (ORGANIC_FARM_FOOD_OUTPUT
01204 + MP_INFO(x,y).int_7)) == 0)
01205 put_jobs (x, y, FARM_JOBS_USED);
01206 else
01207 MP_INFO(x,y).int_3++;
01208 MP_INFO(x,y).flags |= FLAG_POWERED;
01209 }
01210 else
01211 {
01212 if (put_food (x, y, (ORGANIC_FARM_FOOD_OUTPUT / 4)) == 0)
01213 put_jobs (x, y, FARM_JOBS_USED);
01214 else
01215 MP_INFO(x,y).int_3++;
01216 }
01217 }
01218 else if (get_jobs (x, y, FARM_JOBS_USED / 4) != 0)
01219 {
01220 if (get_power (x, y, ORG_FARM_POWER_REC, 0) != 0)
01221 {
01222 if (put_food (x, y, (ORGANIC_FARM_FOOD_OUTPUT
01223 + (MP_INFO(x,y).int_7 / 4))) == 0)
01224 put_jobs (x, y, FARM_JOBS_USED / 4);
01225 else
01226 MP_INFO(x,y).int_3++;
01227 MP_INFO(x,y).flags |= FLAG_POWERED;
01228 }
01229 else
01230 {
01231 if (put_food (x, y, (ORGANIC_FARM_FOOD_OUTPUT / (4 * 4))) == 0)
01232 put_jobs (x, y, FARM_JOBS_USED / 4);
01233 else
01234 MP_INFO(x,y).int_3++;
01235 }
01236 }
01237 else
01238 {
01239 if (get_power (x, y, ORG_FARM_POWER_REC, 0) != 0)
01240 {
01241 if (put_food (x, y, (ORGANIC_FARM_FOOD_OUTPUT
01242 + (MP_INFO(x,y).int_7 / 8))) != 0)
01243 MP_INFO(x,y).int_3++;
01244 MP_INFO(x,y).flags |= FLAG_POWERED;
01245 }
01246 else if (put_food (x, y, 30
01247 + (ORGANIC_FARM_FOOD_OUTPUT / (4 * 8))) != 0)
01248 MP_INFO(x,y).int_3++;
01249 }
01250 if ((total_time & 0x7f) == 0)
01251 if ((MP_INFO(x,y).flags & FLAG_POWERED) != 0)
01252 get_waste (x, y, 0x80 * ORG_FARM_WASTE_GET);
01253 if ((total_time % 1200) == 0)
01254 {
01255 MP_INFO(x,y).int_4 = MP_INFO(x,y).int_3;
01256 MP_INFO(x,y).int_3 = 0;
01257 }
01258 i = ((total_time + (MP_INFO(x,y).int_5 * 1200)
01259 + MP_INFO(x,y).int_6) % 4800);
01260 if (i % 300 == 0)
01261 {
01262 i /= 300;
01263 if ( /* MP_INFO(x,y).int_2!=0 && */ MP_INFO(x,y).int_4
01264 > MIN_FOOD_SOLD_FOR_ANIM)
01265 {
01266 if (i % 4 == 0)
01267 {
01268 MP_INFO(x,y).int_6 = rand () % 100;
01269 }
01270 switch (i)
01271 {
01272 case (0):
01273 MP_TYPE(x,y) = CST_FARM_O3;
01274 break;
01275 case (1):
01276 MP_TYPE(x,y) = CST_FARM_O3;
01277 break;
01278 case (2):
01279 MP_TYPE(x,y) = CST_FARM_O3;
01280 break;
01281 case (3):
01282 MP_TYPE(x,y) = CST_FARM_O3;
01283 break;
01284 case (4):
01285 MP_TYPE(x,y) = CST_FARM_O7;
01286 break;
01287 case (5):
01288 MP_TYPE(x,y) = CST_FARM_O7;
01289 break;
01290 case (6):
01291 MP_TYPE(x,y) = CST_FARM_O7;
01292 break;
01293 case (7):
01294 MP_TYPE(x,y) = CST_FARM_O7;
01295 break;
01296 case (8):
01297 MP_TYPE(x,y) = CST_FARM_O11;
01298 break;
01299 case (9):
01300 MP_TYPE(x,y) = CST_FARM_O11;
01301 break;
01302 case (10):
01303 MP_TYPE(x,y) = CST_FARM_O11;
01304 break;
01305 case (11):
01306 MP_TYPE(x,y) = CST_FARM_O11;
01307 break;
01308 case (12):
01309 MP_TYPE(x,y) = CST_FARM_O15;
01310 break;
01311 case (13):
01312 MP_TYPE(x,y) = CST_FARM_O15;
01313 break;
01314 case (14):
01315 MP_TYPE(x,y) = CST_FARM_O15;
01316 break;
01317 case (15):
01318 MP_TYPE(x,y) = CST_FARM_O15;
01319 break;
01320
01321 }
01322 }
01323 else
01324 {
01325 MP_TYPE(x,y) = CST_FARM_O0;
01326 }
01327 }
01328 }
|
|
||||||||||||
|
Definition at line 2215 of file engine.c. 02216 {
02217 if (MP_POL(x,y) > 10 && (total_time & 1) == 0)
02218 MP_POL(x,y) -= 1;
02219 }
|
|
|
Definition at line 2151 of file engine.c. 02152 {
02153 int x, p;
02154 int* pol = &map.pollution[0][0];
02155
02156 /* Kill pollution from top edge of map */
02157 do {
02158 if (*pol > 0)
02159 *pol /= POL_DIV;
02160 } while (++pol < &map.pollution[1][0]);
02161
02162
02163 x= 1;
02164 do
02165 {
02166 /* Kill some pollution from left edge of map */
02167 if (*pol++ > 0)
02168 *(pol-1) /= POL_DIV;
02169 do {
02170 if (*pol > 10) {
02171 p = *pol / 16;
02172 *pol -= p;
02173 switch ( rand() % 11)
02174 { /* prevailing wind is *from* SW ie right down */
02175 case 0:
02176 case 1: /* up */
02177 case 2:
02178 *(pol - 1) += p;
02179 break;
02180 case 3:
02181 case 4: /* right */
02182 case 5:
02183 *(pol + WORLD_SIDE_LEN) += p;
02184 break;
02185 case 6: /* down */
02186 case 7:
02187 *(pol + 1) += p;
02188 break;
02189 case 8: /* left */
02190 case 9:
02191 *(pol - WORLD_SIDE_LEN) += p;
02192 break;
02193 case 10:
02194 *pol += p- 2;
02195 break;
02196 }
02197 }
02198 } while (++pol < &map.pollution[x][WORLD_SIDE_LEN-1]);
02199 /* Kill some pollution from right edge of map */
02200 if (*pol > 0)
02201 *pol /= POL_DIV;
02202 ++x;
02203 }
02204 while (++pol < &map.pollution[WORLD_SIDE_LEN-1][0]);
02205
02206 /* Kill pollution from bottom edge of map */
02207 do {
02208 if (*pol > 0)
02209 *pol /= POL_DIV;
02210 } while (++pol < &map.pollution[WORLD_SIDE_LEN][0]);
02211 }
|
|
||||||||||||
|
Definition at line 1801 of file engine.c. 01802 {
01803 /*
01804 // int_1 is the money made so far this month
01805 // int_2 is the money made last month
01806 // int_3 holds the 'pence/pennies/bits' to add next time round.
01807 // int_4 is the import costs so far this month
01808 // int_5 is the import costs for last month
01809 // Use int_3 to int_7 of (x+1,y) to hold the individual buy values
01810 // (x,y+1) is last month's
01811 // Use int_3 to int_7 of (x+2,y) to hold the individual sell values
01812 // (x,y+2) is last month's
01813 */
01814 int i, et = 0, ic = 0, flags, *b1, *b2, *s1, *s2;
01815 /* left connection first */
01816 flags = MP_INFO(x,y).flags;
01817 if (x > 0 && (MP_INFO(x - 1,y).flags
01818 & FLAG_IS_TRANSPORT) != 0)
01819 {
01820 if ((flags & FLAG_MB_FOOD) != 0)
01821 {
01822 i = buy_food (x - 1, y);
01823 ic += i;
01824 MP_INFO(x + 1,y).int_3 += i;
01825 }
01826 if ((flags & FLAG_MS_FOOD) != 0)
01827 {
01828 i = sell_food (x - 1, y);
01829 et += i;
01830 MP_INFO(x + 2,y).int_3 += i;
01831 }
01832 if ((flags & FLAG_MB_COAL) != 0)
01833 {
01834 i = buy_coal (x - 1, y);
01835 ic += i;
01836 MP_INFO(x + 1,y).int_4 += i;
01837 }
01838 if ((flags & FLAG_MS_COAL) != 0)
01839 {
01840 i = sell_coal (x - 1, y);
01841 et += i;
01842 MP_INFO(x + 2,y).int_4 += i;
01843 }
01844 if ((flags & FLAG_MB_ORE) != 0)
01845 {
01846 i = buy_ore (x - 1, y);
01847 ic += i;
01848 MP_INFO(x + 1,y).int_5 += i;
01849 }
01850 if ((flags & FLAG_MS_ORE) != 0)
01851 {
01852 i = sell_ore (x - 1, y);
01853 et += i;
01854 MP_INFO(x + 2,y).int_5 += i;
01855 }
01856 if ((flags & FLAG_MB_GOODS) != 0)
01857 {
01858 i = buy_goods (x - 1, y);
01859 ic += i;
01860 MP_INFO(x + 1,y).int_6 += i;
01861 }
01862 if ((flags & FLAG_MS_GOODS) != 0)
01863 {
01864 i = sell_goods (x - 1, y);
01865 et += i;
01866 MP_INFO(x + 2,y).int_6 += i;
01867 }
01868 if ((flags & FLAG_MB_STEEL) != 0)
01869 {
01870 i = buy_steel (x - 1, y);
01871 ic += i;
01872 MP_INFO(x + 1,y).int_7 += i;
01873 }
01874 if ((flags & FLAG_MS_STEEL) != 0)
01875 {
01876 i = sell_steel (x - 1, y);
01877 et += i;
01878 MP_INFO(x + 2,y).int_7 += i;
01879 }
01880 }
01881 /* upper gate next */
01882 if (y > 0 && (MP_INFO(x,y - 1).flags
01883 & FLAG_IS_TRANSPORT) != 0)
01884 {
01885 if ((flags & FLAG_MB_FOOD) != 0)
01886 {
01887 i = buy_food (x, y - 1);
01888 ic += i;
01889 MP_INFO(x + 1,y).int_3 += i;
01890 }
01891 if ((flags & FLAG_MS_FOOD) != 0)
01892 {
01893 i = sell_food (x, y - 1);
01894 et += i;
01895 MP_INFO(x + 2,y).int_3 += i;
01896 }
01897 if ((flags & FLAG_MB_COAL) != 0)
01898 {
01899 i = buy_coal (x, y - 1);
01900 ic += i;
01901 MP_INFO(x + 1,y).int_4 += i;
01902 }
01903 if ((flags & FLAG_MS_COAL) != 0)
01904 {
01905 i = sell_coal (x, y - 1);
01906 et += i;
01907 MP_INFO(x + 2,y).int_4 += i;
01908 }
01909 if ((flags & FLAG_MB_ORE) != 0)
01910 {
01911 i = buy_ore (x, y - 1);
01912 ic += i;
01913 MP_INFO(x + 1,y).int_5 += i;
01914 }
01915 if ((flags & FLAG_MS_ORE) != 0)
01916 {
01917 i = sell_ore (x, y - 1);
01918 et += i;
01919 MP_INFO(x + 2,y).int_5 += i;
01920 }
01921 if ((flags & FLAG_MB_GOODS) != 0)
01922 {
01923 i = buy_goods (x, y - 1);
01924 ic += i;
01925 MP_INFO(x + 1,y).int_6 += i;
01926 }
01927 if ((flags & FLAG_MS_GOODS) != 0)
01928 {
01929 i = sell_goods (x, y - 1);
01930 et += i;
01931 MP_INFO(x + 2,y).int_6 += i;
01932 }
01933 if ((flags & FLAG_MB_STEEL) != 0)
01934 {
01935 i = buy_steel (x, y - 1);
01936 ic += i;
01937 MP_INFO(x + 1,y).int_7 += i;
01938 }
01939 if ((flags & FLAG_MS_STEEL) != 0)
01940 {
01941 i = sell_steel (x, y - 1);
01942 et += i;
01943 MP_INFO(x + 2,y).int_7 += i;
01944 }
01945 }
01946 MP_INFO(x,y).int_1 += et;
01947 MP_INFO(x,y).int_4 += ic;
01948 if (total_time % 100 == 0)
01949 {
01950 MP_INFO(x,y).int_2 = MP_INFO(x,y).int_1;
01951 MP_INFO(x,y).int_1 = 0;
01952 MP_INFO(x,y).int_5 = MP_INFO(x,y).int_4;
01953 MP_INFO(x,y).int_4 = 0;
01954 b1 = &(MP_INFO(x + 1,y).int_3);
01955 s1 = &(MP_INFO(x + 2,y).int_3);
01956 b2 = &(MP_INFO(x,y + 1).int_3);
01957 s2 = &(MP_INFO(x,y + 2).int_3);
01958 /* GCS FIX -- This obfuscation is unnecessary. */
01959 for (i = 0; i < 5; i++)
01960 {
01961 *(b2++) = *b1;
01962 *(s2++) = *s1;
01963 *(b1++) = 0;
01964 *(s1++) = 0;
01965 }
01966 }
01967 if (et > 0)
01968 {
01969 sust_port_flag = 0;
01970 tech_level++;
01971 }
01972 if (ic > 0)
01973 {
01974 sust_port_flag = 0;
01975 tech_level++;
01976 }
01977 et += MP_INFO(x,y).int_3; /* int_3 holds the 'pence' */
01978
01979 export_tax += et / 100;
01980 MP_INFO(x,y).int_3 = et % 100;
01981 import_cost += ic;
01982 }
|
|
||||||||||||
|
Definition at line 2894 of file engine.c. 02895 {
02896 /*
02897 // int_1 contains the goods at the pottery
02898 // int_2 contains the ore at the pottery
02899 // int_3 contains the coal at the pottery
02900 // int_4 is the animation trigger time
02901 // int_5 is the % made so far this month or the close time if negative
02902 // int_6 is the % capacity last month
02903 // int_7 contains the jobs stored at the pottery
02904 */
02905 if (MP_INFO(x,y).int_5 < 0)
02906 {
02907 MP_INFO(x,y).int_5++;
02908 return;
02909 }
02910 if (MP_INFO(x,y).int_1 < (MAX_GOODS_AT_POTTERY - POTTERY_MADE_GOODS))
02911 {
02912 if (MP_INFO(x,y).int_2
02913 < (MAX_ORE_AT_POTTERY - POTTERY_GET_ORE))
02914 if (get_ore (x, y, POTTERY_GET_ORE) != 0)
02915 MP_INFO(x,y).int_2 += POTTERY_GET_ORE;
02916 if (MP_INFO(x,y).int_3
02917 < (MAX_COAL_AT_POTTERY - POTTERY_GET_COAL))
02918 if (get_coal (x, y, POTTERY_GET_COAL) != 0)
02919 MP_INFO(x,y).int_3 += POTTERY_GET_COAL;
02920 if (MP_INFO(x,y).int_7
02921 < (MAX_JOBS_AT_POTTERY - POTTERY_GET_JOBS))
02922 if (get_jobs (x, y, POTTERY_GET_JOBS) != 0)
02923 MP_INFO(x,y).int_7 += POTTERY_GET_JOBS;
02924
02925 if (MP_INFO(x,y).int_2 > POTTERY_ORE_MAKE_GOODS
02926 && MP_INFO(x,y).int_3 > POTTERY_COAL_MAKE_GOODS
02927 && MP_INFO(x,y).int_7 > POTTERY_JOBS)
02928 {
02929 MP_INFO(x,y).int_1 += POTTERY_MADE_GOODS;
02930 MP_INFO(x,y).int_2 -= POTTERY_ORE_MAKE_GOODS;
02931 MP_INFO(x,y).int_3 -= POTTERY_COAL_MAKE_GOODS;
02932 MP_INFO(x,y).int_7 -= POTTERY_JOBS;
02933 MP_INFO(x,y).int_5++;
02934 }
02935 else
02936 {
02937 MP_TYPE(x,y) = CST_POTTERY_1;
02938 MP_INFO(x,y).int_6 = 0;
02939 MP_INFO(x,y).int_5 = -POTTERY_CLOSE_TIME;
02940 return;
02941 }
02942 }
02943 if (MP_INFO(x,y).int_1 > 0)
02944 if (put_goods (x, y, MP_INFO(x,y).int_1) != 0)
02945 MP_INFO(x,y).int_1 = 0;
02946
02947 if (total_time % 100 == 0)
02948 {
02949 MP_INFO(x,y).int_6 = MP_INFO(x,y).int_5;
02950 MP_INFO(x,y).int_5 = 0;
02951 }
02952 if (real_time >= MP_INFO(x,y).int_4 /* && block_anim==0 */ )
02953 {
02954 MP_INFO(x,y).int_4 = real_time + POTTERY_ANIM_SPEED;
02955 switch (MP_TYPE(x,y))
02956 {
02957 case (CST_POTTERY_0):
02958 MP_TYPE(x,y) = CST_POTTERY_1;
02959 break;
02960 case (CST_POTTERY_1):
02961 MP_TYPE(x,y) = CST_POTTERY_2;
02962 break;
02963 case (CST_POTTERY_2):
02964 MP_TYPE(x,y) = CST_POTTERY_3;
02965 break;
02966 case (CST_POTTERY_3):
02967 MP_TYPE(x,y) = CST_POTTERY_4;
02968 break;
02969 case (CST_POTTERY_4):
02970 MP_TYPE(x,y) = CST_POTTERY_5;
02971 break;
02972 case (CST_POTTERY_5):
02973 MP_TYPE(x,y) = CST_POTTERY_6;
02974 break;
02975 case (CST_POTTERY_6):
02976 MP_TYPE(x,y) = CST_POTTERY_7;
02977 break;
02978 case (CST_POTTERY_7):
02979 MP_TYPE(x,y) = CST_POTTERY_8;
02980 break;
02981 case (CST_POTTERY_8):
02982 MP_TYPE(x,y) = CST_POTTERY_9;
02983 break;
02984 case (CST_POTTERY_9):
02985 MP_TYPE(x,y) = CST_POTTERY_10;
02986 break;
02987 case (CST_POTTERY_10):
02988 MP_TYPE(x,y) = CST_POTTERY_1;
02989 MP_POL(x,y)++;
02990 break;
02991 }
02992 }
02993 }
|
|
||||||||||||||||
|
Definition at line 3237 of file engine.c. 03238 {
03239 int xx, yy;
03240 if (x == -1 && y == -1)
03241 {
03242 x = rand () % WORLD_SIDE_LEN;
03243 y = rand () % WORLD_SIDE_LEN;
03244 }
03245 else
03246 {
03247 if (x < 0 || x >= WORLD_SIDE_LEN || y < 0 || y >= WORLD_SIDE_LEN)
03248 return;
03249 }
03250 if (MP_TYPE(x,y) == CST_USED)
03251 {
03252 xx = MP_INFO(x,y).int_1;
03253 yy = MP_INFO(x,y).int_2;
03254 x = xx;
03255 y = yy;
03256 }
03257 xx = rand () % 100;
03258 if (xx >= (main_groups[MP_GROUP(x,y)].fire_chance))
03259 return;
03260 if ((MP_INFO(x,y).flags & FLAG_FIRE_COVER) != 0)
03261 return;
03262 if (pwarning)
03263 {
03264 if (MP_GROUP(x,y) == GROUP_POWER_LINE)
03265 ok_dial_box ("fire.mes", BAD, _("It's at a power line."));
03266 else if (MP_GROUP(x,y) == GROUP_SOLAR_POWER)
03267 ok_dial_box ("fire.mes", BAD, _("It's at a solar power station."));
03268 else if (MP_GROUP(x,y) == GROUP_SUBSTATION)
03269 ok_dial_box ("fire.mes", BAD, _("It's at a substation."));
03270 else if (MP_GROUP_IS_RESIDENCE(x,y))
03271 ok_dial_box ("fire.mes", BAD, _("It's at a residential area."));
03272 else if (MP_GROUP(x,y) == GROUP_ORGANIC_FARM)
03273 ok_dial_box ("fire.mes", BAD, _("It's at a farm."));
03274 else if (MP_GROUP(x,y) == GROUP_MARKET)
03275 ok_dial_box ("fire.mes", BAD, _("It's at a market."));
03276 else if (MP_GROUP(x,y) == GROUP_TRACK)
03277 ok_dial_box ("fire.mes", BAD, _("It's at a track."));
03278 else if (MP_GROUP(x,y) == GROUP_COALMINE)
03279 ok_dial_box ("fire.mes", BAD, _("It's at a coal mine."));
03280 else if (MP_GROUP(x,y) == GROUP_RAIL)
03281 ok_dial_box ("fire.mes", BAD, _("It's at a railway."));
03282 else if (MP_GROUP(x,y) == GROUP_COAL_POWER)
03283 ok_dial_box ("fire.mes", BAD, _("It's at a coal power station."));
03284 else if (MP_GROUP(x,y) == GROUP_ROAD)
03285 ok_dial_box ("fire.mes", BAD, _("It's at a road."));
03286 else if (MP_GROUP(x,y) == GROUP_INDUSTRY_L)
03287 ok_dial_box ("fire.mes", BAD, _("It's at light industry."));
03288 else if (MP_GROUP(x,y) == GROUP_UNIVERSITY)
03289 ok_dial_box ("fire.mes", BAD, _("It's at a university."));
03290 else if (MP_GROUP(x,y) == GROUP_COMMUNE)
03291 ok_dial_box ("fire.mes", BAD, _("It's at a commune."));
03292 else if (MP_GROUP(x,y) == GROUP_TIP)
03293 ok_dial_box ("fire.mes", BAD, _("It's at a tip."));
03294 else if (MP_GROUP(x,y) == GROUP_PORT)
03295 ok_dial_box ("fire.mes", BAD, _("It's at a port."));
03296 else if (MP_GROUP(x,y) == GROUP_INDUSTRY_H)
03297 ok_dial_box ("fire.mes", BAD, _("It's at a steel works."));
03298 else if (MP_GROUP(x,y) == GROUP_RECYCLE)
03299 ok_dial_box ("fire.mes", BAD, _("It's at a recycle centre."));
03300 else if (MP_GROUP(x,y) == GROUP_HEALTH)
03301 ok_dial_box ("fire.mes", BAD, _("It's at a health centre."));
03302 else if (MP_GROUP(x,y) == GROUP_ROCKET)
03303 ok_dial_box ("fire.mes", BAD, _("It's at a rocket site."));
03304 else if (MP_GROUP(x,y) == GROUP_WINDMILL)
03305 ok_dial_box ("fire.mes", BAD, _("It's at a windmill."));
03306 else if (MP_GROUP(x,y) == GROUP_SCHOOL)
03307 ok_dial_box ("fire.mes", BAD, _("It's at a school."));
03308 else if (MP_GROUP(x,y) == GROUP_BLACKSMITH)
03309 ok_dial_box ("fire.mes", BAD, _("It's at a blacksmith."));
03310 else if (MP_GROUP(x,y) == GROUP_MILL)
03311 ok_dial_box ("fire.mes", BAD, _("It's at a mill."));
03312 else if (MP_GROUP(x,y) == GROUP_POTTERY)
03313 ok_dial_box ("fire.mes", BAD, _("It's at a pottery."));
03314 else if (MP_GROUP(x,y) == GROUP_FIRESTATION)
03315 ok_dial_box ("fire.mes", BAD, _("It's at a fire station!!!."));
03316 else if (MP_GROUP(x,y) == GROUP_CRICKET)
03317 ok_dial_box ("fire.mes", BAD, _("It's at a cricket pitch!!!."));
03318 else if (MP_GROUP(x,y) == GROUP_SHANTY)
03319 ok_dial_box ("fire.mes", BAD, _("It's at a shanty town."));
03320 else
03321 ok_dial_box ("fire.mes", BAD, _("UNKNOWN!"));
03322 }
03323 fire_area (x, y);
03324 }
|
|
||||||||||||
|
Definition at line 2271 of file engine.c. 02272 {
02273 int i;
02274 /*
02275 // int_1 is the ore made and waiting to go out
02276 // int_2 is the used goods in store
02277 // int_3 is the used steel in store NOT USED at this time
02278 // int_4 is the tech level when built
02279 // int_5 is the recycling done so far this month
02280 // int_6 is the percent of max recycling last month
02281 // int_7 is the waste in store
02282 // cost
02283 */
02284 recycle_cost += RECYCLE_RUNNING_COST;
02285
02286 /*
02287 // let these go through, even if we're full of waste. It's a waste of time
02288 // checking.
02289 */
02290 if (x > 0 && (MP_INFO(x - 1,y).flags & FLAG_IS_TRANSPORT) != 0)
02291 {
02292 i = MP_INFO(x - 1,y).int_7;
02293 if (i > MAX_WASTE_AT_RECYCLE - MP_INFO(x,y).int_2)
02294 i = MAX_WASTE_AT_RECYCLE - MP_INFO(x,y).int_2;
02295 MP_INFO(x,y).int_2 += i;
02296 MP_INFO(x - 1,y).int_7 -= i;
02297 }
02298 if (y > 0 && (MP_INFO(x,y - 1).flags & FLAG_IS_TRANSPORT) != 0)
02299 {
02300 i = MP_INFO(x,y - 1).int_7;
02301 if (i > MAX_WASTE_AT_RECYCLE - MP_INFO(x,y).int_2)
02302 i = MAX_WASTE_AT_RECYCLE - MP_INFO(x,y).int_2;
02303 MP_INFO(x,y).int_2 += i;
02304 MP_INFO(x,y - 1).int_7 -= i;
02305 }
02306
02307 /* get some startup power if not powered yet */
02308 if ((MP_INFO(x,y).flags & FLAG_POWERED) == 0)
02309 if (get_power (x, y, GOODS_RECYCLED, 1) != 0)
02310 MP_INFO(x,y).flags |= FLAG_POWERED;
02311
02312 /* no steel recycling yet - no point, it's only used to make goods.
02313 // recycle to ore.
02314 */
02315 if (MP_INFO(x,y).int_1 < MAX_ORE_AT_RECYCLE
02316 && MP_INFO(x,y).int_2 > GOODS_RECYCLED
02317 && (MP_INFO(x,y).flags & FLAG_POWERED) != 0)
02318 if (get_jobs (x, y, RECYCLE_GOODS_JOBS) != 0)
02319 {
02320 if (get_power (x, y, GOODS_RECYCLED / 2, 1) == 0)
02321 MP_INFO(x,y).flags
02322 &= (0xffffffff - FLAG_POWERED);
02323 else
02324 MP_INFO(x,y).flags |= FLAG_POWERED;
02325 MP_INFO(x,y).int_2 -= GOODS_RECYCLED;
02326 i = (GOODS_RECYCLED * (10 + ((50 * MP_INFO(x,y).int_4)
02327 / MAX_TECH_LEVEL))) / 100;
02328 if (i > (GOODS_RECYCLED * 8) / 10)
02329 i = (GOODS_RECYCLED * 8) / 10;
02330 MP_INFO(x,y).int_1 += i;
02331 ore_made += i;
02332 MP_INFO(x,y).int_5++;
02333 }
02334 if (total_time % 100 == 0)
02335 {
02336 MP_INFO(x,y).int_6 = MP_INFO(x,y).int_5;
02337 MP_INFO(x,y).int_5 = 0;
02338 }
02339 /* now bung the ore out */
02340 /* put it on the railway */
02341 if (x > 0 && MP_GROUP(x-1,y) == GROUP_RAIL
02342 && MP_INFO(x - 1,y).int_5 < MAX_ORE_ON_RAIL
02343 && MP_INFO(x,y).int_1 >= (MAX_ORE_ON_RAIL
02344 - MP_INFO(x - 1,y).int_5))
02345 {
02346 if (get_jobs (x, y, JOBS_LOAD_ORE) != 0)
02347 {
02348 MP_INFO(x,y).int_1
02349 -= (MAX_ORE_ON_RAIL - MP_INFO(x - 1,y).int_5);
02350 MP_INFO(x - 1,y).int_5 = MAX_ORE_ON_RAIL;
02351 }
02352 }
02353 if (y > 0 && MP_GROUP(x,y-1) == GROUP_RAIL
02354 && MP_INFO(x,y - 1).int_5 < MAX_ORE_ON_RAIL
02355 && MP_INFO(x,y).int_1 >= (MAX_ORE_ON_RAIL
02356 - MP_INFO(x,y - 1).int_5))
02357 {
02358 if (get_jobs (x, y, JOBS_LOAD_ORE) != 0)
02359 {
02360 MP_INFO(x,y).int_1
02361 -= (MAX_ORE_ON_RAIL - MP_INFO(x,y - 1).int_5);
02362 MP_INFO(x,y - 1).int_5 = MAX_ORE_ON_RAIL;
02363 }
02364 }
02365 /* put it on the road */
02366 if (x > 0 && MP_GROUP(x-1,y) == GROUP_ROAD
02367 && MP_INFO(x - 1,y).int_5 < MAX_ORE_ON_ROAD
02368 && MP_INFO(x,y).int_1 >= (MAX_ORE_ON_ROAD
02369 - MP_INFO(x - 1,y).int_5))
02370 {
02371 if (get_jobs (x, y, JOBS_LOAD_ORE) != 0)
02372 {
02373 MP_INFO(x,y).int_1
02374 -= (MAX_ORE_ON_ROAD - MP_INFO(x - 1,y).int_5);
02375 MP_INFO(x - 1,y).int_5 = MAX_ORE_ON_ROAD;
02376 }
02377 }
02378 if (y > 0 && MP_GROUP(x,y-1) == GROUP_ROAD
02379 && MP_INFO(x,y - 1).int_5 < MAX_ORE_ON_ROAD
02380 && MP_INFO(x,y).int_1 >= (MAX_ORE_ON_ROAD
02381 - MP_INFO(x,y - 1).int_5))
02382 {
02383 if (get_jobs (x, y, JOBS_LOAD_ORE) != 0)
02384 {
02385 MP_INFO(x,y).int_1
02386 -= (MAX_ORE_ON_ROAD - MP_INFO(x,y - 1).int_5);
02387 MP_INFO(x,y - 1).int_5 = MAX_ORE_ON_ROAD;
02388 }
02389 }
02390 /* put it on the tracks */
02391 if (x > 0 && MP_GROUP(x-1,y) == GROUP_TRACK
02392 && MP_INFO(x - 1,y).int_5 < MAX_ORE_ON_TRACK
02393 && MP_INFO(x,y).int_1 >= (MAX_ORE_ON_TRACK
02394 - MP_INFO(x - 1,y).int_5))
02395 {
02396 if (get_jobs (x, y, JOBS_LOAD_ORE) != 0)
02397 {
02398 MP_INFO(x,y).int_1
02399 -= (MAX_ORE_ON_TRACK - MP_INFO(x - 1,y).int_5);
02400 MP_INFO(x - 1,y).int_5 = MAX_ORE_ON_TRACK;
02401 }
02402 }
02403 if (y > 0 && MP_GROUP(x,y-1) == GROUP_TRACK
02404 && MP_INFO(x,y - 1).int_5 < MAX_ORE_ON_TRACK
02405 && MP_INFO(x,y).int_1 >= (MAX_ORE_ON_TRACK
02406 - MP_INFO(x,y - 1).int_5))
02407 {
02408 if (get_jobs (x, y, JOBS_LOAD_ORE) != 0)
02409 {
02410 MP_INFO(x,y).int_1
02411 -= (MAX_ORE_ON_TRACK - MP_INFO(x,y - 1).int_5);
02412 MP_INFO(x,y - 1).int_5 = MAX_ORE_ON_TRACK;
02413 }
02414 }
02415 /* if we've still got >90% ore and waste in stock, burn some waste cleanly.
02416 */
02417 if (MP_INFO(x,y).int_1 > (MAX_ORE_AT_RECYCLE * 9 / 10)
02418 && MP_INFO(x,y).int_2 > (MAX_WASTE_AT_RECYCLE * 9 / 10))
02419 MP_INFO(x,y).int_2 -= BURN_WASTE_AT_RECYCLE;
02420 }
|
|
||||||||||||
|
Definition at line 303 of file engine.c. 00304 {
00305 /*
00306 // int_1 is a job swingometer to choose +/- JOB_SWING% of normal
00307 // int_2 is the date of the last starve
00308 // int 3 is the real time for the next icon update
00309 // int_4 is the birth rate modifier.
00310 // int_5 is the death rate modifier.
00311 */
00312 int p; /* population */
00313 int bad = 35, good = 30; /* (un)desirability of living here */
00314 int r, po, swing;
00315 int hc = 0; /* have health cover ? */
00316 int brm = 0, drm = 0; /* birth/death rate modifier */
00317 int cc = 0;
00318
00319 p = MP_INFO(x,y).population;
00320 if ((MP_INFO(x,y).flags & FLAG_HEALTH_COVER) != 0)
00321 {
00322 brm += RESIDENCE_BRM_HEALTH;
00323 good += 15;
00324 hc = 1;
00325 }
00326 if ((MP_INFO(x,y).flags & FLAG_FIRE_COVER) == 0)
00327 bad += 5;
00328 else
00329 good += 15;
00330 if ((MP_INFO(x,y).flags & FLAG_CRICKET_COVER) != 0)
00331 {
00332 good += 20;
00333 cc = CRICKET_JOB_SWING;
00334 }
00335 /* normal deaths + pollution deaths */
00336 po = ((MP_POL(x,y) / 50) + 1);
00337 if ((RESIDENCE_BASE_DR - MP_INFO(x,y).int_5 - po) > 1)
00338 r = rand () % (RESIDENCE_BASE_DR - MP_INFO(x,y).int_5 - po);
00339 else
00340 r = 2;
00341 if (p > 0 && (r < po))
00342 {
00343 if (r == 0 || hc == 0)
00344 p--;
00345 else if (hc != 0 && po > 10 && rand () % 4 == 0)
00346 {
00347 p--;
00348 unnat_deaths++;
00349 total_pollution_deaths++;
00350 pollution_deaths_history += 1.0;
00351 bad += 100;
00352 }
00353 if (r > 0 && hc == 0)
00354 {
00355 unnat_deaths++;
00356 total_pollution_deaths++;
00357 pollution_deaths_history += 1.0;
00358 bad += 100;
00359 }
00360 }
00361 /* normal births - must have food and jobs... and people */
00362 if ((MP_INFO(x,y).flags & (FLAG_FED + FLAG_EMPLOYED))
00363 == (FLAG_FED + FLAG_EMPLOYED)
00364 && (rand () % (RESIDENCE_BASE_BR + MP_INFO(x,y).int_4) == 1)
00365 && p > 0)
00366 {
00367 p++;
00368 total_births++;
00369 good += 50;
00370 }
00371 /* are people starving. */
00372 if ((MP_INFO(x,y).flags & FLAG_FED) == 0 && p > 0)
00373 {
00374 if (rand () % DAYS_PER_STARVE == 1)
00375 {
00376 p--;
00377 unnat_deaths++;
00378 total_starve_deaths++;
00379 starve_deaths_history += 1.0;
00380 }
00381 starving_population += p;
00382 bad += 250;
00383 drm += 100;
00384 MP_INFO(x,y).int_2 = total_time; /* for the starve screen */
00385 }
00386 /* kick one out if overpopulated */
00387 if (MP_TYPE(x,y) == CST_RESIDENCE_LL)
00388 {
00389 brm += RESIDENCE1_BRM;
00390 drm += p * 8;
00391 if (p > 50)
00392 {
00393 p--;
00394 people_pool++;
00395 brm += 20;
00396 }
00397 }
00398 else if (MP_TYPE(x,y) == CST_RESIDENCE_ML)
00399 {
00400 brm += RESIDENCE2_BRM;
00401 drm += p * 3;
00402 if (p > 100)
00403 {
00404 p--;
00405 people_pool++;
00406 brm += 10;
00407 }
00408 }
00409 else if (MP_TYPE(x,y) == CST_RESIDENCE_HL)
00410 {
00411 brm += RESIDENCE3_BRM;
00412 drm += p;
00413 good += 40;
00414 if (p > 200)
00415 {
00416 p--;
00417 people_pool++;
00418 brm += 10;
00419 }
00420 }
00421 else if (MP_TYPE(x,y) == CST_RESIDENCE_LH)
00422 {
00423 brm += RESIDENCE4_BRM;
00424 drm += p * 5;
00425 if (p > 100)
00426 {
00427 p--;
00428 people_pool++;
00429 brm += 20;
00430 }
00431 }
00432 else if (MP_TYPE(x,y) == CST_RESIDENCE_MH)
00433 {
00434 brm += RESIDENCE5_BRM;
00435 drm += p / 2;
00436 if (p > 200)
00437 {
00438 p--;
00439 people_pool++;
00440 brm += 10;
00441 }
00442 }
00443 else if (MP_TYPE(x,y) == CST_RESIDENCE_HH)
00444 {
00445 good += 100;
00446 brm += RESIDENCE6_BRM;
00447 drm += p;
00448 if (p > 400)
00449 {
00450 p--;
00451 people_pool++;
00452 brm += 10;
00453 }
00454 }
00455
00456 population += p;
00457
00458 /* now get power */
00459 if (get_power (x, y, POWER_RES_OVERHEAD
00460 + (POWER_USE_PER_PERSON * p), 0) != 0)
00461 {
00462 MP_INFO(x,y).flags |= FLAG_POWERED;
00463 MP_INFO(x,y).flags |= FLAG_HAD_POWER;
00464 good += 10;
00465 }
00466 else
00467 {
00468 MP_INFO(x,y).flags &= (0xffffffff - FLAG_POWERED);
00469 bad += 15;
00470 if ((MP_INFO(x,y).flags & FLAG_HAD_POWER) != 0)
00471 bad += 50;
00472 }
00473 /* now get fed */
00474 if (get_food (x, y, p) != 0)
00475 {
00476 MP_INFO(x,y).flags |= FLAG_FED;
00477 good += 10;
00478 }
00479 else
00480 MP_INFO(x,y).flags &= (0xffffffff - FLAG_FED);
00481 /* now supply jobs and buy goods if employed */
00482 if (MP_INFO(x,y).int_1 > 0)
00483 swing = JOB_SWING + (hc * HC_JOB_SWING) + cc;
00484 else
00485 swing = -(JOB_SWING + (hc * HC_JOB_SWING) + cc);
00486 if (put_jobs (x, y, ((p * (WORKING_POP_PERCENT + swing)) / 100)) != 0)
00487 {
00488 MP_INFO(x,y).flags |= FLAG_EMPLOYED;
00489 MP_INFO(x,y).int_1++;
00490 if (MP_INFO(x,y).int_1 > 10)
00491 MP_INFO(x,y).int_1 = 10;
00492 good += 20;
00493 if (get_goods (x, y, p / 4) != 0)
00494 {
00495 good += 10;
00496 if (get_power (x, y, p / 2, 0) != 0) /* goods use power */
00497
00498 {
00499 good += 5;
00500 brm += 10;
00501 /* buy more goods if got power for them */
00502 if (get_goods (x, y, p / 4) != 0)
00503 good += 5;
00504 }
00505 else
00506 bad += 5;
00507 }
00508 }
00509 else if (MP_INFO(x,y).int_1 < 10)
00510 {
00511 MP_INFO(x,y).flags &= (0xffffffff - FLAG_EMPLOYED);
00512 MP_INFO(x,y).int_1 -= 11;
00513 if (MP_INFO(x,y).int_1 < -300)
00514 MP_INFO(x,y).int_1 = -300;
00515 unemployed_population += p;
00516 total_unemployed_days += p;
00517 if (total_unemployed_days >= NUMOF_DAYS_IN_YEAR)
00518 {
00519 total_unemployed_years++;
00520 /* think we're ok doing this, max of about 120 added each time. */
00521 total_unemployed_days -= NUMOF_DAYS_IN_YEAR;
00522 unemployed_history += 1.0;
00523 }
00524 unemployment_cost += p; /* hmmm */
00525
00526 bad += 70;
00527 }
00528 else
00529 {
00530 MP_INFO(x,y).int_1 -= 20;
00531 bad += 50;
00532 }
00533 drm += p / 4;
00534 /* people_pool stuff */
00535 bad += p / 2;
00536 bad += MP_POL(x,y) / 20;
00537 good += people_pool / 27;
00538 r = rand () % ((good + bad) * RESIDENCE_PPM);
00539 if (r < bad)
00540 {
00541 if (p > MIN_RES_POPULATION)
00542 {
00543 p--;
00544 people_pool++;
00545 }
00546 }
00547 else if (people_pool > 0 && r > ((good + bad) * (RESIDENCE_PPM - 1) + bad))
00548 {
00549 p++;
00550 people_pool--;
00551 }
00552 MP_INFO(x,y).population = p;
00553 MP_INFO(x,y).int_4 = brm;
00554 MP_INFO(x,y).int_5 = drm;
00555 }
|
|
||||||||||||
|
Definition at line 2444 of file engine.c. 02445 {
02446 /*
02447 // You need ROCKET_PAD_JOBS, ROCKET_PAD_GOODS and ROCKET_PAD_STEEL
02448 // to add 1 to % of ready to fire.
02449 // int_1 is the stored jobs
02450 // int_2 is the stored goods
02451 // int_3 is the stored steel
02452 // int_4 is the count which gets to ROCKET_PAD_LAUNCH to fire.
02453 // int_5 is the time of the next animation frame, when waiting for launch.
02454 */
02455 if (MP_TYPE(x,y) == CST_ROCKET_FLOWN)
02456 return; /* The rocket has been launched. */
02457
02458 /* get some jobs */
02459 if (MP_INFO(x,y).int_1 < ROCKET_PAD_JOBS_STORE)
02460 {
02461 if (get_jobs (x, y, ROCKET_PAD_JOBS + 10) != 0)
02462 MP_INFO(x,y).int_1 += ROCKET_PAD_JOBS;
02463 }
02464 /* get goods */
02465 if (MP_INFO(x,y).int_2 < ROCKET_PAD_GOODS_STORE)
02466 {
02467 if (get_goods (x, y, ROCKET_PAD_GOODS + 10) != 0)
02468 MP_INFO(x,y).int_2 += ROCKET_PAD_GOODS;
02469 else if (get_goods (x, y, ROCKET_PAD_GOODS / 10) != 0)
02470 MP_INFO(x,y).int_2 += ROCKET_PAD_GOODS / 5;
02471 else if (get_goods (x, y, ROCKET_PAD_GOODS / 50) != 0)
02472 MP_INFO(x,y).int_2 += ROCKET_PAD_GOODS / 20;
02473 }
02474 /* get steel */
02475 if (MP_INFO(x,y).int_3 < ROCKET_PAD_STEEL_STORE)
02476 {
02477 if (get_steel (x, y, ROCKET_PAD_STEEL + 10) != 0)
02478 MP_INFO(x,y).int_3 += ROCKET_PAD_STEEL + 10;
02479 else if (get_steel (x, y, ROCKET_PAD_STEEL / 5) != 0)
02480 MP_INFO(x,y).int_3 += ROCKET_PAD_STEEL / 5;
02481 else if (get_steel (x, y, ROCKET_PAD_STEEL / 20) != 0)
02482 MP_INFO(x,y).int_3 += ROCKET_PAD_STEEL / 20;
02483 }
02484 #ifdef DEBUG_ROCKETS
02485 MP_INFO(x,y).int_4++;
02486 #else
02487 /* now build the rocket. Unlike uni's need a full store to make +1% */
02488 if (MP_TYPE(x,y) < CST_ROCKET_5
02489 && MP_INFO(x,y).int_1 >= ROCKET_PAD_JOBS_STORE
02490 && MP_INFO(x,y).int_2 >= ROCKET_PAD_GOODS_STORE
02491 && MP_INFO(x,y).int_3 >= ROCKET_PAD_STEEL_STORE)
02492 {
02493 MP_INFO(x,y).int_1 -= ROCKET_PAD_JOBS_STORE;
02494 MP_INFO(x,y).int_2 -= ROCKET_PAD_GOODS_STORE;
02495 MP_INFO(x,y).int_3 -= ROCKET_PAD_STEEL_STORE;
02496 MP_INFO(x,y).int_4++;
02497 goods_used += ROCKET_PAD_GOODS_STORE;
02498
02499 }
02500 #endif
02501 rocket_pad_cost += ROCKET_PAD_RUNNING_COST;
02502 /* animate and return if already said no to launch */
02503 if (MP_TYPE(x,y) >= CST_ROCKET_5
02504 && MP_INFO(x,y).int_4 >= (100 * ROCKET_PAD_LAUNCH) / 100)
02505 {
02506 if (real_time >= MP_INFO(x,y).int_5)
02507 {
02508 MP_INFO(x,y).int_5 = real_time + ROCKET_ANIMATION_SPEED;
02509 switch (MP_TYPE(x,y))
02510 {
02511 case (CST_ROCKET_5):
02512 MP_TYPE(x,y) = CST_ROCKET_6;
02513 break;
02514 case (CST_ROCKET_6):
02515 MP_TYPE(x,y) = CST_ROCKET_7;
02516 break;
02517 case (CST_ROCKET_7):
02518 MP_TYPE(x,y) = CST_ROCKET_5;
02519 break;
02520 }
02521 }
02522 return;
02523 }
02524 /* now choose a graphic */
02525 if (MP_INFO(x,y).int_4 < (25 * ROCKET_PAD_LAUNCH) / 100)
02526 MP_TYPE(x,y) = CST_ROCKET_1;
02527 else if (MP_INFO(x,y).int_4 < (60 * ROCKET_PAD_LAUNCH) / 100)
02528 MP_TYPE(x,y) = CST_ROCKET_2;
02529 else if (MP_INFO(x,y).int_4 < (90 * ROCKET_PAD_LAUNCH) / 100)
02530 MP_TYPE(x,y) = CST_ROCKET_3;
02531 else if (MP_INFO(x,y).int_4 < (100 * ROCKET_PAD_LAUNCH) / 100)
02532 MP_TYPE(x,y) = CST_ROCKET_4;
02533 else if (MP_INFO(x,y).int_4 >= (100 * ROCKET_PAD_LAUNCH) / 100) {
02534 MP_TYPE(x,y) = CST_ROCKET_5;
02535 update_main_screen (0);
02536 if (ask_launch_rocket_now (x,y)) {
02537 launch_rocket (x,y);
02538 }
02539 /* so we don't get get our money back when we bulldoze. */
02540 if (x == last_built_x && y == last_built_y) {
02541 x = 0;
02542 y = 0;
02543 }
02544 }
02545 }
|
|
||||||||||||
|
Definition at line 2695 of file engine.c. 02696 {
02697 /*
02698 // int_1 contains the job pool
02699 // int_2 contains the goods at the school
02700 // int_3 has the tech points made
02701 // int_4 is the tech count so far this 100 days
02702 // int_5 is the tech count last 100 days to give a % of max production
02703 */
02704 if (MP_INFO(x,y).int_1 < (MAX_JOBS_AT_SCHOOL - SCHOOL_JOBS))
02705 if (get_jobs (x, y, SCHOOL_JOBS) != 0)
02706 MP_INFO(x,y).int_1 += SCHOOL_JOBS;
02707 if (MP_INFO(x,y).int_2 < (MAX_GOODS_AT_SCHOOL - SCHOOL_GOODS))
02708 if (get_goods (x, y, SCHOOL_GOODS) != 0)
02709 MP_INFO(x,y).int_2 += SCHOOL_GOODS;
02710 if (MP_INFO(x,y).int_1 >= JOBS_MAKE_TECH_SCHOOL
02711 && MP_INFO(x,y).int_2 >= GOODS_MAKE_TECH_SCHOOL)
02712 {
02713 MP_INFO(x,y).int_1 -= JOBS_MAKE_TECH_SCHOOL;
02714 MP_INFO(x,y).int_2 -= GOODS_MAKE_TECH_SCHOOL;
02715 MP_INFO(x,y).int_3 += TECH_MADE_BY_SCHOOL;
02716 MP_INFO(x,y).int_4++;
02717 tech_level += TECH_MADE_BY_SCHOOL;
02718 }
02719 school_cost += SCHOOL_RUNNING_COST;
02720 if ((total_time % 100) == 0)
02721 {
02722 MP_INFO(x,y).int_5 = MP_INFO(x,y).int_4;
02723 MP_INFO(x,y).int_4 = 0;
02724 }
02725 }
|
|
||||||||||||
|
Definition at line 3603 of file engine.c. 03604 { /* just steal some stuff and make pollution. */
03605
03606 get_food (x, y, SHANTY_GET_FOOD);
03607 if (get_goods (x, y, SHANTY_GET_GOODS) != 0)
03608 if ((goods_tax -= SHANTY_GET_GOODS * 2) < 0)
03609 goods_tax = 0;
03610 get_ore (x, y, SHANTY_GET_ORE);
03611 get_steel (x, y, SHANTY_GET_STEEL);
03612 if (get_jobs (x, y, SHANTY_GET_JOBS) != 0)
03613 if ((income_tax -= SHANTY_GET_JOBS * 2) < 0)
03614 income_tax = 0;
03615 if (get_coal (x, y, SHANTY_GET_COAL) != 0)
03616 if ((coal_tax -= SHANTY_GET_COAL * 2) < 0)
03617 coal_tax = 0;
03618 if ((total_time & 1) == 0)
03619 MP_POL(x,y)++;
03620 else
03621 MP_POL(x+1,y+1)++;
03622 }
|
|
||||||||||||
|
Definition at line 3625 of file engine.c. 03626 {
03627 /*
03628 // int_1 is the amount of waste on the site.
03629 // int_2 if the amount that has flowed in so far this month
03630 // int_3 is the amount stored last month.
03631 // int_4 counts up starting when tip fills, controlling how
03632 long until the land is useful again.
03633 */
03634 int i;
03635
03636 /* XXX: put this in a header somewhere */
03637
03638 /* If the tip is full, age it until it degrades into useful soil */
03639
03640 if (MP_TYPE(x,y) == CST_TIP_8) {
03641 MP_INFO(x,y).int_4++;
03642 if (MP_INFO(x,y).int_4 >= TIP_DEGRADE_TIME) {
03643 do_bulldoze_area(CST_GREEN,x,y);
03644 }
03645 return;
03646 }
03647
03648 /* just grab as much as we can from transport */
03649 if (x > 0 && (MP_INFO(x - 1,y).flags & FLAG_IS_TRANSPORT) != 0)
03650 {
03651 i = MP_INFO(x - 1,y).int_7 / 10;
03652 MP_INFO(x,y).int_1 += i;
03653 MP_INFO(x,y).int_2 += i;
03654 MP_INFO(x - 1,y).int_7 -= i * 10;
03655 sust_dig_ore_coal_tip_flag = 0;
03656 }
03657 if (y > 0 && (MP_INFO(x,y - 1).flags & FLAG_IS_TRANSPORT) != 0)
03658 {
03659 i = MP_INFO(x,y - 1).int_7 / 10;
03660 MP_INFO(x,y).int_1 += i;
03661 MP_INFO(x,y).int_2 += i;
03662 MP_INFO(x,y - 1).int_7 -= i * 10;
03663 sust_dig_ore_coal_tip_flag = 0;
03664 }
03665
03666 #if defined (commentout)
03667 /* Increment the "ore" reserve; this prevents a new tip from being
03668 built on top of a degraded one. */
03669 MP_INFO(x,y).ore_reserve++;
03670 #endif
03671
03672 /* now choose an icon. */
03673 if ((total_time % NUMOF_DAYS_IN_MONTH) == 0)
03674 {
03675 i = (MP_INFO(x,y).int_1 * 7) / MAX_WASTE_AT_TIP;
03676 if (MP_INFO(x,y).int_1 > 0)
03677 i++;
03678 switch (i)
03679 {
03680 case (0):
03681 MP_TYPE(x,y) = CST_TIP_0;
03682 break;
03683 case (1):
03684 MP_TYPE(x,y) = CST_TIP_1;
03685 break;
03686 case (2):
03687 MP_TYPE(x,y) = CST_TIP_2;
03688 break;
03689 case (3):
03690 MP_TYPE(x,y) = CST_TIP_3;
03691 break;
03692 case (4):
03693 MP_TYPE(x,y) = CST_TIP_4;
03694 break;
03695 case (5):
03696 MP_TYPE(x,y) = CST_TIP_5;
03697 break;
03698 case (6):
03699 MP_TYPE(x,y) = CST_TIP_6;
03700 break;
03701 case (7):
03702 MP_TYPE(x,y) = CST_TIP_7;
03703 break;
03704 case (8):
03705 MP_TYPE(x,y) = CST_TIP_8;
03706 MP_INFO(x,y).int_2 = 0;
03707 MP_INFO(x,y).int_4 = 0;
03708 break;
03709
03710 }
03711 MP_INFO(x,y).int_3 = MP_INFO(x,y).int_2;
03712 MP_INFO(x,y).int_2 = 0;
03713 }
03714 }
|
|
||||||||||||
|
Definition at line 2222 of file engine.c. 02223 {
02224 /*
02225 // You need UNIVERSITY_JOBS and UNIVERSITY_GOODS to add 1 to tech_level
02226 // int_1 is the stored jobs
02227 // int_2 is the stored goods
02228 // int_3 is the total tech points made by this uni.
02229 // int_4 is the count so far in this 100 days
02230 // int_5 is the count in the last 100 days to give a percent value
02231 // get some jobs
02232 */
02233 if (MP_INFO(x,y).int_1 < UNIVERSITY_JOBS_STORE)
02234 {
02235 if (get_jobs (x, y, UNIVERSITY_JOBS + 10) != 0)
02236 MP_INFO(x,y).int_1 += UNIVERSITY_JOBS + 10;
02237 }
02238 /* get goods */
02239 if (MP_INFO(x,y).int_2 < UNIVERSITY_GOODS_STORE)
02240 {
02241 if (get_goods (x, y, UNIVERSITY_GOODS + 10) != 0)
02242 MP_INFO(x,y).int_2 += UNIVERSITY_GOODS + 10;
02243 else if (get_goods (x, y, UNIVERSITY_GOODS / 5) != 0)
02244 MP_INFO(x,y).int_2 += UNIVERSITY_GOODS / 5;
02245 else if (get_goods (x, y, UNIVERSITY_GOODS / 20) != 0)
02246 MP_INFO(x,y).int_2 += UNIVERSITY_GOODS / 20;
02247 }
02248 /* now do some research */
02249 if (MP_INFO(x,y).int_1 >= UNIVERSITY_JOBS
02250 && MP_INFO(x,y).int_2 >= UNIVERSITY_GOODS)
02251 {
02252 MP_INFO(x,y).int_1 -= UNIVERSITY_JOBS;
02253 MP_INFO(x,y).int_2 -= UNIVERSITY_GOODS;
02254 goods_used += UNIVERSITY_GOODS;
02255 if (university_intake_rate >= (total_time % 100))
02256 {
02257 MP_INFO(x,y).int_3 += UNIVERSITY_TECH_MADE;
02258 tech_level += UNIVERSITY_TECH_MADE;
02259 MP_INFO(x,y).int_4++;
02260 }
02261 }
02262 if (total_time % 100 == 0)
02263 {
02264 MP_INFO(x,y).int_5 = MP_INFO(x,y).int_4;
02265 MP_INFO(x,y).int_4 = 0;
02266 }
02267 university_cost += UNIVERSITY_RUNNING_COST;
02268 }
|
|
|
Definition at line 1331 of file engine.c. 01332 {
01333 int x;
01334 for (x = 0; x < WORLD_SIDE_LEN; x++) {
01335 mappoint_array_x[x] = x;
01336 mappoint_array_y[x] = x;
01337 }
01338 }
|
|
||||||||||||
|
Definition at line 3843 of file engine.c. 03844 {
03845 /* returns zero if not water at all or if out of bounds. */
03846 if (x < 0 || x >= WORLD_SIDE_LEN || y < 0 || y >= WORLD_SIDE_LEN)
03847 return (0);
03848 if (MP_GROUP(x,y) != GROUP_WATER)
03849 return (0);
03850 if (MP_INFO(x,y).flags & FLAG_IS_RIVER)
03851 return (1);
03852 return (-1);
03853 }
|
|
||||||||||||
|
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 42 of file engine.c. 00043 {
00044 if (total_money >= 0)
00045 return (0);
00046
00047 #ifdef GROUP_POWER_SOURCE_NO_CREDIT
00048 if (selected_group == GROUP_POWER_SOURCE) {
00049 return (1);
00050 }
00051 #endif
00052 #ifdef GROUP_UNIVERSITY_NO_CREDIT
00053 if (selected_group == GROUP_UNIVERSITY) {
00054 return (1);
00055 }
00056 #endif
00057 #ifdef GROUP_PARKLAND_NO_CREDIT
00058 if (selected_group == GROUP_PARKLAND) {
00059 return (1);
00060 }
00061 #endif
00062 #ifdef GROUP_RECYCLE_NO_CREDIT
00063 if (selected_group == GROUP_RECYCLE) {
00064 return (1);
00065 }
00066 #endif
00067 #ifdef GROUP_ROCKET
00068 if (selected_group == GROUP_ROCKET) {
00069 return (1);
00070 }
00071 #endif
00072
00073 if (main_groups[selected_group].no_credit == TRUE ) {
00074 return (1);
00075 }
00076 return (0);
00077 }
|
|
||||||||||||||||
|
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 }
|
|
|
Definition at line 3563 of file engine.c. 03564 {
03565 int x, y, r;
03566 if (numof_shanties <= 0)
03567 return;
03568 x = rand () % WORLD_SIDE_LEN;
03569 y = rand () % WORLD_SIDE_LEN;
03570 r = spiral_find_group (x, y, GROUP_SHANTY);
03571 if (r == -1) {
03572 printf ("Can't find a shanty to remove! ?\n");
03573 return;
03574 }
03575 y = r / WORLD_SIDE_LEN;
03576 x = r % WORLD_SIDE_LEN;
03577 /* decrement of numof_shanties is done in fire area() */
03578 fire_area (x, y);
03579 /* now put the fire out */
03580 MP_INFO(x,y).int_2 = FIRE_LENGTH + 1;
03581 MP_INFO(x + 1,y).int_2 = FIRE_LENGTH + 1;
03582 MP_INFO(x,y + 1).int_2 = FIRE_LENGTH + 1;
03583 MP_INFO(x + 1,y + 1).int_2 = FIRE_LENGTH + 1;
03584 }
|
|
|
Definition at line 2586 of file engine.c. 02587 {
02588 #if defined (commentout)
02589 int x, y, f;
02590 time_t t;
02591 f = 1;
02592 t = time (0);
02593 while (f && (num > 0)) {
02594 for (y = 0; y < WORLD_SIDE_LEN; y++)
02595 for (x = 0; x < WORLD_SIDE_LEN; x++)
02596 if (MP_GROUP_IS_RESIDENCE(x,y) && MP_INFO(x,y).population > 0)
02597 {
02598 MP_INFO(x,y).population--;
02599 // f = 1;
02600 f |= (MP_INFO(x,y).population > 0);
02601 num--;
02602 total_evacuated++;
02603 }
02604 }
02605 while (num > 0 && people_pool > 0) {
02606 num--;
02607 total_evacuated++;
02608 people_pool--;
02609 }
02610 #endif
02611
02612 int x, y;
02613 /* reset housed population so that we can display it correctly */
02614 housed_population = 1;
02615 while (housed_population && (num > 0)) {
02616 housed_population = 0;
02617 for (y = 0; y < WORLD_SIDE_LEN; y++)
02618 for (x = 0; x < WORLD_SIDE_LEN; x++)
02619 if (MP_GROUP_IS_RESIDENCE(x,y) && MP_INFO(x,y).population > 0) {
02620 MP_INFO(x,y).population--;
02621 housed_population += MP_INFO(x,y).population;
02622 num--;
02623 total_evacuated++;
02624 }
02625 }
02626 while (num > 0 && people_pool > 0) {
02627 num--;
02628 total_evacuated++;
02629 people_pool--;
02630 }
02631
02632 refresh_population_text ();
02633
02634 #if defined (commentout)
02635 /* last ship wasn't full so everyone has gone. */
02636 if (num > 0)
02637 {
02638 if (t > HOF_START && t < HOF_STOP)
02639 ok_dial_box ("launch-gone-mail.mes", GOOD, 0L);
02640 else
02641 ok_dial_box ("launch-gone.mes", GOOD, 0L);
02642 housed_population = 0;
02643 }
02644 #endif
02645
02646 /* Note that the previous test was inaccurate. There could be
02647 exactly 1000 people left. */
02648 if (!housed_population && !people_pool) {
02649 ok_dial_box ("launch-gone.mes", GOOD, 0L);
02650 }
02651 }
|
|
||||||||||||
|
Definition at line 2115 of file engine.c. 02116 {
02117 int i = 0;
02118 i = (MP_INFO(xt,yt).int_3 * PORT_EXPORT_RATE) / 1000;
02119 MP_INFO(xt,yt).int_3 -= i;
02120 return (i * PORT_COAL_RATE);
02121 }
|
|
||||||||||||
|
Definition at line 2106 of file engine.c. 02107 {
02108 int i = 0;
02109 i = (MP_INFO(xt,yt).int_1 * PORT_EXPORT_RATE) / 1000;
02110 MP_INFO(xt,yt).int_1 -= i;
02111 return (i * PORT_FOOD_RATE);
02112 }
|
|
||||||||||||
|
Definition at line 2133 of file engine.c. 02134 {
02135 int i = 0;
02136 i = (MP_INFO(xt,yt).int_4 * PORT_EXPORT_RATE) / 1000;
02137 MP_INFO(xt,yt).int_4 -= i;
02138 return (i * PORT_GOODS_RATE);
02139 }
|
|
||||||||||||
|
Definition at line 2124 of file engine.c. 02125 {
02126 int i = 0;
02127 i = (MP_INFO(xt,yt).int_5 * PORT_EXPORT_RATE) / 1000;
02128 MP_INFO(xt,yt).int_5 -= i;
02129 return (i * PORT_ORE_RATE);
02130 }
|
|
||||||||||||
|
Definition at line 2142 of file engine.c. 02143 {
02144 int i = 0;
02145 i = (MP_INFO(xt,yt).int_6 * PORT_EXPORT_RATE) / 1000;
02146 MP_INFO(xt,yt).int_6 -= i;
02147 return (i * PORT_STEEL_RATE);
02148 }
|
|
|
Definition at line 1341 of file engine.c. 01342 {
01343 int i, x, a;
01344 for (i = 0; i < SHUFFLE_MAPPOINT_COUNT; i++)
01345 {
01346 x = rand () % WORLD_SIDE_LEN;
01347 a = mappoint_array_x[i];
01348 mappoint_array_x[i] = mappoint_array_x[x];
01349 mappoint_array_x[x] = a;
01350 x = rand () % WORLD_SIDE_LEN;
01351 a = mappoint_array_y[i];
01352 mappoint_array_y[i] = mappoint_array_y[x];
01353 mappoint_array_y[x] = a;
01354 }
01355 }
|
|
||||||||||||
|
Definition at line 3455 of file engine.c. 03456 {
03457 int i, j, x, y;
03458 x = startx;
03459 y = starty;
03460 /* let's just do a complete spiral for now, work out the bounds later */
03461 for (i = 1; i < (WORLD_SIDE_LEN + WORLD_SIDE_LEN); i++)
03462 {
03463 for (j = 0; j < i; j++)
03464 {
03465 x--;
03466 if (x > 1 && x < WORLD_SIDE_LEN - 2 && y > 1
03467 && y < WORLD_SIDE_LEN - 2)
03468 if (MP_TYPE(x,y) == CST_GREEN
03469 && MP_TYPE(x + 1,y) == CST_GREEN
03470 && MP_TYPE(x,y + 1) == CST_GREEN
03471 && MP_TYPE(x + 1,y + 1) == CST_GREEN)
03472 return (x + y * WORLD_SIDE_LEN);
03473 }
03474 for (j = 0; j < i; j++)
03475 {
03476 y--;
03477 if (x > 1 && x < WORLD_SIDE_LEN - 2 && y > 1
03478 && y < WORLD_SIDE_LEN - 2)
03479 if (MP_TYPE(x,y) == CST_GREEN
03480 && MP_TYPE(x + 1,y) == CST_GREEN
03481 && MP_TYPE(x,y + 1) == CST_GREEN
03482 && MP_TYPE(x + 1,y + 1) == CST_GREEN)
03483 return (x + y * WORLD_SIDE_LEN);
03484 }
03485 i++;
03486 for (j = 0; j < i; j++)
03487 {
03488 x++;
03489 if (x > 1 && x < WORLD_SIDE_LEN - 2 && y > 1
03490 && y < WORLD_SIDE_LEN - 2)
03491 if (MP_TYPE(x,y) == CST_GREEN
03492 && MP_TYPE(x + 1,y) == CST_GREEN
03493 && MP_TYPE(x,y + 1) == CST_GREEN
03494 && MP_TYPE(x + 1,y + 1) == CST_GREEN)
03495 return (x + y * WORLD_SIDE_LEN);
03496 }
03497 for (j = 0; j < i; j++)
03498 {
03499 y++;
03500 if (x > 1 && x < WORLD_SIDE_LEN - 2 && y > 1
03501 && y < WORLD_SIDE_LEN - 2)
03502 if (MP_TYPE(x,y) == CST_GREEN
03503 && MP_TYPE(x + 1,y) == CST_GREEN
03504 && MP_TYPE(x,y + 1) == CST_GREEN
03505 && MP_TYPE(x + 1,y + 1) == CST_GREEN)
03506 return (x + y * WORLD_SIDE_LEN);
03507 }
03508 }
03509 return (-1);
03510 }
|
|
||||||||||||||||
|
Definition at line 3408 of file engine.c. 03409 {
03410 int i, j, x, y;
03411 x = startx;
03412 y = starty;
03413 /* let's just do a complete spiral for now, work out the bounds later */
03414 for (i = 1; i < (WORLD_SIDE_LEN + WORLD_SIDE_LEN); i++)
03415 {
03416 for (j = 0; j < i; j++)
03417 {
03418 x--;
03419 if (x > 0 && x < WORLD_SIDE_LEN && y > 0 && y < WORLD_SIDE_LEN)
03420 if (MP_GROUP(x,y) == group)
03421 return (x + y * WORLD_SIDE_LEN);
03422 }
03423 for (j = 0; j < i; j++)
03424 {
03425 y--;
03426 if (x > 0 && x < WORLD_SIDE_LEN && y > 0 && y < WORLD_SIDE_LEN)
03427 if (MP_GROUP(x,y) == group)
03428 return (x + y * WORLD_SIDE_LEN);
03429 }
03430 i++;
03431 for (j = 0; j < i; j++)
03432 {
03433 x++;
03434 if (x > 0 && x < WORLD_SIDE_LEN && y > 0 && y < WORLD_SIDE_LEN)
03435 if (MP_GROUP(x,y) == group)
03436 return (x + y * WORLD_SIDE_LEN);
03437 }
03438 for (j = 0; j < i; j++)
03439 {
03440 y++;
03441 if (x > 0 && x < WORLD_SIDE_LEN && y > 0 && y < WORLD_SIDE_LEN)
03442 if (MP_GROUP(x,y) == group)
03443 return (x + y * WORLD_SIDE_LEN);
03444 }
03445 }
03446 return (-1);
03447 }
|
|
|
Definition at line 3587 of file engine.c. 03588 {
03589 int i, pp;
03590 pp = people_pool - (COMMUNE_POP * numof_communes);
03591 i = (pp - SHANTY_MIN_PP) / SHANTY_POP;
03592 if (i > numof_shanties)
03593 add_a_shanty (); /* vv-- schmitt trigger */
03594
03595 else if (numof_shanties > 0 && i < (numof_shanties - 1))
03596 remove_a_shanty ();
03597 else if (numof_shanties > 0 && rand () % 100 == 10)
03598 remove_a_shanty (); /* randomly close some down. */
03599
03600 }
|
|
||||||||||||
|
Definition at line 3771 of file engine.c. 03772 {
03773 switch (MP_GROUP(x,y))
03774 {
03775 case (GROUP_ORGANIC_FARM):
03776 MP_INFO(x,y).int_7 = ((double) MP_INFO(x,y).int_1
03777 * ORGANIC_FARM_FOOD_OUTPUT) / MAX_TECH_LEVEL;
03778 break;
03779 case (GROUP_WINDMILL):
03780 #ifdef OLD_POWER_CODE
03781 MP_INFO(x,y).int_5 = WINDMILL_POWER
03782 #else
03783 MP_INFO(x,y).int_1 = WINDMILL_POWER
03784 #endif
03785 + (((double) MP_INFO(x,y).int_2 * WINDMILL_POWER) / MAX_TECH_LEVEL);
03786 break;
03787 case (GROUP_COAL_POWER):
03788 #ifdef OLD_POWER_CODE
03789 MP_INFO(x,y).int_5 = POWERS_COAL_OUTPUT
03790 #else
03791 MP_INFO(x,y).int_1 = POWERS_COAL_OUTPUT
03792 #endif
03793 + (((double) MP_INFO(x,y).int_4 * POWERS_COAL_OUTPUT)
03794 / MAX_TECH_LEVEL);
03795 break;
03796 case (GROUP_SOLAR_POWER):
03797 MP_INFO(x,y).int_3 = POWERS_SOLAR_OUTPUT
03798 + (((double) MP_INFO(x,y).int_2 * POWERS_SOLAR_OUTPUT)
03799 / MAX_TECH_LEVEL);
03800 break;
03801 }
03802 }
|
|
|
Definition at line 81 of file shrglobs.c. |
1.3.9.1