1 |
#!/opt/bin/perl |
2 |
|
3 |
# |
4 |
# This file is part of Deliantra, the Roguelike Realtime MMORPG. |
5 |
# |
6 |
# Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
7 |
# |
8 |
# Deliantra is free software: you can redistribute it and/or modify it under |
9 |
# the terms of the Affero GNU General Public License as published by the |
10 |
# Free Software Foundation, either version 3 of the License, or (at your |
11 |
# option) any later version. |
12 |
# |
13 |
# This program is distributed in the hope that it will be useful, |
14 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
# GNU General Public License for more details. |
17 |
# |
18 |
# You should have received a copy of the Affero GNU General Public License |
19 |
# and the GNU General Public License along with this program. If not, see |
20 |
# <http://www.gnu.org/licenses/>. |
21 |
# |
22 |
# The authors can be reached via e-mail to <support@deliantra.net> |
23 |
# |
24 |
|
25 |
my %ARG = @ARGV; |
26 |
|
27 |
use List::Util; |
28 |
|
29 |
# todo: gather dynamically |
30 |
my @kw = qw( |
31 |
no_pass |
32 |
walk_on |
33 |
walk_off |
34 |
fly_on |
35 |
fly_off |
36 |
flying |
37 |
|
38 |
gender |
39 |
hintmode |
40 |
attack_skill |
41 |
ranged_skill |
42 |
|
43 |
ac |
44 |
activate_on_push |
45 |
activate_on_release |
46 |
alive |
47 |
anim_speed |
48 |
animation |
49 |
applied |
50 |
arch |
51 |
armour |
52 |
attach |
53 |
attack_movement |
54 |
attacktype |
55 |
auto_apply |
56 |
been_applied |
57 |
berserk |
58 |
blocksview |
59 |
body_range |
60 |
body_arm |
61 |
body_torso |
62 |
body_head |
63 |
body_neck |
64 |
body_skill |
65 |
body_finger |
66 |
body_shoulder |
67 |
body_foot |
68 |
body_hand |
69 |
body_wrist |
70 |
body_waist |
71 |
body_shield |
72 |
body_combat |
73 |
can_apply |
74 |
can_cast_spell |
75 |
can_roll |
76 |
can_see_in_dark |
77 |
can_use_armour |
78 |
can_use_bow |
79 |
can_use_horn |
80 |
can_use_range |
81 |
can_use_ring |
82 |
can_use_rod |
83 |
can_use_scroll |
84 |
can_use_shield |
85 |
can_use_skill |
86 |
can_use_wand |
87 |
can_use_weapon |
88 |
carrying |
89 |
casting_time |
90 |
cha |
91 |
changing |
92 |
client_type |
93 |
con |
94 |
confused |
95 |
connected |
96 |
container |
97 |
cursed |
98 |
custom_name |
99 |
dam |
100 |
dam_modifier |
101 |
damned |
102 |
destroy_on_death |
103 |
dex |
104 |
direction |
105 |
duration |
106 |
duration_modifier |
107 |
editable |
108 |
editor_folder |
109 |
elevation |
110 |
end |
111 |
endlore |
112 |
endmsg |
113 |
exp |
114 |
expmul |
115 |
face |
116 |
food |
117 |
friendly |
118 |
gen_sp_armour |
119 |
generator |
120 |
glow_radius |
121 |
grace |
122 |
has_ready_bow |
123 |
has_ready_scroll |
124 |
has_ready_skill |
125 |
has_ready_weapon |
126 |
has_ready_range |
127 |
hitback |
128 |
hp |
129 |
identified |
130 |
immune |
131 |
inherit |
132 |
int |
133 |
inv_locked |
134 |
invisible |
135 |
is_animated |
136 |
is_blind |
137 |
is_buildable |
138 |
is_cauldron |
139 |
is_dust |
140 |
is_floor |
141 |
is_hilly |
142 |
is_lightable |
143 |
is_thrown |
144 |
is_turnable |
145 |
is_used_up |
146 |
is_water |
147 |
is_wooded |
148 |
item_power |
149 |
known_cursed |
150 |
known_magical |
151 |
last_eat |
152 |
last_grace |
153 |
last_heal |
154 |
last_sp |
155 |
level |
156 |
lifesave |
157 |
lore |
158 |
luck |
159 |
magic |
160 |
make_invisible |
161 |
material |
162 |
materialname |
163 |
maxgrace |
164 |
maxhp |
165 |
maxsp |
166 |
monster |
167 |
more |
168 |
move_allow |
169 |
move_block |
170 |
move_off |
171 |
move_on |
172 |
move_slow |
173 |
move_slow_penalty |
174 |
move_state |
175 |
move_type |
176 |
msg |
177 |
name |
178 |
name_pl |
179 |
neutral |
180 |
no_attack |
181 |
no_damage |
182 |
no_drop |
183 |
no_magic |
184 |
no_pick |
185 |
no_skill_ident |
186 |
no_steal |
187 |
no_strength |
188 |
nrof |
189 |
obj_original |
190 |
object |
191 |
oid |
192 |
one_hit |
193 |
only_attack |
194 |
other_arch |
195 |
overlay_floor |
196 |
owner |
197 |
path_attuned |
198 |
path_denied |
199 |
path_repelled |
200 |
perm_exp |
201 |
pick_up |
202 |
player_sold |
203 |
pow |
204 |
precious |
205 |
protected |
206 |
is_quad |
207 |
race |
208 |
random_move |
209 |
random_movement |
210 |
random_speed |
211 |
randomitems |
212 |
range |
213 |
range_modifier |
214 |
reflect_missile |
215 |
reflect_spell |
216 |
reflecting |
217 |
resist_acid |
218 |
resist_blind |
219 |
resist_cancellation |
220 |
resist_chaos |
221 |
resist_cold |
222 |
resist_confusion |
223 |
resist_counterspell |
224 |
resist_death |
225 |
resist_deplete |
226 |
resist_disease |
227 |
resist_drain |
228 |
resist_electricity |
229 |
resist_fear |
230 |
resist_fire |
231 |
resist_ghosthit |
232 |
resist_godpower |
233 |
resist_holyword |
234 |
resist_internal |
235 |
resist_life_stealing |
236 |
resist_magic |
237 |
resist_paralyze |
238 |
resist_physical |
239 |
resist_poison |
240 |
resist_slow |
241 |
resist_turn_undead |
242 |
resist_weaponmagic |
243 |
run_away |
244 |
scared |
245 |
see_anywhere |
246 |
see_invisible |
247 |
skill |
248 |
slaying |
249 |
sleep |
250 |
slow_move |
251 |
sound |
252 |
sound_destroy |
253 |
smoothlevel |
254 |
sp |
255 |
speed |
256 |
speed_left |
257 |
sl |
258 |
splitting |
259 |
stand_still |
260 |
startequip |
261 |
state |
262 |
stealth |
263 |
str |
264 |
subtype |
265 |
tag |
266 |
tear_down |
267 |
title |
268 |
treasure_env |
269 |
type |
270 |
unaggressive |
271 |
undead |
272 |
unique |
273 |
unpaid |
274 |
use_content_on_gen |
275 |
uuid |
276 |
value |
277 |
vulnerable |
278 |
wc |
279 |
weapontype |
280 |
weight |
281 |
will_apply |
282 |
wis |
283 |
x |
284 |
xrays |
285 |
y |
286 |
|
287 |
maplore |
288 |
endmaplore |
289 |
enter_x |
290 |
enter_y |
291 |
width |
292 |
height |
293 |
reset_timeout |
294 |
reset_time |
295 |
swap_time |
296 |
difficulty |
297 |
darkness |
298 |
fixed_resettime |
299 |
per_player |
300 |
per_party |
301 |
no_reset |
302 |
region |
303 |
shopitems |
304 |
shopgreed |
305 |
shopmin |
306 |
shopmax |
307 |
shoprace |
308 |
outdoor |
309 |
tile_path_1 |
310 |
tile_path_2 |
311 |
tile_path_3 |
312 |
tile_path_4 |
313 |
tile_path_5 |
314 |
tile_path_6 |
315 |
|
316 |
file_format_version |
317 |
|
318 |
map |
319 |
savebed_map |
320 |
bed_x |
321 |
bed_y |
322 |
password |
323 |
bowtype |
324 |
petmode |
325 |
gen_hp |
326 |
gen_sp |
327 |
gen_grace |
328 |
listening |
329 |
peaceful |
330 |
digestion |
331 |
pickup |
332 |
outputs_sync |
333 |
outputs_count |
334 |
usekeys |
335 |
unapply |
336 |
weapon_sp |
337 |
weapon_sp_left |
338 |
lev_array |
339 |
endplst |
340 |
|
341 |
visibility |
342 |
magicmap |
343 |
|
344 |
parent |
345 |
longname |
346 |
jail_map |
347 |
jail_x |
348 |
jail_y |
349 |
portal_map |
350 |
fallback |
351 |
nomore |
352 |
|
353 |
chance |
354 |
mods |
355 |
diff |
356 |
saves |
357 |
description |
358 |
density |
359 |
damage |
360 |
|
361 |
anim |
362 |
mina |
363 |
facings |
364 |
player |
365 |
|
366 |
allowed |
367 |
keycode |
368 |
trans |
369 |
yield |
370 |
ingred |
371 |
cauldron |
372 |
|
373 |
Str |
374 |
Dex |
375 |
Con |
376 |
Wis |
377 |
Cha |
378 |
Int |
379 |
Pow |
380 |
|
381 |
treasure |
382 |
treasureone |
383 |
list |
384 |
change_name |
385 |
change_title |
386 |
change_slaying |
387 |
yes |
388 |
no |
389 |
|
390 |
max_level |
391 |
|
392 |
authour |
393 |
size |
394 |
index |
395 |
); |
396 |
|
397 |
open GPERF, "|-", "exec $ARG{GPERF} -m50 >kw_hash.h" |
398 |
or die "$ARGV{GPERF}: $!"; |
399 |
|
400 |
print GPERF <<EOF; |
401 |
%language=C++ |
402 |
%enum |
403 |
%define class-name kw_lex |
404 |
%define lookup-function-name match |
405 |
%struct-type |
406 |
%compare-strncmp |
407 |
%delimiters=, |
408 |
struct keyword_idx { const char *name; enum keyword index; }; |
409 |
%% |
410 |
EOF |
411 |
|
412 |
for (@kw) { |
413 |
printf GPERF "%s,%s\n", $_, "KW_$_"; |
414 |
} |
415 |
|
416 |
print GPERF <<EOF; |
417 |
%% |
418 |
extern const char *const keyword_str [] = { |
419 |
"<EOF>", |
420 |
"<ERROR>", |
421 |
EOF |
422 |
|
423 |
for (@kw) { |
424 |
printf GPERF " \"%s\",\n", $_; |
425 |
} |
426 |
|
427 |
print GPERF "};\n"; |
428 |
|
429 |
printf GPERF "\nextern const unsigned char keyword_len [] = { 5, 7, %s };\n\n", |
430 |
join ", ", map length, @kw; |
431 |
|
432 |
close GPERF |
433 |
or die "$ARG{GPERF}: failed to run"; |
434 |
|
435 |
open KW, ">", "keyword.h"; |
436 |
|
437 |
print KW <<EOF; |
438 |
// |
439 |
// AUTOGENERATED: this is a generated file |
440 |
// edit include/genkeywords instead |
441 |
// |
442 |
|
443 |
#ifndef KW_H__ |
444 |
#define KW_H__ |
445 |
|
446 |
enum keyword { |
447 |
KW_NULL = 0, |
448 |
KW_EOF = 0, |
449 |
KW_ERROR, |
450 |
EOF |
451 |
|
452 |
for (@kw) { |
453 |
printf KW " %s,\n", "KW_$_", |
454 |
} |
455 |
|
456 |
print KW <<EOF; |
457 |
NUM_KEYWORD, |
458 |
}; |
459 |
|
460 |
extern const char *const keyword_str []; |
461 |
extern const unsigned char keyword_len []; |
462 |
|
463 |
EOF |
464 |
|
465 |
printf KW "#define MAX_KEYWORD_LEN %d\n", List::Util::max map length, @kw; |
466 |
|
467 |
print KW <<EOF; |
468 |
|
469 |
#endif |
470 |
|
471 |
EOF |
472 |
|