]> de.git.xonotic.org Git - xonotic/xonotic-maps.pk3dir.git/blob - scripts/entities.def2ent
Merge branch 'master' of git://git.xonotic.org/xonotic/xonotic-maps.pk3dir
[xonotic/xonotic-maps.pk3dir.git] / scripts / entities.def2ent
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 my %types;
7 my %types_override;
8
9 open my $fh, '<', '../../xonotic-data.pk3dir/qcsrc/server/qc.asm'
10         or die "must have qc.asm in server qc";
11 while(<$fh>)
12 {
13         chomp;
14         if(/^\.(\w+) (\w+);$/)
15         {
16                 if($1 eq "float")
17                 {
18                         $types{$2} = "real";
19                 }
20                 elsif($1 eq "string")
21                 {
22                         $types{$2} = "string";
23                 }
24                 elsif($1 eq "vector")
25                 {
26                         $types{$2} = "real3";
27                 }
28         }
29 }
30
31 # specialization
32 $types{angle} = "direction";
33 $types{angles} = "angles";
34 $types{_color} = "color";
35 $types{colormod} = "color";
36 $types{killtarget} = "target";
37 $types{model2} = "model";
38 $types{model} = "model";
39 $types{noise} = "sound";
40 $types{noise1} = "sound";
41 $types{noise2} = "sound";
42 $types{noise3} = "sound";
43 $types{target2} = "target";
44 $types{target3} = "target";
45 $types{target4} = "target";
46 $types{targetname} = "targetname";
47 $types{target} = "target";
48 $types{team} = "integer";
49
50 # missing definition in QC, q3map2 only
51 $types{_ambient} = "real";
52 $types{_anglescale} = "real";
53 $types{author} = "string";
54 $types{_blocksize} = "integer3";
55 $types{_castshadows} = "boolean";
56 $types{_celshader} = "texture";
57 $types{_clonename} = "targetname";
58 $types{_clone} = "target";
59 $types{_description} = "string";
60 $types{_deviance} = "real";
61 $types{fade} = "real";
62 $types{_farplanedist} = "real";
63 $types{_filterradius} = "real";
64 $types{_floodlight} = "string";
65 $types{_frame} = "real";
66 $types{gridsize} = "integer3";
67 $types{_ignoreleaks} = "boolean";
68 $types{_indexmap} = "texture";
69 $types{key1} = "string";
70 $types{key2} = "string";
71 $types{_layers} = "integer";
72 $types{_lightmapscale} = "real";
73 $types{light} = "real";
74 $types{max} = "real3";
75 $types{_mingridlight} = "real";
76 $types{_minlight} = "real";
77 $types{min} = "real3";
78 $types{modelscale_vec} = "real3";
79 $types{_noshadersun} = "boolean";
80 $types{_offsets} = "string";
81 $types{_receiveshadows} = "boolean";
82 $types{_remap} = "array";
83 $types{_samples} = "integer";
84 $types{_scale} = "real";
85 $types{_shader} = "texture";
86 $types{_sun} = "boolean";
87
88 # XML types:
89 # angle           specialisation of real - Yaw angle
90 # angles          specialisation of real3 - Pitch Yaw Roll
91 # array           an array of strings - value is a semi-colon-delimited string
92 # boolean         an integer - shows as a checkbox - true = non-zero
93 # color           specialisation of real3 - RGB floating-point colour
94 # direction       specialisation of real - Yaw angle, -1 = down, -2 = up
95 # integer2        two integer values
96 # integer3        three integer values
97 # integer         an integer value
98 # model           the VFS path to a model file
99 # skin            the VFS path to a skin file
100 # sound           the VFS path to a sound file
101 # target          a string that uniquely identifies an entity or group of entities
102 # targetname      a string that uniquely identifies an entity or group of entities
103 # texture         the VFS path to a texture file or a shader name
104
105
106 print <<EOF;
107 <?xml version="1.0"?>
108 <classes>
109 EOF
110
111 my $closetag;
112 my @spawnflags;
113 my $class;
114 while(<STDIN>)
115 {
116         chomp;
117         s/&/&amp;/g;
118         s/</&lt;/g;
119         s/>/&gt;/g;
120         s/"/&quot;/g;
121         if(/^\/\*QUAKED (\S+) \((\S+ \S+ \S+)\) \((\S+ \S+ \S+)\) \((\S+ \S+ \S+)\) ?(.*)/)
122         {
123                 $class = $1;
124                 print "<point name=\"$1\" color=\"$2\" box=\"$3 $4\">\n";
125                 $closetag = "</point>";
126                 @spawnflags = split / /, $5;
127         }
128         elsif(/^\/\*QUAKED (\S+) \((\S+ \S+ \S+)\) \? ?(.*)/)
129         {
130                 $class = $1;
131                 print "<group name=\"$1\" color=\"$2\">\n";
132                 $closetag = "</group>";
133                 @spawnflags = split / /, $3;
134         }
135         elsif(/^\*\/$/)
136         {
137                 print "$closetag\n";
138         }
139         elsif(/^([0-9a-z_]*): +(.*)/)
140         {
141                 my $type = $types_override{$class}{$1} || $types{$1};
142                 warn "No type for $1"
143                         if not defined $type;
144                 print "<$type key=\"$1\" name=\"$1\">$2</$type>\n";
145         }
146         elsif(/^([0-9A-Z_]*): +(.*)/)
147         {
148                 my $bit = [grep { $spawnflags[$_] eq $1; } 0..@spawnflags-1]->[0];
149                 warn "Cannot find bit $1 in @spawnflags\n"
150                         if not defined $bit;
151                 print "<flag key=\"$1\" name=\"$1\" bit=\"$bit\">$2</flag>\n";
152         }
153         else
154         {
155                 print "$_\n";
156         }
157 }
158
159 print <<EOF;
160 </classes>
161 EOF