#include <stdio.h>#include <stdlib.h>#include "common.h"#include "lctypes.h"#include "lin-city.h"#include "market.h"#include "stats.h"Go to the source code of this file.
Data Structures | |
| struct | stack |
Functions | |
| int | get_jobs (int x, int y, int jobs) |
| int | put_jobs (int x, int y, int jobs) |
| int | get_food (int x, int y, int food) |
| int | put_food (int x, int y, int food) |
| int | get_goods (int x, int y, int goods) |
| int | put_goods (int x, int y, int goods) |
| int | put_waste (int x, int y, int waste) |
| int | get_waste (int x, int y, int waste) |
| int | get_steel (int x, int y, int steel) |
| int | put_steel (int x, int y, int steel) |
| int | get_ore (int x, int y, int ore) |
| int | put_ore (int x, int y, int ore) |
| int | get_coal (int x, int y, int coal) |
| int | put_coal (int x, int y, int coal) |
| int | add_a_market (int x, int y) |
| void | remove_a_market (int x, int y) |
| void | do_market (int x, int y) |
| void | shuffle_markets (void) |
| int | deal_with_transport (int x, int y, int tx, int ty) |
| int | get_stuff (int x, int y, int stuff, int stuff_type) |
| int | get_stuff2 (Map_Point_Info *map, int stuff, int stuff_type) |
| int | get_stuff3 (Map_Point_Info *map, int stuff, int stuff_type) |
| int | get_stuff4 (Map_Point_Info *map, int stuff, int stuff_type) |
| int | put_stuff (int x, int y, int stuff, int stuff_type) |
| int | put_stuff2 (Map_Point_Info *minfo, short *type, int stuff, int stuff_type) |
| int | put_stuff3 (Map_Point_Info *minfo, short *type, int stuff, int stuff_type) |
| int | put_stuff4 (Map_Point_Info *minfo, short *type, int stuff, int stuff_type) |
Variables | |
| const int | t2 [8] |
| const int | t3 [12] |
| const int | t4 [16] |
| int | tmax [3][7] |
|
||||||||||||
|
Definition at line 361 of file market.c. 00362 {
00363 if (numof_markets >= MAX_NUMOF_MARKETS)
00364 return (0);
00365 marketx[numof_markets] = x;
00366 markety[numof_markets] = y;
00367 numof_markets++;
00368 /* oh dear. Got to bootstap markets with jobs, otherwise power won't work */
00369 /* GCS: Is this still true? */
00370 MP_INFO(x,y).int_2 = 2000;
00371 return (1);
00372 }
|
|
||||||||||||||||||||
|
Definition at line 482 of file market.c. 00483 {
00484 int i, r, extra_jobs = 3, flags;
00485 flags = MP_INFO(x,y).flags;
00486 /* tracks */
00487 if (MP_GROUP(tx,ty) == GROUP_TRACK)
00488 {
00489 /* food */
00490 if ((flags & FLAG_MB_FOOD) != 0)
00491 {
00492 r = (MAX_FOOD_IN_MARKET * 1000)
00493 / (MAX_FOOD_ON_TRACK + MAX_FOOD_IN_MARKET);
00494 i = MP_INFO(x,y).int_1 + MP_INFO(tx,ty).int_1;
00495 MP_INFO(x,y).int_1 = (i * r) / 1000;
00496 MP_INFO(tx,ty).int_1 = i - MP_INFO(x,y).int_1;
00497 }
00498
00499 /* jobs */
00500 if ((flags & FLAG_MB_JOBS) != 0)
00501 {
00502 r = (MAX_JOBS_IN_MARKET * 1000)
00503 / (MAX_JOBS_ON_TRACK + MAX_JOBS_IN_MARKET);
00504 i = MP_INFO(x,y).int_2 + MP_INFO(tx,ty).int_2;
00505 MP_INFO(x,y).int_2 = (i * r) / 1000;
00506 MP_INFO(tx,ty).int_2 = i - MP_INFO(x,y).int_2;
00507 }
00508
00509 /* coal */
00510 if ((flags & FLAG_MB_COAL) != 0)
00511 {
00512 r = (MAX_COAL_IN_MARKET * 1000)
00513 / (MAX_COAL_ON_TRACK + MAX_COAL_IN_MARKET);
00514 i = MP_INFO(x,y).int_3 + MP_INFO(tx,ty).int_3;
00515 MP_INFO(x,y).int_3 = (i * r) / 1000;
00516 MP_INFO(tx,ty).int_3 = i - MP_INFO(x,y).int_3;
00517 }
00518
00519 /* goods */
00520 if ((flags & FLAG_MB_GOODS) != 0)
00521 {
00522 r = (MAX_GOODS_IN_MARKET * 1000)
00523 / (MAX_GOODS_ON_TRACK + MAX_GOODS_IN_MARKET);
00524 i = MP_INFO(x,y).int_4 + MP_INFO(tx,ty).int_4;
00525 MP_INFO(x,y).int_4 = (i * r) / 1000;
00526 MP_INFO(tx,ty).int_4 = i - MP_INFO(x,y).int_4;
00527 }
00528
00529 /* ore */
00530 if ((flags & FLAG_MB_ORE) != 0)
00531 {
00532 r = (MAX_ORE_IN_MARKET * 1000)
00533 / (MAX_ORE_ON_TRACK + MAX_ORE_IN_MARKET);
00534 i = MP_INFO(x,y).int_5 + MP_INFO(tx,ty).int_5;
00535 MP_INFO(x,y).int_5 = (i * r) / 1000;
00536 MP_INFO(tx,ty).int_5 = i - MP_INFO(x,y).int_5;
00537 }
00538
00539
00540 /* steel */
00541 if ((flags & FLAG_MB_STEEL) != 0)
00542 {
00543 r = (MAX_STEEL_IN_MARKET * 1000)
00544 / (MAX_STEEL_ON_TRACK + MAX_STEEL_IN_MARKET);
00545 i = MP_INFO(x,y).int_6 + MP_INFO(tx,ty).int_6;
00546 MP_INFO(x,y).int_6 = (i * r) / 1000;
00547 MP_INFO(tx,ty).int_6 = i - MP_INFO(x,y).int_6;
00548 }
00549
00550 /* waste */
00551 r = (MAX_WASTE_IN_MARKET * 1000)
00552 / (MAX_WASTE_ON_TRACK + MAX_WASTE_IN_MARKET);
00553 i = MP_INFO(x,y).int_7 + MP_INFO(tx,ty).int_7;
00554 MP_INFO(x,y).int_7 = (i * r) / 1000;
00555 MP_INFO(tx,ty).int_7 = i - MP_INFO(x,y).int_7;
00556
00557
00558 /* if it's full of waste, burn some to make pollution. */
00559 if (MP_INFO(x,y).int_7 >= (99 * MAX_WASTE_IN_MARKET / 100))
00560 {
00561 MP_POL(x,y) += 3000;
00562 MP_INFO(x,y).int_7 -= (7 * MAX_WASTE_IN_MARKET) / 10;
00563 #if defined (commentout)
00564 /* this should fire up the pollution mini screen within a second. */
00565 mini_screen_flags = MINI_SCREEN_POL_FLAG;
00566 #endif
00567 }
00568 }
00569
00570
00571 /* do rail traffic */
00572 else if (MP_GROUP(tx,ty) == GROUP_RAIL)
00573 {
00574 /* food */
00575 if ((flags & FLAG_MB_FOOD) != 0)
00576 {
00577 r = (MAX_FOOD_IN_MARKET * 1000)
00578 / (MAX_FOOD_ON_RAIL + MAX_FOOD_IN_MARKET);
00579 i = MP_INFO(x,y).int_1 + MP_INFO(tx,ty).int_1;
00580 MP_INFO(x,y).int_1 = (i * r) / 1000;
00581 MP_INFO(tx,ty).int_1 = i - MP_INFO(x,y).int_1;
00582 }
00583
00584 /* jobs */
00585 if ((flags & FLAG_MB_JOBS) != 0)
00586 {
00587 r = (MAX_JOBS_IN_MARKET * 1000)
00588 / (MAX_JOBS_ON_RAIL + MAX_JOBS_IN_MARKET);
00589 i = MP_INFO(x,y).int_2 + MP_INFO(tx,ty).int_2;
00590 MP_INFO(x,y).int_2 = (i * r) / 1000;
00591 MP_INFO(tx,ty).int_2 = i - MP_INFO(x,y).int_2;
00592 }
00593
00594 /* coal */
00595 if ((flags & FLAG_MB_COAL) != 0)
00596 {
00597 r = (MAX_COAL_IN_MARKET * 1000)
00598 / (MAX_COAL_ON_RAIL + MAX_COAL_IN_MARKET);
00599 i = MP_INFO(x,y).int_3 + MP_INFO(tx,ty).int_3;
00600 MP_INFO(x,y).int_3 = (i * r) / 1000;
00601 MP_INFO(tx,ty).int_3 = i - MP_INFO(x,y).int_3;
00602 }
00603
00604 /* goods */
00605 if ((flags & FLAG_MB_GOODS) != 0)
00606 {
00607 r = (MAX_GOODS_IN_MARKET * 1000)
00608 / (MAX_GOODS_ON_RAIL + MAX_GOODS_IN_MARKET);
00609 i = MP_INFO(x,y).int_4 + MP_INFO(tx,ty).int_4;
00610 MP_INFO(x,y).int_4 = (i * r) / 1000;
00611 MP_INFO(tx,ty).int_4 = i - MP_INFO(x,y).int_4;
00612 }
00613
00614 /* ore */
00615 if ((flags & FLAG_MB_ORE) != 0)
00616 {
00617 r = (MAX_ORE_IN_MARKET * 1000)
00618 / (MAX_ORE_ON_RAIL + MAX_ORE_IN_MARKET);
00619 i = MP_INFO(x,y).int_5 + MP_INFO(tx,ty).int_5;
00620 MP_INFO(x,y).int_5 = (i * r) / 1000;
00621 MP_INFO(tx,ty).int_5 = i - MP_INFO(x,y).int_5;
00622 }
00623
00624 /* steel */
00625 if ((flags & FLAG_MB_STEEL) != 0)
00626 {
00627 r = (MAX_STEEL_IN_MARKET * 1000)
00628 / (MAX_STEEL_ON_RAIL + MAX_STEEL_IN_MARKET);
00629 i = MP_INFO(x,y).int_6 + MP_INFO(tx,ty).int_6;
00630 MP_INFO(x,y).int_6 = (i * r) / 1000;
00631 MP_INFO(tx,ty).int_6 = i - MP_INFO(x,y).int_6;
00632 }
00633
00634 /* waste */
00635 r = (MAX_WASTE_IN_MARKET * 1000)
00636 / (MAX_WASTE_ON_RAIL + MAX_WASTE_IN_MARKET);
00637 i = MP_INFO(x,y).int_7 + MP_INFO(tx,ty).int_7;
00638 MP_INFO(x,y).int_7 = (i * r) / 1000;
00639 MP_INFO(tx,ty).int_7 = i - MP_INFO(x,y).int_7;
00640
00641 }
00642
00643 /* do road traffic */
00644 else if (MP_GROUP(tx,ty) == GROUP_ROAD)
00645 {
00646 /* food */
00647 if ((flags & FLAG_MB_FOOD) != 0)
00648 {
00649 r = (MAX_FOOD_IN_MARKET * 1000)
00650 / (MAX_FOOD_ON_ROAD + MAX_FOOD_IN_MARKET);
00651 i = MP_INFO(x,y).int_1 + MP_INFO(tx,ty).int_1;
00652 MP_INFO(x,y).int_1 = (i * r) / 1000;
00653 MP_INFO(tx,ty).int_1 = i - MP_INFO(x,y).int_1;
00654 }
00655
00656 /* jobs */
00657 if ((flags & FLAG_MB_JOBS) != 0)
00658 {
00659 r = (MAX_JOBS_IN_MARKET * 1000)
00660 / (MAX_JOBS_ON_ROAD + MAX_JOBS_IN_MARKET);
00661 i = MP_INFO(x,y).int_2 + MP_INFO(tx,ty).int_2;
00662 MP_INFO(x,y).int_2 = (i * r) / 1000;
00663 MP_INFO(tx,ty).int_2 = i - MP_INFO(x,y).int_2;
00664 }
00665
00666 /* coal */
00667 if ((flags & FLAG_MB_COAL) != 0)
00668 {
00669 r = (MAX_COAL_IN_MARKET * 1000)
00670 / (MAX_COAL_ON_ROAD + MAX_COAL_IN_MARKET);
00671 i = MP_INFO(x,y).int_3 + MP_INFO(tx,ty).int_3;
00672 MP_INFO(x,y).int_3 = (i * r) / 1000;
00673 MP_INFO(tx,ty).int_3 = i - MP_INFO(x,y).int_3;
00674 }
00675
00676 /* goods */
00677 if ((flags & FLAG_MB_GOODS) != 0)
00678 {
00679 r = (MAX_GOODS_IN_MARKET * 1000)
00680 / (MAX_GOODS_ON_ROAD + MAX_GOODS_IN_MARKET);
00681 i = MP_INFO(x,y).int_4 + MP_INFO(tx,ty).int_4;
00682 MP_INFO(x,y).int_4 = (i * r) / 1000;
00683 MP_INFO(tx,ty).int_4 = i - MP_INFO(x,y).int_4;
00684 }
00685
00686 /* ore */
00687 if ((flags & FLAG_MB_ORE) != 0)
00688 {
00689 r = (MAX_ORE_IN_MARKET * 1000)
00690 / (MAX_ORE_ON_ROAD + MAX_ORE_IN_MARKET);
00691 i = MP_INFO(x,y).int_5 + MP_INFO(tx,ty).int_5;
00692 MP_INFO(x,y).int_5 = (i * r) / 1000;
00693 MP_INFO(tx,ty).int_5 = i - MP_INFO(x,y).int_5;
00694 }
00695
00696 /* steel */
00697 if ((flags & FLAG_MB_STEEL) != 0)
00698 {
00699 r = (MAX_STEEL_IN_MARKET * 1000)
00700 / (MAX_STEEL_ON_ROAD + MAX_STEEL_IN_MARKET);
00701 i = MP_INFO(x,y).int_6 + MP_INFO(tx,ty).int_6;
00702 MP_INFO(x,y).int_6 = (i * r) / 1000;
00703 MP_INFO(tx,ty).int_6 = i - MP_INFO(x,y).int_6;
00704 }
00705
00706 /* waste */
00707 r = (MAX_WASTE_IN_MARKET * 1000)
00708 / (MAX_WASTE_ON_ROAD + MAX_WASTE_IN_MARKET);
00709 i = MP_INFO(x,y).int_7 + MP_INFO(tx,ty).int_7;
00710 MP_INFO(x,y).int_7 = (i * r) / 1000;
00711 MP_INFO(tx,ty).int_7 = i - MP_INFO(x,y).int_7;
00712 }
00713 else
00714 extra_jobs = 0;
00715
00716 return (extra_jobs);
00717 }
|
|
||||||||||||
|
Definition at line 390 of file market.c. 00391 {
00392 /*
00393 // int_1 contains the food it holds
00394 // int_2 contains the jobs
00395 // int_3 contains the coal
00396 // int_4 contains the goods
00397 // int_5 contains the ore
00398 // int_6 contains the steel
00399 // int_7 contains the waste
00400 */
00401
00402 int extra_jobs = 0;
00403
00404 shuffle_markets ();
00405
00406 if (x > 0 && (MP_INFO(x - 1,y).flags & FLAG_IS_TRANSPORT) != 0)
00407 extra_jobs += deal_with_transport (x, y, x - 1, y);
00408 if (x > 0 && (MP_INFO(x - 1,y + 1).flags & FLAG_IS_TRANSPORT) != 0)
00409 extra_jobs += deal_with_transport (x, y, x - 1, y + 1);
00410 if (y > 0 && (MP_INFO(x,y - 1).flags & FLAG_IS_TRANSPORT) != 0)
00411 extra_jobs += deal_with_transport (x, y, x, y - 1);
00412 if (y > 0 && (MP_INFO(x + 1,y - 1).flags & FLAG_IS_TRANSPORT) != 0)
00413 extra_jobs += deal_with_transport (x, y, x + 1, y - 1);
00414 if (x < WORLD_SIDE_LEN - 2
00415 && (MP_INFO(x + 2,y).flags & FLAG_IS_TRANSPORT) != 0)
00416 extra_jobs += deal_with_transport (x, y, x + 2, y);
00417 if (x < WORLD_SIDE_LEN - 2
00418 && (MP_INFO(x + 2,y + 1).flags & FLAG_IS_TRANSPORT) != 0)
00419 extra_jobs += deal_with_transport (x, y, x + 2, y + 1);
00420 if (y < WORLD_SIDE_LEN - 2
00421 && (MP_INFO(x,y + 2).flags & FLAG_IS_TRANSPORT) != 0)
00422 extra_jobs += deal_with_transport (x, y, x, y + 2);
00423 if (y < WORLD_SIDE_LEN - 2
00424 && (MP_INFO(x + 1,y + 2).flags & FLAG_IS_TRANSPORT) != 0)
00425 extra_jobs += deal_with_transport (x, y, x + 1, y + 2);
00426
00427 if (MP_INFO(x,y).int_1 > MAX_FOOD_IN_MARKET)
00428 MP_INFO(x,y).int_1 = MAX_FOOD_IN_MARKET;
00429 if (MP_INFO(x,y).int_2 > MAX_JOBS_IN_MARKET)
00430 MP_INFO(x,y).int_2 = MAX_JOBS_IN_MARKET;
00431 if (MP_INFO(x,y).int_4 > MAX_GOODS_IN_MARKET)
00432 MP_INFO(x,y).int_4 = MAX_GOODS_IN_MARKET;
00433
00434 /* now choose a graphic only dependent on food (for now anyway) */
00435 if (total_time % 25 == 17)
00436 {
00437 if (MP_INFO(x,y).int_1 <= 0)
00438 {
00439 if (MP_INFO(x,y).int_2 > 0)
00440 MP_TYPE(x,y) = CST_MARKET_LOW;
00441 else
00442 MP_TYPE(x,y) = CST_MARKET_EMPTY;
00443 }
00444 else if (MP_INFO(x,y).int_1 < (MARKET_FOOD_SEARCH_TRIGGER / 2))
00445 MP_TYPE(x,y) = CST_MARKET_LOW;
00446 else if (MP_INFO(x,y).int_1
00447 < (MAX_FOOD_IN_MARKET - MAX_FOOD_IN_MARKET / 4))
00448 MP_TYPE(x,y) = CST_MARKET_MED;
00449 else
00450 MP_TYPE(x,y) = CST_MARKET_FULL;
00451 }
00452
00453 /* now employ some people */
00454 get_jobs (x, y, 1 + (extra_jobs / 5));
00455
00456 /* keep the pbars accurate */
00457 inventory(x,y);
00458 }
|
|
||||||||||||||||
|
Definition at line 313 of file market.c. 00314 {
00315 int q;
00316 if (numof_markets > 0)
00317 {
00318 for (q = 0; q < numof_markets; q++)
00319 {
00320 if ((abs (marketx[q] - x) < MARKET_RANGE)
00321 && (abs (markety[q] - y) < MARKET_RANGE)
00322 && (MP_INFO(marketx[q],markety[q]).int_3
00323 > coal))
00324 {
00325 MP_INFO(marketx[q],markety[q]).int_3 -= coal;
00326 return (1);
00327 }
00328 }
00329 }
00330 if (get_stuff (x, y, coal, T_COAL) != 0)
00331 return (1);
00332 return (0);
00333 }
|
|
||||||||||||||||
|
Definition at line 65 of file market.c. 00066 {
00067 int q;
00068 if (numof_markets > 0)
00069 {
00070 for (q = 0; q < numof_markets; q++)
00071 {
00072 if ((abs (marketx[q] - x) < MARKET_RANGE)
00073 && (abs (markety[q] - y) < MARKET_RANGE)
00074 && (MP_INFO(marketx[q],markety[q]).int_1
00075 > food))
00076 {
00077 MP_INFO(marketx[q],markety[q]).int_1 -= food;
00078 return (1);
00079 }
00080 }
00081 }
00082 if (get_stuff (x, y, food, T_FOOD) != 0)
00083 return (1);
00084 return (0);
00085 }
|
|
||||||||||||||||
|
Definition at line 113 of file market.c. 00114 {
00115 int q;
00116 if (numof_markets > 0)
00117 {
00118 for (q = 0; q < numof_markets; q++)
00119 {
00120 if (abs (marketx[q] - x) < MARKET_RANGE
00121 && abs (markety[q] - y) < MARKET_RANGE
00122 && (MP_INFO(marketx[q],markety[q]).int_4
00123 > goods))
00124 {
00125 MP_INFO(marketx[q],markety[q]).int_4 -= goods;
00126 goods_tax += goods;
00127 goods_used += goods;
00128 /* make the waste here. */
00129 MP_INFO(marketx[q],markety[q]).int_7 += goods / 3;
00130 return (1);
00131 }
00132 }
00133 }
00134 if (get_stuff (x, y, goods, T_GOODS) != 0)
00135 {
00136 put_stuff (x, y, goods / 3, T_WASTE);
00137 goods_tax += goods;
00138 goods_used += goods;
00139 return (1);
00140 }
00141 return (0);
00142 }
|
|
||||||||||||||||
|
Definition at line 16 of file market.c. 00017 {
00018 int q;
00019 if (numof_markets > 0)
00020 {
00021 for (q = 0; q < numof_markets; q++)
00022 {
00023 if ((abs (marketx[q] - x) < MARKET_RANGE
00024 && abs (markety[q] - y) < MARKET_RANGE
00025 && (MP_INFO(marketx[q],markety[q]).int_2 > (3 * jobs / 2))))
00026 {
00027 MP_INFO(marketx[q],markety[q]).int_2 -= jobs;
00028 income_tax += jobs;
00029 return (1);
00030 }
00031 }
00032 }
00033 if (get_stuff (x, y, jobs, T_JOBS) != 0)
00034 {
00035 income_tax += jobs;
00036 return (1);
00037 }
00038 return (0);
00039 }
|
|
||||||||||||||||
|
Definition at line 265 of file market.c. 00266 {
00267 int q;
00268 if (numof_markets > 0)
00269 {
00270 for (q = 0; q < numof_markets; q++)
00271 {
00272 if ((abs (marketx[q] - x) < MARKET_RANGE)
00273 && (abs (markety[q] - y) < MARKET_RANGE)
00274 && (MP_INFO(marketx[q],markety[q]).int_5
00275 > ore))
00276 {
00277 MP_INFO(marketx[q],markety[q]).int_5 -= ore;
00278 return (1);
00279 }
00280 }
00281 }
00282 if (get_stuff (x, y, ore, T_ORE) != 0)
00283 return (1);
00284 return (0);
00285 }
|
|
||||||||||||||||
|
Definition at line 217 of file market.c. 00218 {
00219 int q;
00220 if (numof_markets > 0)
00221 {
00222 for (q = 0; q < numof_markets; q++)
00223 {
00224 if ((abs (marketx[q] - x) < MARKET_RANGE)
00225 && (abs (markety[q] - y) < MARKET_RANGE)
00226 && (MP_INFO(marketx[q],markety[q]).int_6
00227 > steel))
00228 {
00229 MP_INFO(marketx[q],markety[q]).int_6 -= steel;
00230 return (1);
00231 }
00232 }
00233 }
00234 if (get_stuff (x, y, steel, T_STEEL) != 0)
00235 return (1);
00236 return (0);
00237 }
|
|
||||||||||||||||||||
|
Definition at line 720 of file market.c. 00721 {
00722 int res = 0;
00723 Map_Point_Info *minfo = &MP_INFO(x,y);
00724
00725 switch (MP_SIZE(x,y))
00726 {
00727 case 2:
00728 res = get_stuff2 (minfo, stuff, stuff_type);
00729 break;
00730 case 3:
00731 res = get_stuff3 (minfo, stuff, stuff_type);
00732 break;
00733 case 4:
00734 res = get_stuff4 (minfo, stuff, stuff_type);
00735 break;
00736 default:
00737 do_error ("Bad area size in get_stuff()");
00738 }
00739 return (res);
00740 }
|
|
||||||||||||||||
|
Definition at line 757 of file market.c. 00758 {
00759 static int tstart2 = 0;
00760 int i, st, tst, *ip, *stack[8], **ssp; /* stack is a pipe -- (ThMO) */
00761
00762 /* we'll stack our found pointers so to avoid re-looping and
00763 * testing again (ThMO) */
00764
00765 tst = tstart2;
00766
00767 /* can we find enough on the transport? */
00768
00769 for (ssp = stack, st = 0, i = 0; i < 8; i++)
00770 {
00771 if (map[t2[tst]].flags & FLAG_IS_TRANSPORT)
00772 {
00773 ip = &map[t2[tst]].int_1;
00774 ip += stuff_type;
00775 st += *ip;
00776 *ssp++ = ip; /* push it -- (ThMO) */
00777 if (st >= stuff)
00778 {
00779 ssp = stack;
00780 do
00781 {
00782 ip = *ssp++; /* pop it -- (ThMO) */
00783 *ip = (stuff -= *ip) < 0 ? -stuff : 0;
00784 }
00785 while (stuff > 0);
00786 tstart2 = ++tst & 7;
00787 return (1);
00788 }
00789 }
00790 if (++tst >= 8)
00791 tst = 0;
00792 }
00793 return (0);
00794 }
|
|
||||||||||||||||
|
Definition at line 815 of file market.c. 00816 {
00817 static int tstart3 = 0;
00818
00819 int i, st, tst, *ip, *stack[12], **ssp; /* stack is a pipe -- (ThMO) */
00820
00821 /* we'll stack our found pointers so to avoid re-looping and
00822 * testing again
00823 * (ThMO)
00824 */
00825
00826 tst = tstart3;
00827
00828 /* can we find enough on the transport? */
00829
00830 for (ssp = stack, st = 0, i = 0; i < 12; i++)
00831 {
00832 if (map[t3[tst]].flags & FLAG_IS_TRANSPORT)
00833 {
00834 ip = &map[t3[tst]].int_1;
00835 ip += stuff_type;
00836 st += *ip;
00837 *ssp++ = ip; /* push it -- (ThMO) */
00838 if (st >= stuff)
00839 {
00840 ssp = stack;
00841 do
00842 {
00843 ip = *ssp++; /* pop it -- (ThMO) */
00844 *ip = (stuff -= *ip) < 0 ? -stuff : 0;
00845 }
00846 while (stuff > 0);
00847 ++tst;
00848 tstart3 = tst >= 12 ? 0 : tst;
00849 return (1);
00850 }
00851 }
00852 if (++tst >= 12)
00853 tst = 0;
00854 }
00855 return (0);
00856 }
|
|
||||||||||||||||
|
Definition at line 881 of file market.c. 00882 {
00883 static int
00884 tstart4 = 0;
00885
00886 int i, st, tst, *ip, *stack[16], **ssp; /* stack is a pipe -- (ThMO) */
00887
00888 /* we'll stack our found pointers so to avoid re-looping and
00889 * testing again
00890 * (ThMO)
00891 */
00892
00893 tst = tstart4;
00894
00895 /* can we find enough on the transport? */
00896
00897 for (ssp = stack, st = 0, i = 0; i < 16; i++)
00898 {
00899 if (map[t4[tst]].flags & FLAG_IS_TRANSPORT)
00900 {
00901 ip = &map[t4[tst]].int_1;
00902 ip += stuff_type;
00903 st += *ip;
00904 *ssp++ = ip; /* push it -- (ThMO) */
00905 if (st >= stuff)
00906 {
00907 ssp = stack;
00908 do
00909 {
00910 ip = *ssp++; /* pop it -- (ThMO) */
00911 *ip = (stuff -= *ip) < 0 ? -stuff : 0;
00912 }
00913 while (stuff > 0);
00914 tstart4 = ++tst & 15;
00915 return (1);
00916 }
00917 }
00918 if (++tst >= 16)
00919 tst = 0;
00920 }
00921 return (0);
00922 }
|
|
||||||||||||||||
|
Definition at line 193 of file market.c. 00194 {
00195 int q;
00196 if (numof_markets > 0)
00197 {
00198 for (q = 0; q < numof_markets; q++)
00199 {
00200 if ((abs (marketx[q] - x) < MARKET_RANGE)
00201 && (abs (markety[q] - y) < MARKET_RANGE)
00202 && (MP_INFO(marketx[q],markety[q]).int_7
00203 > waste))
00204 {
00205 MP_INFO(marketx[q],markety[q]).int_7 -= waste;
00206 return (1);
00207 }
00208 }
00209 }
00210 if (get_stuff (x, y, waste, T_WASTE) != 0)
00211 return (1);
00212 return (0);
00213 }
|
|
||||||||||||||||
|
Definition at line 336 of file market.c. 00337 {
00338 int q;
00339 if (numof_markets > 0)
00340 {
00341 for (q = 0; q < numof_markets; q++)
00342 {
00343 if (MP_INFO(marketx[q],markety[q]).int_3
00344 >= (MAX_COAL_IN_MARKET - coal))
00345 continue;
00346 if ((abs (marketx[q] - x) < MARKET_RANGE)
00347 && (abs (markety[q] - y) < MARKET_RANGE))
00348 {
00349 MP_INFO(marketx[q],markety[q]).int_3 += coal;
00350 return (1);
00351 }
00352 }
00353 }
00354 if (put_stuff (x, y, coal, T_COAL) != 0)
00355 return (1);
00356 return (0);
00357 }
|
|
||||||||||||||||
|
Definition at line 88 of file market.c. 00089 {
00090 int q;
00091 if (numof_markets > 0)
00092 {
00093 for (q = 0; q < numof_markets; q++)
00094 {
00095 if (MP_INFO(marketx[q],markety[q]).int_1
00096 >= (MAX_FOOD_IN_MARKET - food))
00097 continue;
00098 if ((abs (marketx[q] - x) < ORG_FARM_RANGE)
00099 && (abs (markety[q] - y) < ORG_FARM_RANGE))
00100 {
00101 MP_INFO(marketx[q],markety[q]).int_1 += food;
00102 return (1);
00103 }
00104 }
00105 }
00106 if (put_stuff (x, y, food, T_FOOD) != 0)
00107 return (1);
00108 return (0);
00109 }
|
|
||||||||||||||||
|
Definition at line 145 of file market.c. 00146 {
00147 int q;
00148 if (numof_markets > 0)
00149 {
00150 for (q = 0; q < numof_markets; q++)
00151 {
00152 if (MP_INFO(marketx[q],markety[q]).int_4
00153 >= (MAX_GOODS_IN_MARKET - goods))
00154 continue;
00155 if ((abs (marketx[q] - x) < MARKET_RANGE)
00156 && (abs (markety[q] - y) < MARKET_RANGE))
00157 {
00158 MP_INFO(marketx[q],markety[q]).int_4 += goods;
00159 return (1);
00160 }
00161 }
00162 }
00163 if (put_stuff (x, y, goods, T_GOODS) != 0)
00164 return (1);
00165 return (0);
00166 }
|
|
||||||||||||||||
|
Definition at line 42 of file market.c. 00043 {
00044 int q;
00045 if (numof_markets > 0) {
00046 for (q = 0; q < numof_markets; q++) {
00047 if (MP_INFO(marketx[q],markety[q]).int_2
00048 >= (MAX_JOBS_IN_MARKET - jobs))
00049 continue;
00050 if (abs (marketx[q] - x) < EMPLOYER_RANGE
00051 && abs (markety[q] - y) < EMPLOYER_RANGE)
00052 {
00053 MP_INFO(marketx[q],markety[q]).int_2 += jobs;
00054 return (1);
00055 }
00056 }
00057 }
00058 if (put_stuff (x, y, jobs, T_JOBS) != 0) {
00059 return (1);
00060 }
00061 return (0);
00062 }
|
|
||||||||||||||||
|
Definition at line 288 of file market.c. 00289 {
00290 int q;
00291 if (numof_markets > 0)
00292 {
00293 for (q = 0; q < numof_markets; q++)
00294 {
00295 if (MP_INFO(marketx[q],markety[q]).int_5
00296 >= (MAX_ORE_IN_MARKET - ore))
00297 continue;
00298 if ((abs (marketx[q] - x) < MARKET_RANGE)
00299 && (abs (markety[q] - y) < MARKET_RANGE))
00300 {
00301 MP_INFO(marketx[q],markety[q]).int_5 += ore;
00302 return (1);
00303 }
00304 }
00305 }
00306 if (put_stuff (x, y, ore, T_ORE) != 0)
00307 return (1);
00308 return (0);
00309 }
|
|
||||||||||||||||
|
Definition at line 240 of file market.c. 00241 {
00242 int q;
00243 if (numof_markets > 0)
00244 {
00245 for (q = 0; q < numof_markets; q++)
00246 {
00247 if (MP_INFO(marketx[q],markety[q]).int_6
00248 >= (MAX_STEEL_IN_MARKET - steel))
00249 continue;
00250 if ((abs (marketx[q] - x) < MARKET_RANGE)
00251 && (abs (markety[q] - y) < MARKET_RANGE))
00252 {
00253 MP_INFO(marketx[q],markety[q]).int_6 += steel;
00254 return (1);
00255 }
00256 }
00257 }
00258 if (put_stuff (x, y, steel, T_STEEL) != 0)
00259 return (1);
00260 return (0);
00261 }
|
|
||||||||||||||||||||
|
Definition at line 925 of file market.c. 00926 {
00927 int res = 0;
00928 short *type = &MP_TYPE(x,y);
00929 Map_Point_Info *minfo = &MP_INFO(x,y);
00930 switch (MP_SIZE(x,y))
00931 {
00932 case 2:
00933 res = put_stuff2 (minfo, type, stuff, stuff_type);
00934 break;
00935 case 3:
00936 res = put_stuff3 (minfo, type, stuff, stuff_type);
00937 break;
00938 case 4:
00939 res = put_stuff4 (minfo, type, stuff, stuff_type);
00940 break;
00941 default:
00942 do_error ("Bad area size in put_stuff()");
00943 }
00944 return res;
00945 }
|
|
||||||||||||||||||||
|
Definition at line 968 of file market.c. 00969 {
00970 static int tstart2 = 0;
00971 int i, st, tst, *ip, tp = 0;
00972 struct stack stack[8], *ssp; /* stack is really a pipe -- (ThMO) */
00973
00974 /* we'll stack our found pointers so to avoid re-looping and
00975 * testing again (ThMO) */
00976
00977 tst = tstart2;
00978
00979 /* can we put enough on the transport? */
00980
00981 for (ssp = stack, st = 0, i = 0; i < 8; i++) {
00982 int map_index = t2[tst];
00983 if (minfo[map_index].flags & FLAG_IS_TRANSPORT) {
00984 switch (get_group_of_type(type[map_index]))
00985 {
00986 case GROUP_TRACK:
00987 tp = tmax[0][stuff_type];
00988 break;
00989 case GROUP_ROAD:
00990 tp = tmax[1][stuff_type];
00991 break;
00992 case GROUP_RAIL:
00993 tp = tmax[2][stuff_type];
00994 break;
00995 default:
00996 do_error ("Bad transport type in put_stuff2");
00997 }
00998 ip = &minfo[map_index].int_1;
00999 ssp->ip = ip += stuff_type; /* push it -- (ThMO) */
01000 ssp++->max_val = tp;
01001 st += tp - *ip;
01002 if (st >= stuff) {
01003 ssp = stack;
01004 do {
01005 tp = ssp->max_val - *ssp->ip; /* pop it -- (ThMO) */
01006 if ((stuff -= tp) < 0)
01007 *ssp->ip += tp + stuff; /* == orig. stuff -- (ThMO) */
01008 else
01009 *ssp->ip = ssp->max_val;
01010 ++ssp;
01011 } while (stuff > 0);
01012 tstart2 = ++tst & 7;
01013 return (1);
01014 }
01015 }
01016 if (++tst >= 8)
01017 tst = 0;
01018 }
01019 return (0);
01020 }
|
|
||||||||||||||||||||
|
Definition at line 1024 of file market.c. 01025 {
01026 static int tstart3 = 0;
01027 int i, st, tst, *ip, tp = 0;
01028 struct stack stack[12], *ssp; /* stack is really a pipe -- (ThMO)
01029 we'll stack our found pointers so
01030 to avoid re-looping and
01031 testing again (ThMO) */
01032
01033 tst = tstart3;
01034
01035 /* can we put enough on the transport? */
01036
01037 for (ssp = stack, st = 0, i = 0; i < 12; i++) {
01038 int map_index = t3[tst];
01039 if (minfo[map_index].flags & FLAG_IS_TRANSPORT) {
01040 switch (get_group_of_type(type[map_index]))
01041 {
01042 case GROUP_TRACK:
01043 tp = tmax[0][stuff_type];
01044 break;
01045 case GROUP_ROAD:
01046 tp = tmax[1][stuff_type];
01047 break;
01048 case GROUP_RAIL:
01049 tp = tmax[2][stuff_type];
01050 break;
01051 default:
01052 do_error ("Bad transport type in put_stuff3");
01053 }
01054 ip = &minfo[map_index].int_1;
01055 ssp->ip = ip += stuff_type; /* push it -- (ThMO) */
01056 ssp++->max_val = tp;
01057 st += tp - *ip;
01058 if (st >= stuff) {
01059 ssp = stack;
01060 do {
01061 tp = ssp->max_val - *ssp->ip; /* pop it -- (ThMO) */
01062 if ((stuff -= tp) < 0)
01063 *ssp->ip += tp + stuff; /* == orig. stuff -- (ThMO) */
01064 else
01065 *ssp->ip = ssp->max_val;
01066 ++ssp;
01067 } while (stuff > 0);
01068 ++tst;
01069 tstart3 = tst >= 12 ? 0 : tst;
01070 return (1);
01071 }
01072 }
01073 if (++tst >= 12)
01074 tst = 0;
01075 }
01076 return (0);
01077 }
|
|
||||||||||||||||||||
|
Definition at line 1081 of file market.c. 01082 {
01083 static int tstart4 = 0;
01084 int i, st, tst, *ip, tp = 0;
01085 struct stack stack[16], *ssp; /* stack is really a pipe -- (ThMO)
01086 */
01087 /* we'll stack our found pointers so to avoid re-looping and
01088 * testing again (ThMO) */
01089
01090 tst = tstart4;
01091
01092 /* can we put enough on the transport? */
01093
01094 for (ssp = stack, st = 0, i = 0; i < 16; i++) {
01095 int map_index = t4[tst];
01096 if (minfo[map_index].flags & FLAG_IS_TRANSPORT) {
01097 switch (get_group_of_type(type[map_index]))
01098 {
01099 case GROUP_TRACK:
01100 tp = tmax[0][stuff_type];
01101 break;
01102 case GROUP_ROAD:
01103 tp = tmax[1][stuff_type];
01104 break;
01105 case GROUP_RAIL:
01106 tp = tmax[2][stuff_type];
01107 break;
01108 default:
01109 do_error ("Bad transport type in put_stuff4");
01110 }
01111 ip = &minfo[map_index].int_1;
01112 ssp->ip = ip += stuff_type; /* push it -- (ThMO) */
01113 ssp++->max_val = tp;
01114 st += tp - *ip;
01115 if (st >= stuff) {
01116 ssp = stack;
01117 do {
01118 tp = ssp->max_val - *ssp->ip; /* pop it -- (ThMO) */
01119 if ((stuff -= tp) < 0)
01120 *ssp->ip += tp + stuff; /* == orig. stuff -- (ThMO) */
01121 else
01122 *ssp->ip = ssp->max_val;
01123 ++ssp;
01124 } while (stuff > 0);
01125 tstart4 = ++tst & 15;
01126 return (1);
01127 }
01128 }
01129 if (++tst >= 16)
01130 tst = 0;
01131 }
01132 return (0);
01133 }
|
|
||||||||||||||||
|
Definition at line 169 of file market.c. 00170 {
00171 int q;
00172 if (numof_markets > 0)
00173 {
00174 for (q = 0; q < numof_markets; q++)
00175 {
00176 if (MP_INFO(marketx[q],markety[q]).int_7
00177 >= (MAX_WASTE_IN_MARKET - waste))
00178 continue;
00179 if ((abs (marketx[q] - x) < MARKET_RANGE)
00180 && (abs (markety[q] - y) < MARKET_RANGE))
00181 {
00182 MP_INFO(marketx[q],markety[q]).int_7 += waste;
00183 return (1);
00184 }
00185 }
00186 }
00187 if (put_stuff (x, y, waste, T_WASTE) != 0)
00188 return (1);
00189 return (0);
00190 }
|
|
||||||||||||
|
Definition at line 375 of file market.c. 00376 {
00377 int q;
00378 for (q = 0; q < numof_markets; q++)
00379 if (marketx[q] == x && markety[q] == y)
00380 break;
00381 for (; q < numof_markets; q++)
00382 {
00383 marketx[q] = marketx[q + 1];
00384 markety[q] = markety[q + 1];
00385 }
00386 numof_markets--;
00387 }
|
|
|
Definition at line 461 of file market.c. 00462 {
00463 register int x;
00464 int q, r, m;
00465 m = (numof_markets / 4) + 1;
00466 for (x = 0; x < m; x++)
00467 {
00468 r = rand () % numof_markets;
00469 if (r == x)
00470 continue;
00471 q = marketx[x];
00472 marketx[x] = marketx[r];
00473 marketx[r] = q;
00474 q = markety[x];
00475 markety[x] = markety[r];
00476 markety[r] = q;
00477 }
00478 }
|
|
|
Initial value:
{
-1,
WORLD_SIDE_LEN - 1,
2 * WORLD_SIDE_LEN,
2 * WORLD_SIDE_LEN + 1,
WORLD_SIDE_LEN + 2,
2,
1 - WORLD_SIDE_LEN,
-WORLD_SIDE_LEN
}
|
|
|
Initial value:
{
-1,
WORLD_SIDE_LEN - 1,
2 * WORLD_SIDE_LEN - 1,
3 * WORLD_SIDE_LEN,
3 * WORLD_SIDE_LEN + 1,
3 * WORLD_SIDE_LEN + 2,
2 * WORLD_SIDE_LEN + 3,
WORLD_SIDE_LEN + 3,
3,
2 - WORLD_SIDE_LEN,
1 - WORLD_SIDE_LEN,
-WORLD_SIDE_LEN
}
|
|
|
Initial value:
{
-1,
WORLD_SIDE_LEN - 1,
2 * WORLD_SIDE_LEN - 1,
3 * WORLD_SIDE_LEN - 1,
4 * WORLD_SIDE_LEN,
4 * WORLD_SIDE_LEN + 1,
4 * WORLD_SIDE_LEN + 2,
4 * WORLD_SIDE_LEN + 3,
3 * WORLD_SIDE_LEN + 4,
2 * WORLD_SIDE_LEN + 4,
WORLD_SIDE_LEN + 4,
4,
3 - WORLD_SIDE_LEN,
2 - WORLD_SIDE_LEN,
1 - WORLD_SIDE_LEN,
-WORLD_SIDE_LEN
}
|
|
|
Initial value:
{
{MAX_FOOD_ON_TRACK, MAX_JOBS_ON_TRACK
,MAX_COAL_ON_TRACK, MAX_GOODS_ON_TRACK, MAX_ORE_ON_TRACK
,MAX_STEEL_ON_TRACK, MAX_WASTE_ON_TRACK},
{MAX_FOOD_ON_ROAD, MAX_JOBS_ON_ROAD
,MAX_COAL_ON_ROAD, MAX_GOODS_ON_ROAD, MAX_ORE_ON_ROAD
,MAX_STEEL_ON_ROAD, MAX_WASTE_ON_ROAD},
{MAX_FOOD_ON_RAIL, MAX_JOBS_ON_RAIL
,MAX_COAL_ON_RAIL, MAX_GOODS_ON_RAIL, MAX_ORE_ON_RAIL
,MAX_STEEL_ON_RAIL, MAX_WASTE_ON_RAIL}
}
|
1.3.9.1