forked from calref/cboe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspec_legacy.cpp
247 lines (229 loc) · 7.2 KB
/
spec_legacy.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
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
//
// spec_legacy.cpp
// BoE
//
// Created by Celtic Minstrel on 15-07-11.
//
//
#include "catch.hpp"
#include "oldstructs.hpp"
#include "special.hpp"
#include "restypes.hpp"
using namespace std;
ostream& operator<< (ostream& out, eSpecType spec);
TEST_CASE("When converting legacy special nodes (general)") {
cSpecial newSpec;
legacy::special_node_type oldSpec = {0,-1,-1,0,-1,-1,-1,-1,-1,-1,-1};
// Fetching opcodes requires strings to be available
// Here we fetch them from the rsrc dir, rather than the data dir
ResMgr::pushPath<StringRsrc>("../rsrc/strings");
oldSpec.jumpto = 12;
SECTION("Set Flag") {
oldSpec.type = 1;
oldSpec.m1 = 2; oldSpec.m2 = 3;
oldSpec.sd1 = 4; oldSpec.sd2 = 5;
oldSpec.ex1a = 6;
newSpec.append(oldSpec);
CHECK(newSpec.type == eSpecType::SET_SDF);
CHECK(newSpec.m1 == 2); CHECK(newSpec.m2 == 3);
CHECK(newSpec.sd1 == 4); CHECK(newSpec.sd2 == 5);
CHECK(newSpec.ex1a == 6);
CHECK(newSpec.jumpto == 12);
}
SECTION("Secret Passage") {
oldSpec.type = 4;
newSpec.append(oldSpec);
CHECK(newSpec.type == eSpecType::CANT_ENTER);
CHECK(newSpec.ex1a == 0);
CHECK(newSpec.ex2a == 1);
CHECK(newSpec.jumpto == 12);
}
SECTION("Out Block") {
oldSpec.type = 7;
oldSpec.m1 = 4; oldSpec.m2 = 5;
oldSpec.ex1a = 1;
newSpec.append(oldSpec);
CHECK(newSpec.type == eSpecType::IF_CONTEXT);
CHECK(newSpec.m1 == 4); CHECK(newSpec.m2 == 5);
CHECK(newSpec.ex1a == int(eSpecCtx::OUT_MOVE));
CHECK(newSpec.ex1b == 1);
CHECK(newSpec.jumpto == 12);
}
SECTION("Town Block") {
oldSpec.type = 8;
oldSpec.m1 = 4; oldSpec.m2 = 5;
oldSpec.ex1a = 1;
newSpec.append(oldSpec);
CHECK(newSpec.type == eSpecType::IF_CONTEXT);
CHECK(newSpec.m1 == 4); CHECK(newSpec.m2 == 5);
CHECK(newSpec.ex1a == int(eSpecCtx::TOWN_MOVE));
CHECK(newSpec.ex1b == 1);
CHECK(newSpec.jumpto == 12);
}
SECTION("Combat Block") {
oldSpec.type = 9;
oldSpec.m1 = 4; oldSpec.m2 = 5;
oldSpec.ex1a = 1;
newSpec.append(oldSpec);
CHECK(newSpec.type == eSpecType::IF_CONTEXT);
CHECK(newSpec.m1 == 4); CHECK(newSpec.m2 == 5);
CHECK(newSpec.ex1a == int(eSpecCtx::COMBAT_MOVE));
CHECK(newSpec.ex1b == 1);
CHECK(newSpec.jumpto == 12);
}
SECTION("Looking Block") {
oldSpec.type = 10;
oldSpec.m1 = 4; oldSpec.m2 = 5;
newSpec.append(oldSpec);
CHECK(newSpec.type == eSpecType::IF_LOOKING);
CHECK(newSpec.m1 == 4); CHECK(newSpec.m2 == 5);
CHECK(newSpec.jumpto == 12);
}
// Clean up after ourselves
ResMgr::popPath<StringRsrc>();
}
TEST_CASE("When converting legacy special nodes (one-shot)") {
cSpecial newSpec;
legacy::special_node_type oldSpec = {0,-1,-1,0,-1,-1,-1,-1,-1,-1,-1};
// Fetching opcodes requires strings to be available
// Here we fetch them from the rsrc dir, rather than the data dir
ResMgr::pushPath<StringRsrc>("../rsrc/strings");
oldSpec.sd1 = 8; oldSpec.sd2 = 7;
oldSpec.m1 = 4; oldSpec.m2 = 5;
oldSpec.jumpto = 12;
SECTION("Give Item") {
oldSpec.type = 50;
oldSpec.ex1a = 9;
oldSpec.ex1b = 2500;
oldSpec.ex2a = 1500;
oldSpec.ex2b = 10;
newSpec.append(oldSpec);
CHECK(newSpec.type == eSpecType::ONCE_GIVE_ITEM);
CHECK(newSpec.sd1 == 8); CHECK(newSpec.sd2 == 7);
CHECK(newSpec.m1 == 4); CHECK(newSpec.m2 == 5);
CHECK(newSpec.ex1a == 9);
CHECK(newSpec.ex1b == 2500);
CHECK(newSpec.ex2a == 1500);
CHECK(newSpec.ex2b == 10);
CHECK(newSpec.jumpto == 12);
}
// Clean up after ourselves
ResMgr::popPath<StringRsrc>();
}
TEST_CASE("When converting legacy special nodes (affect)") {
cSpecial newSpec;
legacy::special_node_type oldSpec = {0,-1,-1,0,-1,-1,-1,-1,-1,-1,-1};
// Fetching opcodes requires strings to be available
// Here we fetch them from the rsrc dir, rather than the data dir
ResMgr::pushPath<StringRsrc>("../rsrc/strings");
oldSpec.m1 = 4; oldSpec.m2 = 5;
oldSpec.jumpto = 12;
SECTION("Select a PC") {
oldSpec.type = 80;
oldSpec.ex1a = 1;
oldSpec.ex1b = 10;
newSpec.append(oldSpec);
CHECK(newSpec.type == eSpecType::SELECT_TARGET);
CHECK(newSpec.m1 == 4); CHECK(newSpec.m2 == 5);
CHECK(newSpec.ex1a == 1);
CHECK(newSpec.ex1b == 10);
CHECK(newSpec.jumpto == 12);
}
// Clean up after ourselves
ResMgr::popPath<StringRsrc>();
}
TEST_CASE("When converting legacy special nodes (if-then)") {
cSpecial newSpec;
legacy::special_node_type oldSpec = {0,-1,-1,0,-1,-1,-1,-1,-1,-1,-1};
// Fetching opcodes requires strings to be available
// Here we fetch them from the rsrc dir, rather than the data dir
ResMgr::pushPath<StringRsrc>("../rsrc/strings");
oldSpec.jumpto = 12;
SECTION("Stuff Done Flag?") {
oldSpec.type = 130;
oldSpec.sd1 = 8; oldSpec.sd2 = 7;
oldSpec.ex1a = 1;
oldSpec.ex1b = 10;
oldSpec.ex2a = 9;
oldSpec.ex2b = 13;
newSpec.append(oldSpec);
CHECK(newSpec.type == eSpecType::IF_SDF);
CHECK(newSpec.sd1 == 8); CHECK(newSpec.sd2 == 7);
CHECK(newSpec.ex1a == 1);
CHECK(newSpec.ex1b == 10);
CHECK(newSpec.ex2a == 9);
CHECK(newSpec.ex2b == 13);
CHECK(newSpec.jumpto == 12);
}
// Clean up after ourselves
ResMgr::popPath<StringRsrc>();
}
TEST_CASE("When converting legacy special nodes (town)") {
cSpecial newSpec;
legacy::special_node_type oldSpec = {0,-1,-1,0,-1,-1,-1,-1,-1,-1,-1};
// Fetching opcodes requires strings to be available
// Here we fetch them from the rsrc dir, rather than the data dir
ResMgr::pushPath<StringRsrc>("../rsrc/strings");
oldSpec.m1 = 4; oldSpec.m2 = 5;
SECTION("Town Hostile") {
oldSpec.type = 170;
oldSpec.jumpto = 12;
newSpec.append(oldSpec);
CHECK(newSpec.type == eSpecType::MAKE_TOWN_HOSTILE);
CHECK(newSpec.m1 == 4); CHECK(newSpec.m2 == 5);
CHECK(newSpec.jumpto == 12);
}
// Clean up after ourselves
ResMgr::popPath<StringRsrc>();
}
TEST_CASE("When converting legacy special nodes (rect)") {
cSpecial newSpec;
legacy::special_node_type oldSpec = {0,-1,-1,0,-1,-1,-1,-1,-1,-1,-1};
// Fetching opcodes requires strings to be available
// Here we fetch them from the rsrc dir, rather than the data dir
ResMgr::pushPath<StringRsrc>("../rsrc/strings");
oldSpec.ex1a = 2;
oldSpec.ex1b = 10;
oldSpec.ex2a = 4;
oldSpec.ex2b = 20;
oldSpec.jumpto = 12;
SECTION("Place Fire Wall") {
oldSpec.type = 200;
oldSpec.m1 = 4; oldSpec.m2 = 5;
oldSpec.pic = 1;
oldSpec.sd1 = 75;
newSpec.append(oldSpec);
CHECK(newSpec.type == eSpecType::RECT_PLACE_FIELD);
CHECK(newSpec.m1 == 4); CHECK(newSpec.m2 == 5);
CHECK(newSpec.pic == 1);
CHECK(newSpec.sd1 == 75);
CHECK(newSpec.sd2 == WALL_FIRE);
CHECK(newSpec.ex1a == 2);
CHECK(newSpec.ex1b == 10);
CHECK(newSpec.ex2a == 4);
CHECK(newSpec.ex2b == 20);
CHECK(newSpec.jumpto == 12);
}
// Clean up after ourselves
ResMgr::popPath<StringRsrc>();
}
TEST_CASE("When converting legacy special nodes (outdoors)") {
cSpecial newSpec;
legacy::special_node_type oldSpec = {0,-1,-1,0,-1,-1,-1,-1,-1,-1,-1};
// Fetching opcodes requires strings to be available
// Here we fetch them from the rsrc dir, rather than the data dir
ResMgr::pushPath<StringRsrc>("../rsrc/strings");
oldSpec.jumpto = 12;
SECTION("Make Outdoor Wandering") {
oldSpec.type = 225;
newSpec.append(oldSpec);
CHECK(newSpec.type == eSpecType::OUT_MAKE_WANDER);
CHECK(newSpec.jumpto == 12);
}
// Clean up after ourselves
ResMgr::popPath<StringRsrc>();
}
ostream& operator<< (ostream& out, eSpecType spec) {
out << (*spec).opcode();
return out;
}