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