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.2 by root, Thu Aug 31 09:19:34 2006 UTC vs.
Revision 1.9 by root, Sat Dec 30 10:16:10 2006 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
83 has_ready_rod 94 has_ready_rod
84 has_ready_scroll 95 has_ready_scroll
85 has_ready_skill 96 has_ready_skill
86 has_ready_wand 97 has_ready_wand
87 has_ready_weapon 98 has_ready_weapon
99 has_ready_range
88 hitback 100 hitback
89 hp 101 hp
90 identified 102 identified
91 immune 103 immune
92 int 104 int
94 invisible 106 invisible
95 is_animated 107 is_animated
96 is_blind 108 is_blind
97 is_buildable 109 is_buildable
98 is_cauldron 110 is_cauldron
111 is_dust
99 is_floor 112 is_floor
100 is_hilly 113 is_hilly
101 is_lightable 114 is_lightable
102 is_thrown 115 is_thrown
103 is_turnable 116 is_turnable
155 path_attuned 168 path_attuned
156 path_denied 169 path_denied
157 path_repelled 170 path_repelled
158 perm_exp 171 perm_exp
159 pick_up 172 pick_up
173 player_sold
160 pow 174 pow
161 protected 175 protected
162 race 176 race
163 random_move 177 random_move
164 random_movement 178 random_movement
221 unaggressive 235 unaggressive
222 undead 236 undead
223 unique 237 unique
224 unpaid 238 unpaid
225 use_content_on_gen 239 use_content_on_gen
240 uuid
226 value 241 value
227 vulnerable 242 vulnerable
228 was_wiz 243 was_wiz
229 wc 244 wc
230 weapontype 245 weapontype
233 wis 248 wis
234 wiz 249 wiz
235 x 250 x
236 xrays 251 xrays
237 y 252 y
253
254 Object
255 Str
256 Dex
257 Con
258 Wis
259 Cha
260 Int
261 Pow
262 More
263
264 maplore
265 endmaplore
266 enter_x
267 enter_y
268 width
269 height
270 reset_timeout
271 reset_time
272 swap_time
273 difficulty
274 darkness
275 fixed_resettime
276 per_player
277 per_party
278 region
279 shopitems
280 shopgreed
281 shopmin
282 shopmax
283 shoprace
284 outdoor
285 tile_path_1
286 tile_path_2
287 tile_path_3
288 tile_path_4
289
290 file_format_version
291
292 temp
293 pressure
294 humid
295 windspeed
296 winddir
297 sky
238); 298);
239 299
240open GPERF, "|-", "gperf -m50 >kw_hash.h" 300open GPERF, "|-", "exec $ARG{GPERF} -m50 >kw_hash.h"
241 or die "gperf: $!"; 301 or die "$ARGV{GPERF}: $!";
242 302
243print GPERF <<EOF; 303print GPERF <<EOF;
244%language=C++ 304%language=C++
245%enum 305%enum
246%define class-name kw_lex 306%define class-name kw_lex
251struct keyword_idx { const char *name; enum keyword index; }; 311struct keyword_idx { const char *name; enum keyword index; };
252%% 312%%
253EOF 313EOF
254 314
255for (@kw) { 315for (@kw) {
256 printf GPERF "%s,%s\n", $_, "KW_" . uc; 316 printf GPERF "%s,%s\n", $_, "KW_$_";
257} 317}
258 318
259print GPERF <<EOF; 319print GPERF <<EOF;
260%% 320%%
261const char *const keyword_str [] = { 321extern const char *const keyword_str [] = {
262 "<EOF>", 322 "<EOF>",
263 "<ERROR>", 323 "<ERROR>",
264EOF 324EOF
265 325
266for (@kw) { 326for (@kw) {
267 printf GPERF " \"%s\",\n", $_; 327 printf GPERF " \"%s\",\n", $_;
268} 328}
269 329
270print GPERF "};\n\n"; 330print GPERF "};\n";
331
332printf GPERF "\nextern const unsigned char keyword_len [] = { 5, 7, %s };\n\n",
333 join ", ", map length, @kw;
334
335close GPERF
336 or die "$ARG{GPERF}: failed to run";
271 337
272open KW, ">", "keyword.h"; 338open KW, ">", "keyword.h";
273 339
274print KW <<EOF; 340print KW <<EOF;
275#ifndef KW_H__ 341#ifndef KW_H__
276#define KW_H__ 342#define KW_H__
277 343
278enum keyword { 344enum keyword {
279 KW_eof, KW_error, 345 KW_NULL = 0,
346 KW_EOF = 0,
347 KW_ERROR,
280EOF 348EOF
281 349
282for (@kw) { 350for (@kw) {
283 printf KW " %s,\n", "KW_" . uc; 351 printf KW " %s,\n", "KW_$_",
284} 352}
285 353
286print KW <<EOF; 354print KW <<EOF;
287 NUM_KEYWORD, 355 NUM_KEYWORD,
288}; 356};
289 357
290extern const char *const keyword_str []; 358extern const char *const keyword_str [];
359extern const unsigned char keyword_len [];
360
361EOF
362
363printf KW "#define MAX_KEYWORD_LEN %d\n", List::Util::max map length, @kw;
364
365print KW <<EOF;
291 366
292#endif 367#endif
293 368
294EOF 369EOF
295 370

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines