-
Notifications
You must be signed in to change notification settings - Fork 54
/
Constructions.cpp
174 lines (167 loc) · 6.48 KB
/
Constructions.cpp
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#include "common.h"
#include "SpriteMaps.h"
#include "Constructions.h"
#include "WorldSegment.h"
#include "df/construction.h"
using namespace std;
using namespace DFHack;
using namespace df::enums;
void changeConstructionMaterials(WorldSegment* segment, vector<df::construction>* allConstructions)
{
//find construction
int32_t i;
Tile* b;
df::construction* construct = 0;
i = (uint32_t) allConstructions->size();
if(i <= 0) {
return;
}
while(--i >= 0) {
construct = &(*allConstructions)[i];
b = segment->getTile(construct->pos.x, construct->pos.y, construct->pos.z);
if( !b ) {
continue;
}
if (b->tileMaterial() != tiletype_material::CONSTRUCTION)
continue;
//don't assign invalid material indexes
//if(construct->mat_idx != -1){
//on second thought, invalid indices are needed.
b->material.type = construct->mat_type;
b->material.index = construct->mat_index;
//}
b->consForm = construct->item_type;
}
}
/**
* Reads an unbuilt construction's tle type to the given block and converts the
* material to "CONSTRUCTION".
*/
bool readConstructionsToTile( Tile* b, const Buildings::t_building* building )
{
if(building->type == df::building_type::Construction) {
df::tiletype constructedTiletype = df::tiletype::Void;
switch(building->construction_type)
{
case construction_type::Fortification:
constructedTiletype = df::tiletype::ConstructedFortification;
break;
case construction_type::Wall:
constructedTiletype = df::tiletype::ConstructedPillar;
break;
case construction_type::Floor:
constructedTiletype = df::tiletype::ConstructedFloor;
break;
case construction_type::UpStair:
constructedTiletype = df::tiletype::ConstructedStairU;
break;
case construction_type::DownStair:
constructedTiletype = df::tiletype::ConstructedStairD;
break;
case construction_type::UpDownStair:
constructedTiletype = df::tiletype::ConstructedStairUD;
break;
case construction_type::Ramp:
constructedTiletype = df::tiletype::ConstructedRamp;
break;
case construction_type::TrackN:
constructedTiletype = df::tiletype::ConstructedFloorTrackN;
break;
case construction_type::TrackS:
constructedTiletype = df::tiletype::ConstructedFloorTrackS;
break;
case construction_type::TrackE:
constructedTiletype = df::tiletype::ConstructedFloorTrackE;
break;
case construction_type::TrackW:
constructedTiletype = df::tiletype::ConstructedFloorTrackW;
break;
case construction_type::TrackNS:
constructedTiletype = df::tiletype::ConstructedFloorTrackNS;
break;
case construction_type::TrackNE:
constructedTiletype = df::tiletype::ConstructedFloorTrackNE;
break;
case construction_type::TrackNW:
constructedTiletype = df::tiletype::ConstructedFloorTrackNW;
break;
case construction_type::TrackSE:
constructedTiletype = df::tiletype::ConstructedFloorTrackSE;
break;
case construction_type::TrackSW:
constructedTiletype = df::tiletype::ConstructedFloorTrackSW;
break;
case construction_type::TrackEW:
constructedTiletype = df::tiletype::ConstructedFloorTrackEW;
break;
case construction_type::TrackNSE:
constructedTiletype = df::tiletype::ConstructedFloorTrackNSE;
break;
case construction_type::TrackNSW:
constructedTiletype = df::tiletype::ConstructedFloorTrackNSW;
break;
case construction_type::TrackNEW:
constructedTiletype = df::tiletype::ConstructedFloorTrackNEW;
break;
case construction_type::TrackSEW:
constructedTiletype = df::tiletype::ConstructedFloorTrackSEW;
break;
case construction_type::TrackNSEW:
constructedTiletype = df::tiletype::ConstructedFloorTrackNSEW;
break;
case construction_type::TrackRampN:
constructedTiletype = df::tiletype::ConstructedRampTrackN;
break;
case construction_type::TrackRampS:
constructedTiletype = df::tiletype::ConstructedRampTrackS;
break;
case construction_type::TrackRampE:
constructedTiletype = df::tiletype::ConstructedRampTrackE;
break;
case construction_type::TrackRampW:
constructedTiletype = df::tiletype::ConstructedRampTrackW;
break;
case construction_type::TrackRampNS:
constructedTiletype = df::tiletype::ConstructedRampTrackNS;
break;
case construction_type::TrackRampNE:
constructedTiletype = df::tiletype::ConstructedRampTrackNE;
break;
case construction_type::TrackRampNW:
constructedTiletype = df::tiletype::ConstructedRampTrackNW;
break;
case construction_type::TrackRampSE:
constructedTiletype = df::tiletype::ConstructedRampTrackSE;
break;
case construction_type::TrackRampSW:
constructedTiletype = df::tiletype::ConstructedRampTrackSW;
break;
case construction_type::TrackRampEW:
constructedTiletype = df::tiletype::ConstructedRampTrackEW;
break;
case construction_type::TrackRampNSE:
constructedTiletype = df::tiletype::ConstructedRampTrackNSE;
break;
case construction_type::TrackRampNSW:
constructedTiletype = df::tiletype::ConstructedRampTrackNSW;
break;
case construction_type::TrackRampNEW:
constructedTiletype = df::tiletype::ConstructedRampTrackNEW;
break;
case construction_type::TrackRampSEW:
constructedTiletype = df::tiletype::ConstructedRampTrackSEW;
break;
case construction_type::TrackRampNSEW:
constructedTiletype = df::tiletype::ConstructedRampTrackNSEW;
break;
default:
//do nothing
break;
}
b->material.type = CONSTRUCTION;
b->material.index = INVALID_INDEX;
b->tileType = constructedTiletype;
return true;
}
return false;
}