1 /* ---------------------------------------------------------------------- *
2  * pottery.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 "pottery.h"
10 
do_pottery(int x,int y)11 void do_pottery(int x, int y)
12 {
13     /*
14        // int_1 contains the goods at the pottery
15        // int_2 contains the ore at the pottery
16        // int_3 contains the coal at the pottery
17        // int_4 unused
18        // int_5 is the % made so far this month or the close time if negative
19        // int_6 is the % capacity last month
20        // int_7 contains the jobs stored at the pottery
21        // MP_ANIM is the animation trigger time since 1.91
22      */
23     if (MP_INFO(x, y).int_5 < 0) {
24         MP_INFO(x, y).int_5++;
25         return;
26     }
27     if (MP_INFO(x, y).int_1 < (MAX_GOODS_AT_POTTERY - POTTERY_MADE_GOODS)) {
28         if (MP_INFO(x, y).int_2 < (MAX_ORE_AT_POTTERY - POTTERY_GET_ORE))
29             if (get_ore(x, y, POTTERY_GET_ORE) != 0)
30                 MP_INFO(x, y).int_2 += POTTERY_GET_ORE;
31         if (MP_INFO(x, y).int_3 < (MAX_COAL_AT_POTTERY - POTTERY_GET_COAL))
32             if (get_coal(x, y, POTTERY_GET_COAL) != 0)
33                 MP_INFO(x, y).int_3 += POTTERY_GET_COAL;
34         if (MP_INFO(x, y).int_7 < (MAX_JOBS_AT_POTTERY - POTTERY_GET_JOBS))
35             if (get_jobs(x, y, POTTERY_GET_JOBS) != 0)
36                 MP_INFO(x, y).int_7 += POTTERY_GET_JOBS;
37 
38         if (MP_INFO(x, y).int_2 > POTTERY_ORE_MAKE_GOODS
39             && MP_INFO(x, y).int_3 > POTTERY_COAL_MAKE_GOODS && MP_INFO(x, y).int_7 > POTTERY_JOBS) {
40             MP_INFO(x, y).int_1 += POTTERY_MADE_GOODS;
41             MP_INFO(x, y).int_2 -= POTTERY_ORE_MAKE_GOODS;
42             MP_INFO(x, y).int_3 -= POTTERY_COAL_MAKE_GOODS;
43             MP_INFO(x, y).int_7 -= POTTERY_JOBS;
44             MP_INFO(x, y).int_5++;
45         } else {
46             MP_TYPE(x, y) = CST_POTTERY_1;
47             MP_INFO(x, y).int_6 = 0;
48             MP_INFO(x, y).int_5 = -POTTERY_CLOSE_TIME;
49             return;
50         }
51     }
52     if (MP_INFO(x, y).int_1 > 0)
53         if (put_goods(x, y, MP_INFO(x, y).int_1) != 0)
54             MP_INFO(x, y).int_1 = 0;
55 
56     if (total_time % 100 == 0) {
57         MP_INFO(x, y).int_6 = MP_INFO(x, y).int_5;
58         MP_INFO(x, y).int_5 = 0;
59     }
60     if (real_time >= MP_ANIM(x, y) /* && block_anim==0 */ ) {
61         MP_ANIM(x, y) = real_time + POTTERY_ANIM_SPEED;
62         switch (MP_TYPE(x, y)) {
63         case (CST_POTTERY_0):
64             MP_TYPE(x, y) = CST_POTTERY_1;
65             break;
66         case (CST_POTTERY_1):
67             MP_TYPE(x, y) = CST_POTTERY_2;
68             break;
69         case (CST_POTTERY_2):
70             MP_TYPE(x, y) = CST_POTTERY_3;
71             break;
72         case (CST_POTTERY_3):
73             MP_TYPE(x, y) = CST_POTTERY_4;
74             break;
75         case (CST_POTTERY_4):
76             MP_TYPE(x, y) = CST_POTTERY_5;
77             break;
78         case (CST_POTTERY_5):
79             MP_TYPE(x, y) = CST_POTTERY_6;
80             break;
81         case (CST_POTTERY_6):
82             MP_TYPE(x, y) = CST_POTTERY_7;
83             break;
84         case (CST_POTTERY_7):
85             MP_TYPE(x, y) = CST_POTTERY_8;
86             break;
87         case (CST_POTTERY_8):
88             MP_TYPE(x, y) = CST_POTTERY_9;
89             break;
90         case (CST_POTTERY_9):
91             MP_TYPE(x, y) = CST_POTTERY_10;
92             break;
93         case (CST_POTTERY_10):
94             MP_TYPE(x, y) = CST_POTTERY_1;
95             MP_POL(x, y)++;
96             break;
97         }
98     }
99 }
100 
mps_pottery(int x,int y)101 void mps_pottery(int x, int y)
102 {
103     int i = 0;
104 
105     mps_store_title(i++, _("Pottery"));
106     i++;
107     mps_store_sfp(i++, _("Capacity"), MP_INFO(x, y).int_6 * 1.0);
108     i++;
109     mps_store_title(i++, _("Inventory"));
110     mps_store_sfp(i++, _("Jobs"), MP_INFO(x, y).int_7 * 100.0 / MAX_JOBS_AT_POTTERY);
111     mps_store_sfp(i++, _("Goods"), MP_INFO(x, y).int_1 * 100.0 / MAX_GOODS_AT_POTTERY);
112     mps_store_sfp(i++, _("Ore"), MP_INFO(x, y).int_2 * 100.0 / MAX_ORE_AT_POTTERY);
113     mps_store_sfp(i++, _("Coal"), MP_INFO(x, y).int_3 * 100.0 / MAX_COAL_AT_POTTERY);
114 }
115