1 #ifndef _POWER_H 2 #define _POWER_H 3 4 #undef DEBUG_POWER 5 6 struct grid_struct { 7 int power_lines; 8 long total_power; 9 long avail_power; /* Capacity available */ 10 long max_power; 11 long demand; 12 short powered; 13 }; 14 15 typedef struct grid_struct Grid; 16 17 /* public */ 18 #define MAX_GRIDS 128 // How many grids in the array, not how many to allocate 19 extern Grid * grid[MAX_GRIDS]; 20 21 void map_power_grid(void); 22 int get_power (int x, int y, int power, int block_industry); 23 void do_windmill(int x, int y); 24 void do_power_substation(int x, int y); 25 void do_power_source(int x, int y); 26 void do_power_source_coal(int x, int y); 27 void do_power_line(int x, int y); 28 void power_time_step (); 29 30 /* intended private */ 31 void recurse_power_grid (int startx, int starty, int steps); 32 int check_grid(int x, int y, int xi, int yi); 33 void project_power(int x, int y); 34 35 /* #ifdef POWER_LINE_CAPACITY 36 #undef POWER_LINE_CAPACITY 37 #endif */ 38 39 #define POWER_LINE_LOSS 1 /* one KW */ 40 #define POWER_MODULUS 25 /* Controls how often we see a packet in anim */ 41 42 #define WEST 1 43 #define NORTH 2 44 #define EAST 3 45 #define SOUTH 4 46 47 #define XY_IS_GRID(x,y) \ 48 ((MP_GROUP(x,y) == GROUP_COAL_POWER) ||\ 49 (MP_GROUP(x,y) == GROUP_WINDMILL) || \ 50 (MP_GROUP(x,y) == GROUP_POWER_LINE) || \ 51 (MP_GROUP(x,y) == GROUP_SOLAR_POWER) || \ 52 (MP_GROUP(x,y) == GROUP_SUBSTATION)) 53 54 #define XY_IS_WATER(x,y) (MP_GROUP(x,y) == GROUP_WATER) 55 56 #define IS_POWER_SOURCE(x,y) \ 57 ((MP_GROUP(x,y) == GROUP_COAL_POWER) || \ 58 (MP_GROUP(x,y) == GROUP_SOLAR_POWER) || \ 59 (MP_GROUP(x,y) == GROUP_WINDMILL)) 60 61 #define IS_POWER_LINE(x,y) (MP_GROUP(x,y) == GROUP_POWER_LINE) 62 63 #define IS_OLD_WINDMILL(x,y) \ 64 ((MP_GROUP(x,y) == GROUP_WINDMILL) && \ 65 (MP_TYPE(x,y) != CST_USED) && \ 66 (MP_INFO(x,y).int_2 < MODERN_WINDMILL_TECH)) 67 68 #define GRID_CURRENT(x,y) (MP_INFO(x,y).int_7 == grid_inc) 69 70 /*** JOBS ***/ 71 #define SOLAR_POWER_JOBS 50 72 73 #endif 74