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 "modules.h"
9 #include "mill.h"
10 
do_mill(int x,int y)11 void do_mill(int x, int y)
12 {
13        // int_1 contains the goods at the mill
14        // int_2 contains the food store
15        // int_3 contains the coal store
16        // int_4 unused
17        // int_5 is the % count so far this month
18        // int_6 is the % capacity last month
19        // int_7 unused
20        // MP_ANIM contains the animation trigger time since 1.91
21 
22     /* get food */
23     int block_anim = 0;
24     if (MP_INFO(x, y).int_2 < MAX_FOOD_AT_MILL)
25         if (get_food(x, y, MILL_GET_FOOD) != 0)
26             MP_INFO(x, y).int_2 += MILL_GET_FOOD;
27 
28     /* get coal or power */
29     if (MP_INFO(x, y).int_3 < MAX_COAL_AT_MILL) {
30         if (get_coal(x, y, MILL_GET_COAL) != 0)
31             MP_INFO(x, y).int_3 += MILL_GET_COAL;
32         else if (get_power(x, y, MILL_GET_COAL * MILL_POWER_PER_COAL, 0) != 0)
33             MP_INFO(x, y).int_3 += MILL_GET_COAL;
34     } else {
35         // prevent blinking in minimap: we have power
36         get_power(x,y,0,0);
37     }
38 
39     if (MP_INFO(x, y).int_1 < MAX_GOODS_AT_MILL) {
40         if (MP_INFO(x, y).int_2 > FOOD_USED_BY_MILL && MP_INFO(x, y).int_3 > COAL_USED_BY_MILL) {
41             if (get_jobs(x, y, MILL_JOBS) != 0) {
42                 MP_INFO(x, y).int_2 -= FOOD_USED_BY_MILL;
43                 MP_INFO(x, y).int_3 -= COAL_USED_BY_MILL;
44                 MP_INFO(x, y).int_1 += GOODS_MADE_BY_MILL;
45                 MP_INFO(x, y).int_5++;
46             } else {
47                 MP_TYPE(x, y) = CST_MILL_0;
48                 block_anim = 1;
49             }
50         } else
51             block_anim = 1;
52     }
53 
54     if (MP_INFO(x, y).int_1 > GOODS_MADE_BY_MILL)
55         if (put_goods(x, y, GOODS_MADE_BY_MILL - 1) != 0)
56             MP_INFO(x, y).int_1 -= (GOODS_MADE_BY_MILL - 1);
57 
58     if (total_time % 100 == 0) {
59         MP_INFO(x, y).int_6 = MP_INFO(x, y).int_5;
60         MP_INFO(x, y).int_5 = 0;
61     }
62     if (real_time >= MP_ANIM(x, y) && block_anim == 0) {
63         MP_ANIM(x, y) = real_time + MILL_ANIM_SPEED;
64         switch (MP_TYPE(x, y)) {
65         case (CST_MILL_0):
66             MP_TYPE(x, y) = CST_MILL_1;
67             break;
68         case (CST_MILL_1):
69             MP_TYPE(x, y) = CST_MILL_2;
70             break;
71         case (CST_MILL_2):
72             MP_TYPE(x, y) = CST_MILL_3;
73             break;
74         case (CST_MILL_3):
75             MP_TYPE(x, y) = CST_MILL_4;
76             break;
77         case (CST_MILL_4):
78             MP_TYPE(x, y) = CST_MILL_5;
79             break;
80         case (CST_MILL_5):
81             MP_TYPE(x, y) = CST_MILL_6;
82             break;
83         case (CST_MILL_6):
84             MP_TYPE(x, y) = CST_MILL_1;
85             MP_POL(x, y)++;
86             break;
87         }
88     }
89 }
90 
mps_mill(int x,int y)91 void mps_mill(int x, int y)
92 {
93     int i = 0;
94     mps_store_title(i++, _("Textile Mill"));
95     i++;
96     mps_store_sfp(i++, _("Capacity"), MP_INFO(x, y).int_6);
97     i++;
98     mps_store_title(i++, _("Inventory"));
99     mps_store_sfp(i++, _("Goods"), MP_INFO(x, y).int_1 * 100.0 / MAX_GOODS_AT_MILL);
100     mps_store_sfp(i++, _("Food"), MP_INFO(x, y).int_2 * 100.0 / MAX_FOOD_AT_MILL);
101     mps_store_sfp(i++, _("Coal"), MP_INFO(x, y).int_3 * 100.0 / MAX_COAL_AT_MILL);
102 
103 }
104