forked from tech-squares/sd
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.cpp
More file actions
307 lines (289 loc) · 8.87 KB
/
Copy pathcommon.cpp
File metadata and controls
307 lines (289 loc) · 8.87 KB
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
// -*- mode:c++; indent-tabs-mode:nil; c-basic-offset:3; fill-column:88 -*-
// SD -- square dance caller's helper.
//
// Copyright (C) 1990-2010 William B. Ackerman.
//
// This file is part of "Sd".
//
// Sd is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Sd is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
// License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Sd; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// This is for version 37.
#include "sd.h"
// These combinations are not allowed.
#define FORBID1 (INHERITFLAG_FRACTAL|INHERITFLAG_YOYOETCMASK)
#define FORBID2 (INHERITFLAG_SINGLEFILE|INHERITFLAG_SINGLE)
#define FORBID3 (INHERITFLAG_MXNMASK|INHERITFLAG_NXNMASK)
#define FORBID4 (INHERITFLAG_12_MATRIX|INHERITFLAG_16_MATRIX)
bool do_heritflag_merge(uint32 *dest, uint32 source)
{
uint32 revertsource = source & INHERITFLAG_REVERTMASK;
if (revertsource) {
// If the source is a revert/reflect bit, things are complicated.
uint32 revertdest = *dest & INHERITFLAG_REVERTMASK;
if (!revertdest) {
goto good;
}
else if (revertsource == INHERITFLAGRVRTK_REVERT &&
revertdest == INHERITFLAGRVRTK_REFLECT) {
*dest &= ~INHERITFLAG_REVERTMASK;
*dest |= INHERITFLAGRVRTK_RFV;
return false;
}
else if (revertsource == INHERITFLAGRVRTK_REFLECT &&
revertdest == INHERITFLAGRVRTK_REVERT) {
*dest &= ~INHERITFLAG_REVERTMASK;
*dest |= INHERITFLAGRVRTK_RVF;
return false;
}
else if (revertsource == INHERITFLAGRVRTK_REFLECT &&
revertdest == INHERITFLAGRVRTK_REFLECT) {
*dest &= ~INHERITFLAG_REVERTMASK;
*dest |= INHERITFLAGRVRTK_RFF;
return false;
}
else if (revertsource == INHERITFLAGRVRTK_REVERT &&
revertdest == INHERITFLAGRVRTK_RVF) {
*dest &= ~INHERITFLAG_REVERTMASK;
*dest |= INHERITFLAGRVRTK_RVFV;
return false;
}
else if (revertsource == INHERITFLAGRVRTK_REFLECT &&
revertdest == INHERITFLAGRVRTK_RFV) {
*dest &= ~INHERITFLAG_REVERTMASK;
*dest |= INHERITFLAGRVRTK_RFVF;
return false;
}
else
return true;
}
// Check for plain redundancy. If this is a bit in one of the complex
// fields, this simple test may not catch the error, but the next one will.
if (*dest & source)
return true;
if (((*dest & FORBID1) && (source & FORBID1)) ||
((*dest & FORBID2) && (source & FORBID2)) ||
((*dest & FORBID3) && (source & FORBID3)) ||
((*dest & FORBID4) && (source & FORBID4)))
return true;
good:
*dest |= source;
return false;
}
// BEWARE!! This list is keyed to the definition of "begin_kind" in sd.h .
int begin_sizes[] = {
0, // b_nothing
1, // b_1x1
2, // b_1x2
2, // b_2x1
3, // b_1x3
3, // b_3x1
4, // b_2x2
4, // b_dmd
4, // b_pmd
4, // b_star
6, // b_trngl
6, // b_ptrngl
8, // b_trngl4
8, // b_ptrngl4
10, // b_beehive,
10, // b_pbeehive,
10, // b_vee,
10, // b_pvee,
16, // b_trngl8
16, // b_ptrngl8
6, // b_bone6
6, // b_pbone6
6, // b_short6
6, // b_pshort6
6, // b_1x2dmd
6, // b_p1x2dmd
6, // b_2x1dmd
6, // b_p2x1dmd
6, // b_wingedstar6
6, // b_pwingedstar6
8, // b_qtag
8, // b_pqtag
8, // b_bone
8, // b_pbone
8, // b_rigger
8, // b_prigger
9, // b_3x3
8, // b_2stars
8, // b_p2stars
8, // b_spindle
8, // b_pspindle
8, // b_hrglass
8, // b_phrglass
8, // b_dhrglass
8, // b_pdhrglass
8, // b_crosswave
8, // b_pcrosswave
4, // b_1x4
4, // b_4x1
8, // b_1x8
8, // b_8x1
8, // b_2x4
8, // b_4x2
6, // b_2x3
6, // b_3x2
10, // b_2x5
10, // b_5x2
10, // b_d2x5
10, // b_d5x2
10, // b_wqtag
10, // b_pwqtag
10, // b_deep2x1dmd
10, // b_pdeep2x1dmd
10, // b_whrglass
10, // b_pwhrglass
5, // b_1x5
5, // b_5x1
6, // b_1x6
6, // b_6x1
12, // b_3x4
12, // b_4x3
12, // b_2x6
12, // b_6x2
14, // b_2x7
14, // b_7x2
14, // b_d2x7
14, // b_d7x2
18, // b_2x9
18, // b_9x2
12, // b_d3x4
12, // b_d4x3
20, // b_d4x5
20, // b_d5x4
10, // b_spindle12
10, // b_pspindle12
16, // b_2x8
16, // b_8x2
16, // b_4x4
10, // b_1x10
10, // b_10x1
12, // b_1x12
12, // b_12x1
14, // b_1x14
14, // b_14x1
16, // b_1x16
16, // b_16x1
16, // b_c1phan
8, // b_galaxy
18, // b_3x6
18, // b_6x3
24, // b_3x8
24, // b_8x3
20, // b_4x5
20, // b_5x4
24, // b_4x6
24, // b_6x4
20, // b_2x10
20, // b_10x2
24, // b_2x12
24, // b_12x2
12, // b_deepqtg
12, // b_pdeepqtg
16, // b_deepbigqtg
16, // b_pdeepbigqtg
12, // b_widerigger
12, // b_pwiderigger
12, // b_rigger12
12, // b_prigger12
12, // b_deepxwv
12, // b_pdeepxwv
20, // b_3oqtg
20, // b_p3oqtg
8, // b_thar
8, // b_alamo
8, // b_ptpd
8, // b_pptpd
8, // b_1x3dmd
8, // b_p1x3dmd
8, // b_3x1dmd
8, // b_p3x1dmd
12, // b_3dmd
12, // b_p3dmd
16, // b_4dmd
16, // b_p4dmd
12, // b_3ptpd
12, // b_p3ptpd
16, // b_4ptpd
16, // b_p4ptpd
16, // b_hqtag
16, // b_phqtag
12, // b_hsqtag
12, // b_phsqtag
8, // b_wingedstar
8, // b_pwingedstar
8, // b_323
8, // b_p323
10, // b_343
10, // b_p343
12, // b_525
12, // b_p525
14, // b_545
14, // b_p545
14, // bh545
14, // bhp545
12, // b_23232
12, // b_p23232
12, // b_3mdmd
12, // b_p3mdmd
12, // b_3mptpd
12, // b_p3mptpd
16, // b_4mdmd
16, // b_p4mdmd
16, // b_4mptpd
16, // b_p4mptpd
10, // b_1x4dmd
10, // b_p1x4dmd
12, // b_bigh
12, // b_pbigh
12, // b_bigx
12, // b_pbigx
16, // b_bigbigh
16, // b_pbigbigh
16, // b_bigbigx
16, // b_pbigbigx
12, // b_bigrig
12, // b_pbigrig
12, // b_bighrgl
12, // b_pbighrgl
12, // b_bigdhrgl
12, // b_pbigdhrgl
12, // b_bigbone
12, // b_pbigbone
12, // b_dblbone6
12, // b_pdblbone6
12, // b_bigdmd
12, // b_pbigdmd
12, // b_bigptpd
12, // b_pbigptpd
12, // b_5x1dmd
12, // b_p5x1dmd
12, // b_1x5dmd
12, // b_p1x5dmd
18, // b_big3dmd
18, // b_pbig3dmd
24, // b_big4dmd
24, // b_pbig4dmd
16, // b_dblxwave
16, // b_pdblxwave
16, // b_dblspindle
16, // b_pdblspindle
16, // b_dblbone
16, // b_pdblbone
16, // b_dblrig
16}; // b_pdblrig