ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/preprocess
Revision: 1.8
Committed: Mon Dec 11 19:10:58 2006 UTC (17 years, 5 months ago) by root
Branch: MAIN
Changes since 1.7: +7 -2 lines
Log Message:
- portability fixes
- fail when GPERF not found

File Contents

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