1 /* ---------------------------------------------------------------------- *
2 * mill.c
3 * This file is part of lincity.
4 * Lincity is copyright (c) I J Peters 1995-1997, (c) Greg Sharp 1997-2001.
5 * (c) Corey Keasling, 2004
6 * ---------------------------------------------------------------------- */
7
8 #include <lin-city.h>
9 #include <lctypes.h>
10 #include <lcintl.h>
11 #include <lcconfig.h>
12 #include <engglobs.h>
13 #include <cliglobs.h>
14 #include <stats.h>
15 #include <mps.h>
16 #include <mill.h>
17
18
19 void
do_mill(int x,int y)20 do_mill (int x, int y)
21 {
22 /*
23 // int_1 contains the goods at the mill
24 // int_2 contains the food store
25 // int_3 contains the coal store
26 // int_4 contains the animation trigger time
27 // int_5 is the % count so far this month
28 // int_6 is the % capacity last month
29 */
30 /* get food */
31 int block_anim = 0;
32 if (MP_INFO(x,y).int_2 < MAX_FOOD_AT_MILL)
33 if (get_food (x, y, MILL_GET_FOOD) != 0)
34 MP_INFO(x,y).int_2 += MILL_GET_FOOD;
35 /* get coal */
36 if (MP_INFO(x,y).int_3 < MAX_COAL_AT_MILL)
37 {
38 if (get_coal (x, y, MILL_GET_COAL) != 0)
39 MP_INFO(x,y).int_3 += MILL_GET_COAL;
40 else if (get_power (x, y, MILL_GET_COAL
41 * MILL_POWER_PER_COAL, 0) != 0)
42 MP_INFO(x,y).int_3 += MILL_GET_COAL;
43 }
44 if (MP_INFO(x,y).int_1 < MAX_GOODS_AT_MILL)
45 {
46 if (MP_INFO(x,y).int_2 > FOOD_USED_BY_MILL
47 && MP_INFO(x,y).int_3 > COAL_USED_BY_MILL)
48 {
49 if (get_jobs (x, y, MILL_JOBS) != 0)
50 {
51 MP_INFO(x,y).int_2 -= FOOD_USED_BY_MILL;
52 MP_INFO(x,y).int_3 -= COAL_USED_BY_MILL;
53 MP_INFO(x,y).int_1 += GOODS_MADE_BY_MILL;
54 MP_INFO(x,y).int_5++;
55 }
56 else
57 {
58 MP_TYPE(x,y) = CST_MILL_0;
59 block_anim = 1;
60 }
61 }
62 else
63 block_anim = 1;
64 }
65
66 if (MP_INFO(x,y).int_1 > 0)
67 if (put_goods (x, y, MP_INFO(x,y).int_1) != 0)
68 MP_INFO(x,y).int_1 = 0;
69
70 if (total_time % 100 == 0)
71 {
72 MP_INFO(x,y).int_6 = MP_INFO(x,y).int_5;
73 MP_INFO(x,y).int_5 = 0;
74 }
75 if (real_time >= MP_INFO(x,y).int_4 && block_anim == 0)
76 {
77 MP_INFO(x,y).int_4 = real_time + MILL_ANIM_SPEED;
78 switch (MP_TYPE(x,y))
79 {
80 case (CST_MILL_0):
81 MP_TYPE(x,y) = CST_MILL_1;
82 break;
83 case (CST_MILL_1):
84 MP_TYPE(x,y) = CST_MILL_2;
85 break;
86 case (CST_MILL_2):
87 MP_TYPE(x,y) = CST_MILL_3;
88 break;
89 case (CST_MILL_3):
90 MP_TYPE(x,y) = CST_MILL_4;
91 break;
92 case (CST_MILL_4):
93 MP_TYPE(x,y) = CST_MILL_5;
94 break;
95 case (CST_MILL_5):
96 MP_TYPE(x,y) = CST_MILL_6;
97 break;
98 case (CST_MILL_6):
99 MP_TYPE(x,y) = CST_MILL_1;
100 MP_POL(x,y)++;
101 break;
102 }
103 }
104 }
105
106 void
mps_mill(int x,int y)107 mps_mill (int x, int y)
108 {
109 int i = 0;
110 mps_store_title(i++,_("Textile Mill"));
111 i++;
112 mps_store_sfp(i++,_("Capacity"), MP_INFO(x,y).int_6);
113 i++;
114 mps_store_title(i++,_("Inventory"));
115 mps_store_sfp(i++,_("Goods"),
116 MP_INFO(x,y).int_1 * 100.0 / MAX_GOODS_AT_MILL);
117 mps_store_sfp(i++,_("Food"),
118 MP_INFO(x,y).int_2 * 100.0 / MAX_FOOD_AT_MILL);
119 mps_store_sfp(i++,_("Coal"),
120 MP_INFO(x,y).int_3 * 100.0 / MAX_COAL_AT_MILL);
121
122 }
123