+
+ if($c->{isreturn})
+ {
+ if ($$state >= 0) {
+ ++$warned{$$state}{''}{"Changing .solid without setmodel/setorigin/setsize breaks area grid linking in Quake [write is here]"};
+ ++$warned{$ip}{''}{"Changing .solid without setmodel/setorigin/setsize breaks area grid linking in Quake [return is here]"};
+ }
+ }
+
+ return 0;
+ };
+
+ disassemble_function($progs, $func, \%warned)
+ if keys %warned;
+}
+
+use constant DEFAULTGLOBALS => [
+ "OFS_NULL",
+ "OFS_RETURN",
+ "OFS_RETURN[1]",
+ "OFS_RETURN[2]",
+ "OFS_PARM0",
+ "OFS_PARM0[1]",
+ "OFS_PARM0[2]",
+ "OFS_PARM1",
+ "OFS_PARM1[1]",
+ "OFS_PARM1[2]",
+ "OFS_PARM2",
+ "OFS_PARM2[1]",
+ "OFS_PARM2[2]",
+ "OFS_PARM3",
+ "OFS_PARM3[1]",
+ "OFS_PARM3[2]",
+ "OFS_PARM4",
+ "OFS_PARM4[1]",
+ "OFS_PARM4[2]",
+ "OFS_PARM5",
+ "OFS_PARM5[1]",
+ "OFS_PARM5[2]",
+ "OFS_PARM6",
+ "OFS_PARM6[1]",
+ "OFS_PARM6[2]",
+ "OFS_PARM7",
+ "OFS_PARM7[1]",
+ "OFS_PARM7[2]"
+];
+
+sub defaultglobal($)
+{
+ my ($ofs) = @_;
+ if($ofs < @{(DEFAULTGLOBALS)})
+ {
+ return { ofs => $ofs, s_name => undef, debugname => DEFAULTGLOBALS->[$ofs], type => undef };
+ }
+ return { ofs => $ofs, s_name => undef, debugname => "<undefined>\@$ofs", type => undef };
+}
+
+sub detect_constants($)
+{
+ my ($progs) = @_;
+ use constant GLOBALFLAG_R => 1; # read
+ use constant GLOBALFLAG_W => 2; # written
+ use constant GLOBALFLAG_S => 4; # saved
+ use constant GLOBALFLAG_I => 8; # initialized
+ use constant GLOBALFLAG_N => 16; # named
+ use constant GLOBALFLAG_Q => 32; # unique to function
+ use constant GLOBALFLAG_U => 64; # unused
+ use constant GLOBALFLAG_P => 128; # possibly parameter passing
+ use constant GLOBALFLAG_D => 256; # has a def
+ my @globalflags = (GLOBALFLAG_Q | GLOBALFLAG_U) x (@{$progs->{globals}} + 2);
+
+ for(@{$progs->{functions}})
+ {
+ for(keys %{$_->{globals_used}})
+ {
+ if($globalflags[$_] & GLOBALFLAG_U)
+ {
+ $globalflags[$_] &= ~GLOBALFLAG_U;
+ }
+ elsif($globalflags[$_] & GLOBALFLAG_Q)
+ {
+ $globalflags[$_] &= ~GLOBALFLAG_Q;
+ }
+ }
+ $globalflags[$_] |= GLOBALFLAG_R
+ for keys %{$_->{globals_read}};
+ $globalflags[$_] |= GLOBALFLAG_W
+ for keys %{$_->{globals_written}};
+ next
+ if $_->{first_statement} < 0;
+ for my $ip($_->{first_statement} .. (@{$progs->{statements}}-1))
+ {
+ my $s = $progs->{statements}[$ip];
+ if($s->{op} eq 'STORE_V')
+ {
+ $globalflags[$s->{a}] |= GLOBALFLAG_P
+ if $s->{b} >= $_->{parm_start} and $s->{b} < $_->{parm_start} + $_->{locals};
+ $globalflags[$s->{a}+1] |= GLOBALFLAG_P
+ if $s->{b}+1 >= $_->{parm_start} and $s->{b}+1 < $_->{parm_start} + $_->{locals};
+ $globalflags[$s->{a}+2] |= GLOBALFLAG_P
+ if $s->{b}+2 >= $_->{parm_start} and $s->{b}+2 < $_->{parm_start} + $_->{locals};
+ }
+ elsif($s->{op} =~ /^STORE_/)
+ {
+ $globalflags[$s->{a}] |= GLOBALFLAG_P
+ if $s->{b} >= $_->{parm_start} and $s->{b} < $_->{parm_start} + $_->{locals};
+ }