1 /* ---------------------------------------------------------------------- *
2  * health_centre.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 <health_centre.h>
17 
18 
19 void
do_health_centre(int x,int y)20 do_health_centre (int x, int y)
21 {
22   /*
23      // int_1 is the jobs stored at the health centre
24      // int_2 is the goods stored at the health centre
25    */
26   if (MP_INFO(x,y).int_1
27       < (MAX_JOBS_AT_HEALTH_CENTRE - HEALTH_CENTRE_GET_JOBS))
28     if (get_jobs (x, y, HEALTH_CENTRE_GET_JOBS) != 0)
29       MP_INFO(x,y).int_1 += HEALTH_CENTRE_GET_JOBS;
30   if (MP_INFO(x,y).int_2
31       < (MAX_GOODS_AT_HEALTH_CENTRE - HEALTH_CENTRE_GET_GOODS))
32     if (get_goods (x, y, HEALTH_CENTRE_GET_GOODS) != 0)
33       MP_INFO(x,y).int_2 += HEALTH_CENTRE_GET_GOODS;
34 
35   /* That's all. Cover is done by different functions every 3 months or so. */
36 
37   health_cost += HEALTH_RUNNING_COST;
38 }
39 
40 
41 void
do_health_cover(int x,int y)42 do_health_cover (int x, int y)
43 {
44   int xx, x1, x2, y1, y2;
45   if (MP_INFO(x,y).int_1 < (HEALTH_CENTRE_JOBS * DAYS_BETWEEN_COVER) ||
46       MP_INFO(x,y).int_2 < (HEALTH_CENTRE_GOODS * DAYS_BETWEEN_COVER))
47     return;
48   MP_INFO(x,y).int_1 -= (HEALTH_CENTRE_JOBS * DAYS_BETWEEN_COVER);
49   MP_INFO(x,y).int_2 -= (HEALTH_CENTRE_GOODS * DAYS_BETWEEN_COVER);
50   x1 = x - HEALTH_CENTRE_RANGE;
51   if (x1 < 0)
52     x1 = 0;
53   x2 = x + HEALTH_CENTRE_RANGE;
54   if (x2 > WORLD_SIDE_LEN)
55     x2 = WORLD_SIDE_LEN;
56   y1 = y - HEALTH_CENTRE_RANGE;
57   if (y1 < 0)
58     y1 = 0;
59   y2 = y + HEALTH_CENTRE_RANGE;
60   if (y2 > WORLD_SIDE_LEN)
61     y2 = WORLD_SIDE_LEN;
62   for (; y1 < y2; y1++)
63     for (xx = x1; xx < x2; xx++)
64       MP_INFO(xx,y1).flags |= FLAG_HEALTH_COVER;
65 }
66 
67 
68 void
mps_health_centre(int x,int y)69 mps_health_centre (int x, int y)
70 {
71     int i = 0;
72 
73     mps_store_title(i++,_("Health Centre"));
74     i++;
75     mps_store_title(i++,_("Inventory"));
76     mps_store_sfp(i++,_("Jobs"),
77 		  MP_INFO(x,y).int_1 * 100.0 / MAX_JOBS_AT_HEALTH_CENTRE);
78     mps_store_sfp(i++,_("Goods"),
79 		  MP_INFO(x,y).int_2 * 100.0 / MAX_GOODS_AT_HEALTH_CENTRE);
80 
81 }
82