ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/preprocess
(Generate patch)

Comparing deliantra/server/include/preprocess (file contents):
Revision 1.1 by root, Thu Aug 31 06:23:19 2006 UTC vs.
Revision 1.19 by root, Fri Feb 16 19:43:41 2007 UTC

1#!/opt/bin/perl 1#!/opt/bin/perl
2
3my %ARG = @ARGV;
4
5use List::Util;
2 6
3# todo: gather dynamically 7# todo: gather dynamically
4my @kw = qw( 8my @kw = qw(
9 no_pass
10 walk_on
11 walk_off
12 fly_on
13 fly_off
14 flying
15
5 ac 16 ac
6 activate_on_push 17 activate_on_push
7 activate_on_release 18 activate_on_release
8 alive 19 alive
9 anim_speed 20 anim_speed
57 cursed 68 cursed
58 custom_name 69 custom_name
59 dam 70 dam
60 dam_modifier 71 dam_modifier
61 damned 72 damned
73 destroy_on_death
62 dex 74 dex
63 direction 75 direction
64 duration 76 duration
65 duration_modifier 77 duration_modifier
66 editable 78 editable
83 has_ready_rod 95 has_ready_rod
84 has_ready_scroll 96 has_ready_scroll
85 has_ready_skill 97 has_ready_skill
86 has_ready_wand 98 has_ready_wand
87 has_ready_weapon 99 has_ready_weapon
100 has_ready_range
88 hitback 101 hitback
89 hp 102 hp
90 identified 103 identified
91 immune 104 immune
92 int 105 int
94 invisible 107 invisible
95 is_animated 108 is_animated
96 is_blind 109 is_blind
97 is_buildable 110 is_buildable
98 is_cauldron 111 is_cauldron
112 is_dust
99 is_floor 113 is_floor
100 is_hilly 114 is_hilly
101 is_lightable 115 is_lightable
102 is_thrown 116 is_thrown
103 is_turnable 117 is_turnable
144 no_pick 158 no_pick
145 no_skill_ident 159 no_skill_ident
146 no_steal 160 no_steal
147 no_strength 161 no_strength
148 nrof 162 nrof
163 obj_original
149 object 164 object
150 oid 165 oid
151 one_hit 166 one_hit
152 only_attack 167 only_attack
153 other_arch 168 other_arch
155 path_attuned 170 path_attuned
156 path_denied 171 path_denied
157 path_repelled 172 path_repelled
158 perm_exp 173 perm_exp
159 pick_up 174 pick_up
175 player_sold
160 pow 176 pow
161 protected 177 protected
162 race 178 race
163 random_move 179 random_move
164 random_movement 180 random_movement
221 unaggressive 237 unaggressive
222 undead 238 undead
223 unique 239 unique
224 unpaid 240 unpaid
225 use_content_on_gen 241 use_content_on_gen
242 uuid
226 value 243 value
227 vulnerable 244 vulnerable
228 was_wiz 245 was_wiz
229 wc 246 wc
230 weapontype 247 weapontype
233 wis 250 wis
234 wiz 251 wiz
235 x 252 x
236 xrays 253 xrays
237 y 254 y
255
256 maplore
257 endmaplore
258 enter_x
259 enter_y
260 width
261 height
262 reset_timeout
263 reset_time
264 swap_time
265 difficulty
266 darkness
267 fixed_resettime
268 per_player
269 per_party
270 region
271 shopitems
272 shopgreed
273 shopmin
274 shopmax
275 shoprace
276 outdoor
277 tile_path_1
278 tile_path_2
279 tile_path_3
280 tile_path_4
281
282 file_format_version
283
284 temp
285 pressure
286 humid
287 windspeed
288 winddir
289 sky
290
291 map
292 savebed_map
293 bed_x
294 bed_y
295 password
296 shoottype
297 bowtype
298 petmode
299 gen_hp
300 gen_sp
301 gen_grace
302 listening
303 peaceful
304 digestion
305 pickup
306 outputs_sync
307 outputs_count
308 usekeys
309 unapply
310 weapon_sp
311 lev_array
312 endplst
313
314 color_fg
315 color_bg
316 visibility
317 magicmap
318
319 parent
320 longname
321 jail_map
322 jail_x
323 jail_y
324 fallback
325 nomore
326
327 chance
328 mods
329 diff
330 saves
331 description
332 density
333 damage
334
335 anim
336 mina
337 facings
338 player
339
340 allowed
341 keycode
342 trans
343 yield
344 ingred
345 cauldron
346
347 Str
348 Dex
349 Con
350 Wis
351 Cha
352 Int
353 Pow
238); 354);
239 355
240open GPERF, "|-", "gperf -m50 >kw_hash.h" 356open GPERF, "|-", "exec $ARG{GPERF} -m50 >kw_hash.h"
241 or die "gperf: $!"; 357 or die "$ARGV{GPERF}: $!";
242 358
243print GPERF <<EOF; 359print GPERF <<EOF;
244%language=C++ 360%language=C++
245%enum 361%enum
246%define class-name kw_lex 362%define class-name kw_lex
247%define lookup-function-name match 363%define lookup-function-name match
248%struct-type 364%struct-type
249%compare-strncmp 365%compare-strncmp
250%delimiters=, 366%delimiters=,
251struct kw { const char *name; enum kw index; }; 367struct keyword_idx { const char *name; enum keyword index; };
252%% 368%%
253EOF 369EOF
254 370
255for (@kw) { 371for (@kw) {
256 printf GPERF "%s,%s\n", $_, "KW_" . uc; 372 printf GPERF "%s,%s\n", $_, "KW_$_";
257} 373}
258 374
259print GPERF <<EOF; 375print GPERF <<EOF;
260%% 376%%
261const char *const keyword_str [] = { 377extern const char *const keyword_str [] = {
262 "<EOF>", 378 "<EOF>",
263 "<ERROR>", 379 "<ERROR>",
264EOF 380EOF
265 381
266for (@kw) { 382for (@kw) {
267 printf GPERF " \"%s\",\n", $_; 383 printf GPERF " \"%s\",\n", $_;
268} 384}
269 385
270print GPERF "};\n\n"; 386print GPERF "};\n";
387
388printf GPERF "\nextern const unsigned char keyword_len [] = { 5, 7, %s };\n\n",
389 join ", ", map length, @kw;
390
391close GPERF
392 or die "$ARG{GPERF}: failed to run";
271 393
272open KW, ">", "keyword.h"; 394open KW, ">", "keyword.h";
273 395
274print KW <<EOF; 396print KW <<EOF;
275#ifndef KW_H__ 397#ifndef KW_H__
276#define KW_H__ 398#define KW_H__
277 399
278enum keyword { 400enum keyword {
279 KW_eof, KW_error, 401 KW_NULL = 0,
402 KW_EOF = 0,
403 KW_ERROR,
280EOF 404EOF
281 405
282for (@kw) { 406for (@kw) {
283 printf KW " %s,\n", "KW_" . uc; 407 printf KW " %s,\n", "KW_$_",
284} 408}
285 409
286print KW <<EOF; 410print KW <<EOF;
287 NUM_KEYWORD, 411 NUM_KEYWORD,
288}; 412};
289 413
290extern const char *const keyword_str []; 414extern const char *const keyword_str [];
415extern const unsigned char keyword_len [];
416
417EOF
418
419printf KW "#define MAX_KEYWORD_LEN %d\n", List::Util::max map length, @kw;
420
421print KW <<EOF;
291 422
292#endif 423#endif
293 424
294EOF 425EOF
295 426

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines