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