1 /* ---------------------------------------------------------------------- *
2  * solar_power.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 <lclib.h>
13 #include <engglobs.h>
14 #include <cliglobs.h>
15 #include <stats.h>
16 #include <power.h>
17 #include <mps.h>
18 #include <solar_power.h>
19 
20 /*** Solar Power ***/
21 
22 /*
23   int_1 is the power to give away,  this must be >= POWER_LINE_CAPACITY
24   for it to pass it to a power line.
25   Not added to if > POWER_LINE_CAPACITY
26   int_2 is the tech level when it was built.
27   int_3 is the rated output
28   int_5 is the current output
29   int_6 is the grid it's on
30   int_7 is a grid mapping timestamp
31 */
32 
33 void
do_power_source(int x,int y)34 do_power_source (int x, int y)
35 {
36     if (get_jobs(x, y, SOLAR_POWER_JOBS)) {
37 	MP_INFO(x,y).int_5 = MP_INFO(x,y).int_3;
38 	grid[MP_INFO(x,y).int_6]->avail_power += MP_INFO(x,y).int_3;
39     } else {
40 	MP_INFO(x,y).int_5 = 0;
41     }
42 }
43 
44 
45 void
mps_solar_power(int x,int y)46 mps_solar_power (int x, int y)
47 {
48   int i = 0;
49 
50   char s[12];
51 
52   mps_store_title(i++,_("Solar"));
53   mps_store_title(i++,_("Power Station"));
54   i++;
55 
56   format_power (s, sizeof(s), MP_INFO(x,y).int_3);
57   mps_store_title(i++,_("Max Output"));
58   mps_store_title(i++,s);
59   i++;
60 
61   format_power (s, sizeof(s), MP_INFO(x,y).int_5);
62   mps_store_title(i++,_("Current Output"));
63   mps_store_title(i++,s);
64   i++;
65 
66   mps_store_sfp(i++,_("Tech"),
67 		MP_INFO(x,y).int_2 * 100.0 / MAX_TECH_LEVEL);
68   mps_store_sd(i++,_("Grid ID"), MP_INFO(x,y).int_6);
69 }
70