2 # this tool generates JUST the autocvar declarations for cvars
13 my ($name, $type, $force) = @_;
16 if(exists $cvars{$name} and $type ne $cvars{$name})
18 warn "cvar $name used with different types";
21 $cvars{$name} = $type;
32 $cvars{$name} = $type;
38 print STDERR "In file $f\n";
43 if(/^\/\/#NO AUTOCVARS START/ .. /^\/\/#NO AUTOCVARS END/)
48 if(/^float autocvar_(.*);$/)
53 if(/^string autocvar_(.*);$/)
55 found $1, 'cvar_string', 1;
58 if(/^#define autocvar_(.*) cvar("\1")$/)
63 if(/^#define autocvar_(.*) cvar_string("\1")$/)
65 found $1, 'cvar_string', 1;
68 while(/\b(cvar|cvar_string)\s*\(\s*"([^"]+)"\s*\)/g)
75 for my $name(sort keys %cvars)
77 my $type = $cvars{$name};
79 if($type eq 'unknown')
81 print "// cannot declare $name, it is used with different types\n";
85 print "float autocvar_$name;\n";
87 if($type eq 'cvar_string')
89 print "string autocvar_$name;\n";
95 print STDERR "In file $f\n";
101 if(/^\/\/#NO AUTOCVARS START/ .. /^\/\/#NO AUTOCVARS END/)
106 if(/^float autocvar_(.*);$/)
111 if(/^string autocvar_(.*);$/)
116 if(/^#define autocvar_(.*) cvar("\1")$/)
121 if(/^#define autocvar_(.*) cvar_string("\1")$/)
126 s{\b(cvar|cvar_string)\s*\(\s*"([^"]+)"\s*\)}{
127 my ($type, $name) = ($1, $2);
128 my $realtype = $cvars{$name};
130 if(defined $realtype)
132 #$r = "$realtype(\"$name\")";
133 $r = "autocvar_$name";
134 if($type eq 'cvar' && $realtype eq 'cvar_string')
138 if($type eq 'cvar_string' && $realtype eq 'cvar')