1 /* ---------------------------------------------------------------------- *
2  * tip.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 <mps.h>
15 #include <engine.h>
16 #include <stats.h>
17 #include <tip.h>
18 
19 
20 
21 void
do_tip(int x,int y)22 do_tip (int x, int y)
23 {
24   /*
25      // int_1 is the amount of waste on the site.
26      // int_2 if the amount that has flowed in so far this month
27      // int_3 is the amount stored last month.
28      // int_4 counts up starting when tip fills, controlling how
29               long until the land is useful again.
30    */
31   int i;
32 
33 /* XXX: put this in a header somewhere */
34 
35 /* If the tip is full, age it until it degrades into useful soil */
36 
37   if (MP_TYPE(x,y) == CST_TIP_8) {
38       MP_INFO(x,y).int_4++;
39       if (MP_INFO(x,y).int_4 >= TIP_DEGRADE_TIME) {
40 	  do_bulldoze_area(CST_GREEN,x,y);
41       }
42       return;
43   }
44 
45   /* just grab as much as we can from transport */
46   if (x > 0 && (MP_INFO(x - 1,y).flags & FLAG_IS_TRANSPORT) != 0)
47     {
48       i = MP_INFO(x - 1,y).int_7 / 10;
49       MP_INFO(x,y).int_1 += i;
50       MP_INFO(x,y).int_2 += i;
51       MP_INFO(x - 1,y).int_7 -= i * 10;
52       sust_dig_ore_coal_tip_flag = 0;
53     }
54   if (y > 0 && (MP_INFO(x,y - 1).flags & FLAG_IS_TRANSPORT) != 0)
55     {
56       i = MP_INFO(x,y - 1).int_7 / 10;
57       MP_INFO(x,y).int_1 += i;
58       MP_INFO(x,y).int_2 += i;
59       MP_INFO(x,y - 1).int_7 -= i * 10;
60       sust_dig_ore_coal_tip_flag = 0;
61     }
62 
63 #if defined (commentout)
64   /* Increment the "ore" reserve; this prevents a new tip from being
65      built on top of a degraded one. */
66   MP_INFO(x,y).ore_reserve++;
67 #endif
68 
69   /* now choose an icon. */
70   if ((total_time % NUMOF_DAYS_IN_MONTH) == 0)
71     {
72       i = (MP_INFO(x,y).int_1 * 7) / MAX_WASTE_AT_TIP;
73       if (MP_INFO(x,y).int_1 > 0)
74 	i++;
75       switch (i)
76 	{
77 	case (0):
78 	  MP_TYPE(x,y) = CST_TIP_0;
79 	  break;
80 	case (1):
81 	  MP_TYPE(x,y) = CST_TIP_1;
82 	  break;
83 	case (2):
84 	  MP_TYPE(x,y) = CST_TIP_2;
85 	  break;
86 	case (3):
87 	  MP_TYPE(x,y) = CST_TIP_3;
88 	  break;
89 	case (4):
90 	  MP_TYPE(x,y) = CST_TIP_4;
91 	  break;
92 	case (5):
93 	  MP_TYPE(x,y) = CST_TIP_5;
94 	  break;
95 	case (6):
96 	  MP_TYPE(x,y) = CST_TIP_6;
97 	  break;
98 	case (7):
99 	  MP_TYPE(x,y) = CST_TIP_7;
100 	  break;
101 	case (8):
102 	  MP_TYPE(x,y) = CST_TIP_8;
103 	  MP_INFO(x,y).int_2 = 0;
104 	  MP_INFO(x,y).int_4 = 0;
105 	  break;
106 
107 	}
108       MP_INFO(x,y).int_3 = MP_INFO(x,y).int_2;
109       MP_INFO(x,y).int_2 = 0;
110     }
111 }
112 
113 void
mps_tip(int x,int y)114 mps_tip (int x, int y)
115 {
116   int i = 0;
117 
118   mps_store_title(i++,_("Landfill"));
119   i++;
120 
121   mps_store_title(i++,_("Last Month"));
122   mps_store_sd(i++,_("Tons"), MP_INFO(x,y).int_3);
123   mps_store_sfp(i++,_("Percent"),
124 	       MP_INFO(x,y).int_3 * 100.0 / MAX_WASTE_AT_TIP);
125   i++;
126   mps_store_title(i++,_("% Filled"));
127   mps_store_fp(i++,
128 	       MP_INFO(x,y).int_1 * 100.0 / MAX_WASTE_AT_TIP);
129 }
130