1 |
#!/opt/bin/perl |
2 |
|
3 |
use List::Util; |
4 |
|
5 |
# todo: gather dynamically |
6 |
my @kw = qw( |
7 |
no_pass |
8 |
walk_on |
9 |
walk_off |
10 |
fly_on |
11 |
fly_off |
12 |
flying |
13 |
|
14 |
ac |
15 |
activate_on_push |
16 |
activate_on_release |
17 |
alive |
18 |
anim_speed |
19 |
animation |
20 |
applied |
21 |
arch |
22 |
armour |
23 |
attach |
24 |
attack_movement |
25 |
attacktype |
26 |
auto_apply |
27 |
been_applied |
28 |
berserk |
29 |
blocksview |
30 |
body_range |
31 |
body_arm |
32 |
body_torso |
33 |
body_head |
34 |
body_neck |
35 |
body_skill |
36 |
body_finger |
37 |
body_shoulder |
38 |
body_foot |
39 |
body_hand |
40 |
body_wrist |
41 |
body_waist |
42 |
can_apply |
43 |
can_cast_spell |
44 |
can_roll |
45 |
can_see_in_dark |
46 |
can_use_armour |
47 |
can_use_bow |
48 |
can_use_horn |
49 |
can_use_range |
50 |
can_use_ring |
51 |
can_use_rod |
52 |
can_use_scroll |
53 |
can_use_shield |
54 |
can_use_skill |
55 |
can_use_wand |
56 |
can_use_weapon |
57 |
carrying |
58 |
casting_time |
59 |
cha |
60 |
changing |
61 |
client_type |
62 |
con |
63 |
confused |
64 |
connected |
65 |
container |
66 |
cursed |
67 |
custom_name |
68 |
dam |
69 |
dam_modifier |
70 |
damned |
71 |
dex |
72 |
direction |
73 |
duration |
74 |
duration_modifier |
75 |
editable |
76 |
editor_folder |
77 |
elevation |
78 |
end |
79 |
endlore |
80 |
endmsg |
81 |
exp |
82 |
expmul |
83 |
face |
84 |
food |
85 |
friendly |
86 |
gen_sp_armour |
87 |
generator |
88 |
glow_radius |
89 |
grace |
90 |
has_ready_bow |
91 |
has_ready_horn |
92 |
has_ready_rod |
93 |
has_ready_scroll |
94 |
has_ready_skill |
95 |
has_ready_wand |
96 |
has_ready_weapon |
97 |
has_ready_range |
98 |
hitback |
99 |
hp |
100 |
identified |
101 |
immune |
102 |
int |
103 |
inv_locked |
104 |
invisible |
105 |
is_animated |
106 |
is_blind |
107 |
is_buildable |
108 |
is_cauldron |
109 |
is_dust |
110 |
is_floor |
111 |
is_hilly |
112 |
is_lightable |
113 |
is_thrown |
114 |
is_turnable |
115 |
is_used_up |
116 |
is_water |
117 |
is_wooded |
118 |
item_power |
119 |
known_cursed |
120 |
known_magical |
121 |
last_eat |
122 |
last_grace |
123 |
last_heal |
124 |
last_sp |
125 |
level |
126 |
lifesave |
127 |
lore |
128 |
luck |
129 |
magic |
130 |
make_invisible |
131 |
material |
132 |
materialname |
133 |
maxgrace |
134 |
maxhp |
135 |
maxsp |
136 |
monster |
137 |
more |
138 |
move_allow |
139 |
move_block |
140 |
move_off |
141 |
move_on |
142 |
move_slow |
143 |
move_slow_penalty |
144 |
move_state |
145 |
move_type |
146 |
msg |
147 |
name |
148 |
name_pl |
149 |
neutral |
150 |
no_attack |
151 |
no_damage |
152 |
no_drop |
153 |
no_fix_player |
154 |
no_magic |
155 |
no_pick |
156 |
no_skill_ident |
157 |
no_steal |
158 |
no_strength |
159 |
nrof |
160 |
object |
161 |
oid |
162 |
one_hit |
163 |
only_attack |
164 |
other_arch |
165 |
overlay_floor |
166 |
path_attuned |
167 |
path_denied |
168 |
path_repelled |
169 |
perm_exp |
170 |
pick_up |
171 |
player_sold |
172 |
pow |
173 |
protected |
174 |
race |
175 |
random_move |
176 |
random_movement |
177 |
randomitems |
178 |
range |
179 |
range_modifier |
180 |
reflect_missile |
181 |
reflect_spell |
182 |
reflecting |
183 |
resist_acid |
184 |
resist_blind |
185 |
resist_cancellation |
186 |
resist_chaos |
187 |
resist_cold |
188 |
resist_confusion |
189 |
resist_counterspell |
190 |
resist_death |
191 |
resist_deplete |
192 |
resist_disease |
193 |
resist_drain |
194 |
resist_electricity |
195 |
resist_fear |
196 |
resist_fire |
197 |
resist_ghosthit |
198 |
resist_godpower |
199 |
resist_holyword |
200 |
resist_internal |
201 |
resist_life_stealing |
202 |
resist_magic |
203 |
resist_paralyze |
204 |
resist_physical |
205 |
resist_poison |
206 |
resist_slow |
207 |
resist_turn_undead |
208 |
resist_weaponmagic |
209 |
run_away |
210 |
scared |
211 |
see_anywhere |
212 |
see_invisible |
213 |
skill |
214 |
slaying |
215 |
sleep |
216 |
slow_move |
217 |
smoothlevel |
218 |
sp |
219 |
speed |
220 |
speed_left |
221 |
splitting |
222 |
stand_still |
223 |
startequip |
224 |
state |
225 |
stealth |
226 |
str |
227 |
subtype |
228 |
tear_down |
229 |
title |
230 |
tooltype |
231 |
treasure |
232 |
type |
233 |
unaggressive |
234 |
undead |
235 |
unique |
236 |
unpaid |
237 |
use_content_on_gen |
238 |
uuid |
239 |
value |
240 |
vulnerable |
241 |
was_wiz |
242 |
wc |
243 |
weapontype |
244 |
weight |
245 |
will_apply |
246 |
wis |
247 |
wiz |
248 |
x |
249 |
xrays |
250 |
y |
251 |
|
252 |
Object |
253 |
Str |
254 |
Dex |
255 |
Con |
256 |
Wis |
257 |
Cha |
258 |
Int |
259 |
Pow |
260 |
More |
261 |
); |
262 |
|
263 |
open GPERF, "|-", "gperf -m50 >kw_hash.h" |
264 |
or die "gperf: $!"; |
265 |
|
266 |
print GPERF <<EOF; |
267 |
%language=C++ |
268 |
%enum |
269 |
%define class-name kw_lex |
270 |
%define lookup-function-name match |
271 |
%struct-type |
272 |
%compare-strncmp |
273 |
%delimiters=, |
274 |
struct keyword_idx { const char *name; enum keyword index; }; |
275 |
%% |
276 |
EOF |
277 |
|
278 |
for (@kw) { |
279 |
printf GPERF "%s,%s\n", $_, "KW_$_"; |
280 |
} |
281 |
|
282 |
print GPERF <<EOF; |
283 |
%% |
284 |
extern const char *const keyword_str [] = { |
285 |
"<EOF>", |
286 |
"<ERROR>", |
287 |
EOF |
288 |
|
289 |
for (@kw) { |
290 |
printf GPERF " \"%s\",\n", $_; |
291 |
} |
292 |
|
293 |
print GPERF "};\n"; |
294 |
|
295 |
printf GPERF "\nextern const unsigned char keyword_len [] = { 5, 7, %s };\n\n", |
296 |
join ", ", map length, @kw; |
297 |
|
298 |
open KW, ">", "keyword.h"; |
299 |
|
300 |
print KW <<EOF; |
301 |
#ifndef KW_H__ |
302 |
#define KW_H__ |
303 |
|
304 |
enum keyword { |
305 |
KW_NULL = 0, |
306 |
KW_EOF = 0, |
307 |
KW_ERROR, |
308 |
EOF |
309 |
|
310 |
for (@kw) { |
311 |
printf KW " %s,\n", "KW_$_", |
312 |
} |
313 |
|
314 |
print KW <<EOF; |
315 |
NUM_KEYWORD, |
316 |
}; |
317 |
|
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; |
326 |
|
327 |
#endif |
328 |
|
329 |
EOF |
330 |
|