1 | #!/opt/bin/perl |
1 | #!/opt/bin/perl |
|
|
2 | |
|
|
3 | use List::Util; |
2 | |
4 | |
3 | # todo: gather dynamically |
5 | # todo: gather dynamically |
4 | my @kw = qw( |
6 | my @kw = qw( |
|
|
7 | no_pass |
|
|
8 | walk_on |
|
|
9 | walk_off |
|
|
10 | fly_on |
|
|
11 | fly_off |
|
|
12 | flying |
|
|
13 | |
5 | ac |
14 | ac |
6 | activate_on_push |
15 | activate_on_push |
7 | activate_on_release |
16 | activate_on_release |
8 | alive |
17 | alive |
9 | anim_speed |
18 | anim_speed |
… | |
… | |
83 | has_ready_rod |
92 | has_ready_rod |
84 | has_ready_scroll |
93 | has_ready_scroll |
85 | has_ready_skill |
94 | has_ready_skill |
86 | has_ready_wand |
95 | has_ready_wand |
87 | has_ready_weapon |
96 | has_ready_weapon |
|
|
97 | has_ready_range |
88 | hitback |
98 | hitback |
89 | hp |
99 | hp |
90 | identified |
100 | identified |
91 | immune |
101 | immune |
92 | int |
102 | int |
… | |
… | |
94 | invisible |
104 | invisible |
95 | is_animated |
105 | is_animated |
96 | is_blind |
106 | is_blind |
97 | is_buildable |
107 | is_buildable |
98 | is_cauldron |
108 | is_cauldron |
|
|
109 | is_dust |
99 | is_floor |
110 | is_floor |
100 | is_hilly |
111 | is_hilly |
101 | is_lightable |
112 | is_lightable |
102 | is_thrown |
113 | is_thrown |
103 | is_turnable |
114 | is_turnable |
… | |
… | |
155 | path_attuned |
166 | path_attuned |
156 | path_denied |
167 | path_denied |
157 | path_repelled |
168 | path_repelled |
158 | perm_exp |
169 | perm_exp |
159 | pick_up |
170 | pick_up |
|
|
171 | player_sold |
160 | pow |
172 | pow |
161 | protected |
173 | protected |
162 | race |
174 | race |
163 | random_move |
175 | random_move |
164 | random_movement |
176 | random_movement |
… | |
… | |
221 | unaggressive |
233 | unaggressive |
222 | undead |
234 | undead |
223 | unique |
235 | unique |
224 | unpaid |
236 | unpaid |
225 | use_content_on_gen |
237 | use_content_on_gen |
|
|
238 | uuid |
226 | value |
239 | value |
227 | vulnerable |
240 | vulnerable |
228 | was_wiz |
241 | was_wiz |
229 | wc |
242 | wc |
230 | weapontype |
243 | weapontype |
… | |
… | |
233 | wis |
246 | wis |
234 | wiz |
247 | wiz |
235 | x |
248 | x |
236 | xrays |
249 | xrays |
237 | y |
250 | y |
|
|
251 | |
|
|
252 | Object |
|
|
253 | Str |
|
|
254 | Dex |
|
|
255 | Con |
|
|
256 | Wis |
|
|
257 | Cha |
|
|
258 | Int |
|
|
259 | Pow |
|
|
260 | More |
238 | ); |
261 | ); |
239 | |
262 | |
240 | open GPERF, "|-", "gperf -m50 >kw_hash.h" |
263 | open GPERF, "|-", "gperf -m50 >kw_hash.h" |
241 | or die "gperf: $!"; |
264 | or die "gperf: $!"; |
242 | |
265 | |
… | |
… | |
251 | struct keyword_idx { const char *name; enum keyword index; }; |
274 | struct keyword_idx { const char *name; enum keyword index; }; |
252 | %% |
275 | %% |
253 | EOF |
276 | EOF |
254 | |
277 | |
255 | for (@kw) { |
278 | for (@kw) { |
256 | printf GPERF "%s,%s\n", $_, "KW_" . uc; |
279 | printf GPERF "%s,%s\n", $_, "KW_$_"; |
257 | } |
280 | } |
258 | |
281 | |
259 | print GPERF <<EOF; |
282 | print GPERF <<EOF; |
260 | %% |
283 | %% |
261 | const char *const keyword_str [] = { |
284 | extern const char *const keyword_str [] = { |
262 | "<EOF>", |
285 | "<EOF>", |
263 | "<ERROR>", |
286 | "<ERROR>", |
264 | EOF |
287 | EOF |
265 | |
288 | |
266 | for (@kw) { |
289 | for (@kw) { |
267 | printf GPERF " \"%s\",\n", $_; |
290 | printf GPERF " \"%s\",\n", $_; |
268 | } |
291 | } |
269 | |
292 | |
270 | print GPERF "};\n\n"; |
293 | print GPERF "};\n"; |
|
|
294 | |
|
|
295 | printf GPERF "\nextern const unsigned char keyword_len [] = { 5, 7, %s };\n\n", |
|
|
296 | join ", ", map length, @kw; |
271 | |
297 | |
272 | open KW, ">", "keyword.h"; |
298 | open KW, ">", "keyword.h"; |
273 | |
299 | |
274 | print KW <<EOF; |
300 | print KW <<EOF; |
275 | #ifndef KW_H__ |
301 | #ifndef KW_H__ |
276 | #define KW_H__ |
302 | #define KW_H__ |
277 | |
303 | |
278 | enum keyword { |
304 | enum keyword { |
279 | KW_eof, KW_error, |
305 | KW_NULL = 0, |
|
|
306 | KW_EOF = 0, |
|
|
307 | KW_ERROR, |
280 | EOF |
308 | EOF |
281 | |
309 | |
282 | for (@kw) { |
310 | for (@kw) { |
283 | printf KW " %s,\n", "KW_" . uc; |
311 | printf KW " %s,\n", "KW_$_", |
284 | } |
312 | } |
285 | |
313 | |
286 | print KW <<EOF; |
314 | print KW <<EOF; |
287 | NUM_KEYWORD, |
315 | NUM_KEYWORD, |
288 | }; |
316 | }; |
289 | |
317 | |
290 | extern const char *const keyword_str []; |
318 | extern const char *const keyword_str []; |
|
|
319 | extern const unsigned char keyword_len []; |
|
|
320 | |
|
|
321 | EOF |
|
|
322 | |
|
|
323 | printf KW "#define MAX_KEYWORD_LEN %d\n", List::Util::max map length, @kw; |
|
|
324 | |
|
|
325 | print KW <<EOF; |
291 | |
326 | |
292 | #endif |
327 | #endif |
293 | |
328 | |
294 | EOF |
329 | EOF |
295 | |
330 | |