1 #include "building/roadblock.h"
2 
3 #include "building/building.h"
4 #include "building/type.h"
5 
6 
7 
8 
9 
building_roadblock_set_permission(roadblock_permission p,building * b)10 void building_roadblock_set_permission(roadblock_permission p, building* b) {
11     if (building_type_is_roadblock(b->type)) {
12         int permission_bit = 1 << p;
13         b->data.roadblock.exceptions ^= permission_bit;
14     }
15 }
16 
building_roadblock_get_permission(roadblock_permission p,building * b)17 int building_roadblock_get_permission(roadblock_permission p, building* b) {
18     if (!building_type_is_roadblock(b->type)) {
19         return 0;
20     }
21     int permission_bit = 1 << p;
22     return (b->data.roadblock.exceptions & permission_bit);
23 }
24 
building_type_is_roadblock(building_type type)25 int building_type_is_roadblock(building_type type)
26 {
27     switch (type) {
28         case BUILDING_ROADBLOCK:
29         case BUILDING_GARDEN_WALL_GATE:
30             return 1;
31         default:
32             return 0;
33     }
34 }
35