forked from bvschaik/julius
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaqueduct.c
66 lines (56 loc) · 1.68 KB
/
aqueduct.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "aqueduct.h"
#include "map/grid.h"
/**
* The aqueduct grid is used in two ways:
* 1) to mark water/no water (0/1, see map/water_supply.c)
* 2) to store image IDs for the aqueduct (0-15)
* This leads to some strange results
*/
static grid_u8 aqueduct;
static grid_u8 aqueduct_backup;
int map_aqueduct_at(int grid_offset)
{
return aqueduct.items[grid_offset];
}
void map_aqueduct_set(int grid_offset, int value)
{
aqueduct.items[grid_offset] = value;
}
void map_aqueduct_remove(int grid_offset)
{
aqueduct.items[grid_offset] = 0;
if (aqueduct.items[grid_offset + map_grid_delta(0, -1)] == 5) {
aqueduct.items[grid_offset + map_grid_delta(0, -1)] = 1;
}
if (aqueduct.items[grid_offset + map_grid_delta(1, 0)] == 6) {
aqueduct.items[grid_offset + map_grid_delta(1, 0)] = 2;
}
if (aqueduct.items[grid_offset + map_grid_delta(0, 1)] == 5) {
aqueduct.items[grid_offset + map_grid_delta(0, 1)] = 3;
}
if (aqueduct.items[grid_offset + map_grid_delta(-1, 0)] == 6) {
aqueduct.items[grid_offset + map_grid_delta(-1, 0)] = 4;
}
}
void map_aqueduct_clear(void)
{
map_grid_clear_u8(aqueduct.items);
}
void map_aqueduct_backup(void)
{
map_grid_copy_u8(aqueduct.items, aqueduct_backup.items);
}
void map_aqueduct_restore(void)
{
map_grid_copy_u8(aqueduct_backup.items, aqueduct.items);
}
void map_aqueduct_save_state(buffer *buf, buffer *backup)
{
map_grid_save_state_u8(aqueduct.items, buf);
map_grid_save_state_u8(aqueduct_backup.items, backup);
}
void map_aqueduct_load_state(buffer *buf, buffer *backup)
{
map_grid_load_state_u8(aqueduct.items, buf);
map_grid_load_state_u8(aqueduct_backup.items, backup);
}