1 /* ---------------------------------------------------------------------- *
2  * power_line.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 <power.h>
16 #include <mps.h>
17 #include <power_line.h>
18 
19 
20 /*** Power Lines ***/
21 /*
22   int_5 is animation schedule
23   int_6 is the grid it is on
24   int_7 is a grid timestamp
25 */
26 void
do_power_line(int x,int y)27 do_power_line (int x, int y)
28 {
29     if (grid[MP_INFO(x,y).int_6]->powered == -1)
30 	return;
31 
32     switch(MP_INFO(x,y).int_5)
33     {
34     case 0:
35 	MP_INFO(x,y).int_5 = POWER_MODULUS;
36 	break;
37     case 1:
38 	if (!(MP_TYPE(x,y) <= 11 && MP_TYPE(x,y) >= 1))
39 	    break;
40 	MP_TYPE(x,y) += 11;
41 	break;
42     case 2:
43 	if (!(MP_TYPE(x,y) >= 11 && MP_TYPE(x,y) <= 22))
44 	    break;
45 	MP_TYPE(x,y) -= 11;
46 	break;
47     }
48 
49     MP_INFO(x,y).int_5--;
50 }
51 
52 void
mps_power_line(int x,int y)53 mps_power_line (int x, int y)
54 {
55   int i = 0;
56 
57   mps_store_title(i++,_("Power Line"));
58   i++;
59 
60   mps_store_sd(i++,_("Grid ID"),MP_INFO(x,y).int_6);
61 }
62