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.7 by root, Thu Sep 21 00:05:25 2006 UTC

1#!/opt/bin/perl 1#!/opt/bin/perl
2
3use List::Util;
2 4
3# todo: gather dynamically 5# todo: gather dynamically
4my @kw = qw( 6my @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
240open GPERF, "|-", "gperf -m50 >kw_hash.h" 263open GPERF, "|-", "gperf -m50 >kw_hash.h"
241 or die "gperf: $!"; 264 or die "gperf: $!";
242 265
251struct keyword_idx { const char *name; enum keyword index; }; 274struct keyword_idx { const char *name; enum keyword index; };
252%% 275%%
253EOF 276EOF
254 277
255for (@kw) { 278for (@kw) {
256 printf GPERF "%s,%s\n", $_, "KW_" . uc; 279 printf GPERF "%s,%s\n", $_, "KW_$_";
257} 280}
258 281
259print GPERF <<EOF; 282print GPERF <<EOF;
260%% 283%%
261const char *const keyword_str [] = { 284extern const char *const keyword_str [] = {
262 "<EOF>", 285 "<EOF>",
263 "<ERROR>", 286 "<ERROR>",
264EOF 287EOF
265 288
266for (@kw) { 289for (@kw) {
267 printf GPERF " \"%s\",\n", $_; 290 printf GPERF " \"%s\",\n", $_;
268} 291}
269 292
270print GPERF "};\n\n"; 293print GPERF "};\n";
294
295printf GPERF "\nextern const unsigned char keyword_len [] = { 5, 7, %s };\n\n",
296 join ", ", map length, @kw;
271 297
272open KW, ">", "keyword.h"; 298open KW, ">", "keyword.h";
273 299
274print KW <<EOF; 300print KW <<EOF;
275#ifndef KW_H__ 301#ifndef KW_H__
276#define KW_H__ 302#define KW_H__
277 303
278enum keyword { 304enum keyword {
279 KW_eof, KW_error, 305 KW_NULL = 0,
306 KW_EOF = 0,
307 KW_ERROR,
280EOF 308EOF
281 309
282for (@kw) { 310for (@kw) {
283 printf KW " %s,\n", "KW_" . uc; 311 printf KW " %s,\n", "KW_$_",
284} 312}
285 313
286print KW <<EOF; 314print KW <<EOF;
287 NUM_KEYWORD, 315 NUM_KEYWORD,
288}; 316};
289 317
290extern const char *const keyword_str []; 318extern const char *const keyword_str [];
319extern const unsigned char keyword_len [];
320
321EOF
322
323printf KW "#define MAX_KEYWORD_LEN %d\n", List::Util::max map length, @kw;
324
325print KW <<EOF;
291 326
292#endif 327#endif
293 328
294EOF 329EOF
295 330

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines