newlines fixed
This commit is contained in:
parent
7830940da6
commit
59cce31e75
1121 changed files with 717537 additions and 717537 deletions
862
code/Construct
862
code/Construct
|
|
@ -1,431 +1,431 @@
|
||||||
# -*- mode: perl -*-
|
# -*- mode: perl -*-
|
||||||
# cons script for cgame game q3_ui ui .so and .qvm builds
|
# cons script for cgame game q3_ui ui .so and .qvm builds
|
||||||
#
|
#
|
||||||
# Oct. 2001 TTimo <ttimo@idsoftware.com>
|
# Oct. 2001 TTimo <ttimo@idsoftware.com>
|
||||||
#
|
#
|
||||||
|
|
||||||
# the top directory is
|
# the top directory is
|
||||||
# <config>-<cpu>-<OS>-<libc version>
|
# <config>-<cpu>-<OS>-<libc version>
|
||||||
# where:
|
# where:
|
||||||
# <config> is "debug" or "release"
|
# <config> is "debug" or "release"
|
||||||
# <cpu> is "x86" or "ppc"
|
# <cpu> is "x86" or "ppc"
|
||||||
# <OS> is "Linux" "BSD" "IRIX" etc.
|
# <OS> is "Linux" "BSD" "IRIX" etc.
|
||||||
# <libc version> is major.minor of libc config
|
# <libc version> is major.minor of libc config
|
||||||
|
|
||||||
# source the compiler version utility
|
# source the compiler version utility
|
||||||
BEGIN {
|
BEGIN {
|
||||||
push @INC, './unix';
|
push @INC, './unix';
|
||||||
}
|
}
|
||||||
use Cons_gcc;
|
use Cons_gcc;
|
||||||
|
|
||||||
# defaults
|
# defaults
|
||||||
$config = 'debug';
|
$config = 'debug';
|
||||||
$do_smp = 1;
|
$do_smp = 1;
|
||||||
$do_masterserver = 0;
|
$do_masterserver = 0;
|
||||||
$do_authserver = 0;
|
$do_authserver = 0;
|
||||||
$do_authport = 0;
|
$do_authport = 0;
|
||||||
$do_setup = 0;
|
$do_setup = 0;
|
||||||
$do_bspc = 0;
|
$do_bspc = 0;
|
||||||
$do_sdk = 0;
|
$do_sdk = 0;
|
||||||
$do_pk3 = 0;
|
$do_pk3 = 0;
|
||||||
# those are exported
|
# those are exported
|
||||||
$DO_WIN32 = 0;
|
$DO_WIN32 = 0;
|
||||||
$NO_VM = 0;
|
$NO_VM = 0;
|
||||||
$NO_SO = 0;
|
$NO_SO = 0;
|
||||||
$CC='gcc';
|
$CC='gcc';
|
||||||
$CXX='g++';
|
$CXX='g++';
|
||||||
|
|
||||||
# detect an sdk build (don't attempt client build and other things)
|
# detect an sdk build (don't attempt client build and other things)
|
||||||
if ( -r 'unix/Conscript-client' )
|
if ( -r 'unix/Conscript-client' )
|
||||||
{
|
{
|
||||||
$no_core = 0;
|
$no_core = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$no_core = 1;
|
$no_core = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
# detection of CPU type
|
# detection of CPU type
|
||||||
$cpu = `uname -m`;
|
$cpu = `uname -m`;
|
||||||
chop ($cpu);
|
chop ($cpu);
|
||||||
if ($cpu +~ /i?86/)
|
if ($cpu +~ /i?86/)
|
||||||
{
|
{
|
||||||
$cpu = 'x86';
|
$cpu = 'x86';
|
||||||
}
|
}
|
||||||
# OS
|
# OS
|
||||||
$OS = `uname`;
|
$OS = `uname`;
|
||||||
chop ($OS);
|
chop ($OS);
|
||||||
# hacky win32 detection and win32 specifics code
|
# hacky win32 detection and win32 specifics code
|
||||||
if ($OS =~ CYGWIN)
|
if ($OS =~ CYGWIN)
|
||||||
{
|
{
|
||||||
$DO_WIN32 = 1;
|
$DO_WIN32 = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
# libc .. do the little magic!
|
# libc .. do the little magic!
|
||||||
$libc_cmd = '/lib/libc.so.6 |grep "GNU C "|grep version|awk -F "version " \'{ print $2 }\'|cut -b -3';
|
$libc_cmd = '/lib/libc.so.6 |grep "GNU C "|grep version|awk -F "version " \'{ print $2 }\'|cut -b -3';
|
||||||
$libc = `$libc_cmd`;
|
$libc = `$libc_cmd`;
|
||||||
chop ($libc);
|
chop ($libc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($DO_WIN32 eq 1)
|
if ($DO_WIN32 eq 1)
|
||||||
{
|
{
|
||||||
print("Win32 build\n");
|
print("Win32 build\n");
|
||||||
|
|
||||||
$config = $ARGV[0];
|
$config = $ARGV[0];
|
||||||
|
|
||||||
# TODO: option to override $Q3BASE from command line
|
# TODO: option to override $Q3BASE from command line
|
||||||
$Q3BASE = $ENV{Q3BASE}; # FIXME: this doesn't play nice with cygwin path syntax
|
$Q3BASE = $ENV{Q3BASE}; # FIXME: this doesn't play nice with cygwin path syntax
|
||||||
print("\$Q3BASE: $Q3BASE\n");
|
print("\$Q3BASE: $Q3BASE\n");
|
||||||
|
|
||||||
if($config eq 'debug')
|
if($config eq 'debug')
|
||||||
{
|
{
|
||||||
$DIR = 'Debug';
|
$DIR = 'Debug';
|
||||||
system("cp -v $DIR/quake3.exe \$Q3BASE");
|
system("cp -v $DIR/quake3.exe \$Q3BASE");
|
||||||
system("cp -v $DIR/cgamex86.dll $DIR/qagamex86.dll $DIR/uix86.dll \$Q3BASE/baseq3");
|
system("cp -v $DIR/cgamex86.dll $DIR/qagamex86.dll $DIR/uix86.dll \$Q3BASE/baseq3");
|
||||||
}
|
}
|
||||||
elsif ($config eq 'debug-TA')
|
elsif ($config eq 'debug-TA')
|
||||||
{
|
{
|
||||||
$DIR = 'Debug_TA';
|
$DIR = 'Debug_TA';
|
||||||
system("cp -v $DIR/quake3.exe \$Q3BASE");
|
system("cp -v $DIR/quake3.exe \$Q3BASE");
|
||||||
system("cp -v $DIR/cgamex86.dll $DIR/qagamex86.dll $DIR/uix86.dll \$Q3BASE/missionpack");
|
system("cp -v $DIR/cgamex86.dll $DIR/qagamex86.dll $DIR/uix86.dll \$Q3BASE/missionpack");
|
||||||
}
|
}
|
||||||
elsif($config eq 'release-TA')
|
elsif($config eq 'release-TA')
|
||||||
{
|
{
|
||||||
$DIR = 'Release_TA';
|
$DIR = 'Release_TA';
|
||||||
# spank!
|
# spank!
|
||||||
system("./spank.sh");
|
system("./spank.sh");
|
||||||
system("cp -v $DIR/quake3.exe \$Q3BASE");
|
system("cp -v $DIR/quake3.exe \$Q3BASE");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("ERROR: no config option (debug debug-TA release-TA)");
|
printf("ERROR: no config option (debug debug-TA release-TA)");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
# copy selected stuff to shared media
|
# copy selected stuff to shared media
|
||||||
$DESTDIR='/cygdrive/e/incoming/Id/q3-1.32';
|
$DESTDIR='/cygdrive/e/incoming/Id/q3-1.32';
|
||||||
system("cp -v $DIR/quake3.exe $DESTDIR");
|
system("cp -v $DIR/quake3.exe $DESTDIR");
|
||||||
system("cp -v /cygdrive/e/Q3SetupMedia/quake3/CHANGES-1.32.txt $DESTDIR");
|
system("cp -v /cygdrive/e/Q3SetupMedia/quake3/CHANGES-1.32.txt $DESTDIR");
|
||||||
|
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(@ARGV gt 0)
|
if(@ARGV gt 0)
|
||||||
{
|
{
|
||||||
foreach $cmdopt (@ARGV)
|
foreach $cmdopt (@ARGV)
|
||||||
{
|
{
|
||||||
if(lc($cmdopt) eq 'release')
|
if(lc($cmdopt) eq 'release')
|
||||||
{
|
{
|
||||||
$config = 'release';
|
$config = 'release';
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
elsif(lc($cmdopt) eq 'debug')
|
elsif(lc($cmdopt) eq 'debug')
|
||||||
{
|
{
|
||||||
$config = 'debug';
|
$config = 'debug';
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
elsif(lc($cmdopt) eq 'novm')
|
elsif(lc($cmdopt) eq 'novm')
|
||||||
{
|
{
|
||||||
$NO_VM = 1;
|
$NO_VM = 1;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
elsif(lc($cmdopt) eq 'noso')
|
elsif(lc($cmdopt) eq 'noso')
|
||||||
{
|
{
|
||||||
$NO_SO = 1;
|
$NO_SO = 1;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
elsif(lc($cmdopt) eq 'nosmp')
|
elsif(lc($cmdopt) eq 'nosmp')
|
||||||
{
|
{
|
||||||
$do_smp = 0;
|
$do_smp = 0;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
elsif(lc($cmdopt) =~ 'master_server=.*')
|
elsif(lc($cmdopt) =~ 'master_server=.*')
|
||||||
{
|
{
|
||||||
$do_masterserver = 1;
|
$do_masterserver = 1;
|
||||||
$master_server = lc($cmdopt);
|
$master_server = lc($cmdopt);
|
||||||
$master_server =~ s/master_server=(.*)/\1/;
|
$master_server =~ s/master_server=(.*)/\1/;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
elsif(lc($cmdopt) =~ 'auth_server=.*')
|
elsif(lc($cmdopt) =~ 'auth_server=.*')
|
||||||
{
|
{
|
||||||
$do_authserver = 1;
|
$do_authserver = 1;
|
||||||
$auth_server = lc($cmdopt);
|
$auth_server = lc($cmdopt);
|
||||||
$auth_server =~ s/auth_server=(.*)/\1/;
|
$auth_server =~ s/auth_server=(.*)/\1/;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
elsif(lc($cmdopt) =~ 'auth_port=.*')
|
elsif(lc($cmdopt) =~ 'auth_port=.*')
|
||||||
{
|
{
|
||||||
$do_authport = 1;
|
$do_authport = 1;
|
||||||
$auth_port = lc($cmdopt);
|
$auth_port = lc($cmdopt);
|
||||||
$auth_port =~ s/auth_port=(.*)/\1/;
|
$auth_port =~ s/auth_port=(.*)/\1/;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
elsif(lc($cmdopt) =~ 'setup')
|
elsif(lc($cmdopt) =~ 'setup')
|
||||||
{
|
{
|
||||||
$do_setup = 1;
|
$do_setup = 1;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
elsif(lc($cmdopt) =~ 'bspc')
|
elsif(lc($cmdopt) =~ 'bspc')
|
||||||
{
|
{
|
||||||
$do_bspc = 1;
|
$do_bspc = 1;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
elsif(lc($cmdopt) =~ 'sdk')
|
elsif(lc($cmdopt) =~ 'sdk')
|
||||||
{
|
{
|
||||||
$do_sdk = 1;
|
$do_sdk = 1;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
elsif(lc($cmdopt) =~ 'pk3')
|
elsif(lc($cmdopt) =~ 'pk3')
|
||||||
{
|
{
|
||||||
$do_pk3 = 1;
|
$do_pk3 = 1;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
elsif(lc($cmdopt) =~ 'gcc=.*')
|
elsif(lc($cmdopt) =~ 'gcc=.*')
|
||||||
{
|
{
|
||||||
$CC=lc($cmdopt);
|
$CC=lc($cmdopt);
|
||||||
$CC =~ s/gcc=(.*)/\1/;
|
$CC =~ s/gcc=(.*)/\1/;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
elsif(lc($cmdopt) =~ 'g\+\+=.*')
|
elsif(lc($cmdopt) =~ 'g\+\+=.*')
|
||||||
{
|
{
|
||||||
$CXX=lc($cmdopt);
|
$CXX=lc($cmdopt);
|
||||||
$CXX=~s/g\+\+=(.*)/\1/;
|
$CXX=~s/g\+\+=(.*)/\1/;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
# output an error & exit
|
# output an error & exit
|
||||||
print("Error\n $0: Unknown command line option: [ $cmdopt ]\n");
|
print("Error\n $0: Unknown command line option: [ $cmdopt ]\n");
|
||||||
system("cons -h");
|
system("cons -h");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($do_setup eq 1) && ($config ne 'release'))
|
if (($do_setup eq 1) && ($config ne 'release'))
|
||||||
{
|
{
|
||||||
print("Error\n $0: 'setup' requires 'release'\n");
|
print("Error\n $0: 'setup' requires 'release'\n");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
# sdk
|
# sdk
|
||||||
if ($do_sdk eq 1)
|
if ($do_sdk eq 1)
|
||||||
{
|
{
|
||||||
# extract the Q3 version from q_shared.h
|
# extract the Q3 version from q_shared.h
|
||||||
$line = `cat game/q_shared.h | grep Q3_VERSION`;
|
$line = `cat game/q_shared.h | grep Q3_VERSION`;
|
||||||
chomp $line;
|
chomp $line;
|
||||||
$line =~ s/.*Q3\ (.*)\"/$1/;
|
$line =~ s/.*Q3\ (.*)\"/$1/;
|
||||||
$Q3_VER = $line;
|
$Q3_VER = $line;
|
||||||
$SDK_NAME = "linuxq3a-sdk-$Q3_VER.x86.run";
|
$SDK_NAME = "linuxq3a-sdk-$Q3_VER.x86.run";
|
||||||
Default "unix/$SDK_NAME";
|
Default "unix/$SDK_NAME";
|
||||||
Export qw( SDK_NAME Q3_VER );
|
Export qw( SDK_NAME Q3_VER );
|
||||||
Build 'unix/Conscript-sdk';
|
Build 'unix/Conscript-sdk';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
# build the config directory
|
# build the config directory
|
||||||
$CONFIG_DIR = $config . '-' . $cpu . '-' . $OS . '-' . $libc;
|
$CONFIG_DIR = $config . '-' . $cpu . '-' . $OS . '-' . $libc;
|
||||||
|
|
||||||
$COMMON_CFLAGS = '-pipe -fsigned-char ';
|
$COMMON_CFLAGS = '-pipe -fsigned-char ';
|
||||||
|
|
||||||
if ($config eq 'debug')
|
if ($config eq 'debug')
|
||||||
{
|
{
|
||||||
# use -Werror for better QA
|
# use -Werror for better QA
|
||||||
$BASE_CFLAGS = $COMMON_CFLAGS . '-g -Wall -Werror -O ';
|
$BASE_CFLAGS = $COMMON_CFLAGS . '-g -Wall -Werror -O ';
|
||||||
$BSPC_BASE_CFLAGS = $COMMON_CFLAGS . '-g -O -DLINUX -DBSPC -Dstricmp=strcasecmp ';
|
$BSPC_BASE_CFLAGS = $COMMON_CFLAGS . '-g -O -DLINUX -DBSPC -Dstricmp=strcasecmp ';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$BASE_CFLAGS = $COMMON_CFLAGS . '-DNDEBUG -O6 -mcpu=pentiumpro -march=pentium -fomit-frame-pointer -ffast-math -malign-loops=2 -malign-jumps=2 -malign-functions=2 -fno-strict-aliasing -fstrength-reduce ';
|
$BASE_CFLAGS = $COMMON_CFLAGS . '-DNDEBUG -O6 -mcpu=pentiumpro -march=pentium -fomit-frame-pointer -ffast-math -malign-loops=2 -malign-jumps=2 -malign-functions=2 -fno-strict-aliasing -fstrength-reduce ';
|
||||||
$BSPC_BASE_CFLAGS = $BASE_CFLAGS . '-DLINUX -DBSPC -Dstricmp=strcasecmp ';
|
$BSPC_BASE_CFLAGS = $BASE_CFLAGS . '-DLINUX -DBSPC -Dstricmp=strcasecmp ';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($do_masterserver eq 1)
|
if ($do_masterserver eq 1)
|
||||||
{
|
{
|
||||||
$BASE_CFLAGS .= "-DMASTER_SERVER_NAME=\\\"$master_server\\\" ";
|
$BASE_CFLAGS .= "-DMASTER_SERVER_NAME=\\\"$master_server\\\" ";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($do_authserver eq 1)
|
if ($do_authserver eq 1)
|
||||||
{
|
{
|
||||||
$BASE_CFLAGS .= "-DAUTHORIZE_SERVER_NAME=\\\"$auth_server\\\" ";
|
$BASE_CFLAGS .= "-DAUTHORIZE_SERVER_NAME=\\\"$auth_server\\\" ";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($do_authport eq 1)
|
if ($do_authport eq 1)
|
||||||
{
|
{
|
||||||
$BASE_CFLAGS .= "-DPORT_AUTHORIZE=$auth_port ";
|
$BASE_CFLAGS .= "-DPORT_AUTHORIZE=$auth_port ";
|
||||||
}
|
}
|
||||||
|
|
||||||
my @gcc_version = Cons_gcc::get_gcc_version($CC);
|
my @gcc_version = Cons_gcc::get_gcc_version($CC);
|
||||||
print("GCC version: $gcc_version[1] - $gcc_version[2]\n");
|
print("GCC version: $gcc_version[1] - $gcc_version[2]\n");
|
||||||
# with 2.95 you can link with gcc, this avoids nasty useless libstdc++ dependency
|
# with 2.95 you can link with gcc, this avoids nasty useless libstdc++ dependency
|
||||||
if ($gcc_version[0] eq '2')
|
if ($gcc_version[0] eq '2')
|
||||||
{
|
{
|
||||||
$LINK = $CC;
|
$LINK = $CC;
|
||||||
} else {
|
} else {
|
||||||
$LINK = $CXX;
|
$LINK = $CXX;
|
||||||
}
|
}
|
||||||
|
|
||||||
my @ccache = Cons_gcc::get_ccache();
|
my @ccache = Cons_gcc::get_ccache();
|
||||||
if ($ccache[0] eq '1')
|
if ($ccache[0] eq '1')
|
||||||
{
|
{
|
||||||
$CC = $ccache[1] . " " . $CC;
|
$CC = $ccache[1] . " " . $CC;
|
||||||
$CXX = $ccache[1] . " " . $CXX;
|
$CXX = $ccache[1] . " " . $CXX;
|
||||||
}
|
}
|
||||||
|
|
||||||
print 'cpu : ' . $cpu . "\nOS : " . $OS . "\n";
|
print 'cpu : ' . $cpu . "\nOS : " . $OS . "\n";
|
||||||
print "libc: " . $libc . "\n";
|
print "libc: " . $libc . "\n";
|
||||||
print "configured for " . $config . " build\n";
|
print "configured for " . $config . " build\n";
|
||||||
print 'CFLAGS: ' . $BASE_CFLAGS . "\n";
|
print 'CFLAGS: ' . $BASE_CFLAGS . "\n";
|
||||||
|
|
||||||
# install config
|
# install config
|
||||||
$INSTALL_BASEDIR='#install';
|
$INSTALL_BASEDIR='#install';
|
||||||
|
|
||||||
Default $INSTALL_BASEDIR;
|
Default $INSTALL_BASEDIR;
|
||||||
|
|
||||||
sub build_tools {
|
sub build_tools {
|
||||||
system("mkdir qvmtools 2>/dev/null");
|
system("mkdir qvmtools 2>/dev/null");
|
||||||
if (@_[0] eq 'q3lcc')
|
if (@_[0] eq 'q3lcc')
|
||||||
{
|
{
|
||||||
system("cd ../lcc ; make all ; cp /tmp/lcc ../code/qvmtools/q3lcc ; cp /tmp/rcc ../code/qvmtools/q3rcc ; cp /tmp/cpp ../code/qvmtools/q3cpp");
|
system("cd ../lcc ; make all ; cp /tmp/lcc ../code/qvmtools/q3lcc ; cp /tmp/rcc ../code/qvmtools/q3rcc ; cp /tmp/cpp ../code/qvmtools/q3cpp");
|
||||||
}
|
}
|
||||||
elsif (@_[0] eq 'q3asm')
|
elsif (@_[0] eq 'q3asm')
|
||||||
{
|
{
|
||||||
system("cd ../q3asm ; make ; cp q3asm ../code/qvmtools");
|
system("cd ../q3asm ; make ; cp q3asm ../code/qvmtools");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("build_tools: @_[0] unrecognized command\n");
|
printf("build_tools: @_[0] unrecognized command\n");
|
||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
# build tools
|
# build tools
|
||||||
$env_tools = new cons();
|
$env_tools = new cons();
|
||||||
Command $env_tools 'qvmtools/q3lcc', '[perl] &build_tools(\'q3lcc\')';
|
Command $env_tools 'qvmtools/q3lcc', '[perl] &build_tools(\'q3lcc\')';
|
||||||
Command $env_tools 'qvmtools/q3asm', '[perl] &build_tools(\'q3asm\')';
|
Command $env_tools 'qvmtools/q3asm', '[perl] &build_tools(\'q3asm\')';
|
||||||
|
|
||||||
if ($do_bspc eq 1)
|
if ($do_bspc eq 1)
|
||||||
{
|
{
|
||||||
# build bspc
|
# build bspc
|
||||||
$BUILD_DIR = $CONFIG_DIR . '/bspc';
|
$BUILD_DIR = $CONFIG_DIR . '/bspc';
|
||||||
Link $BUILD_DIR => '.';
|
Link $BUILD_DIR => '.';
|
||||||
$INSTALL_DIR = $INSTALL_BASEDIR . '/utils';
|
$INSTALL_DIR = $INSTALL_BASEDIR . '/utils';
|
||||||
Export qw( BSPC_BASE_CFLAGS BUILD_DIR INSTALL_DIR CC CXX LINK );
|
Export qw( BSPC_BASE_CFLAGS BUILD_DIR INSTALL_DIR CC CXX LINK );
|
||||||
Build $BUILD_DIR . '/bspc/Conscript';
|
Build $BUILD_DIR . '/bspc/Conscript';
|
||||||
}
|
}
|
||||||
|
|
||||||
# build vanilla Q3
|
# build vanilla Q3
|
||||||
$TARGET_DIR='Q3';
|
$TARGET_DIR='Q3';
|
||||||
|
|
||||||
$INSTALL_DIR = $INSTALL_BASEDIR . '/baseq3';
|
$INSTALL_DIR = $INSTALL_BASEDIR . '/baseq3';
|
||||||
|
|
||||||
$BUILD_DIR = $CONFIG_DIR . '/' . $TARGET_DIR . '/cgame';
|
$BUILD_DIR = $CONFIG_DIR . '/' . $TARGET_DIR . '/cgame';
|
||||||
Link $BUILD_DIR => '.';
|
Link $BUILD_DIR => '.';
|
||||||
Export qw( BASE_CFLAGS TARGET_DIR INSTALL_DIR NO_VM NO_SO CC CXX LINK );
|
Export qw( BASE_CFLAGS TARGET_DIR INSTALL_DIR NO_VM NO_SO CC CXX LINK );
|
||||||
Build $BUILD_DIR . '/cgame/Conscript';
|
Build $BUILD_DIR . '/cgame/Conscript';
|
||||||
|
|
||||||
$BUILD_DIR = $CONFIG_DIR . '/' . $TARGET_DIR . '/game';
|
$BUILD_DIR = $CONFIG_DIR . '/' . $TARGET_DIR . '/game';
|
||||||
Link $BUILD_DIR => '.';
|
Link $BUILD_DIR => '.';
|
||||||
Export qw( BASE_CFLAGS TARGET_DIR INSTALL_DIR NO_VM NO_SO CC CXX LINK );
|
Export qw( BASE_CFLAGS TARGET_DIR INSTALL_DIR NO_VM NO_SO CC CXX LINK );
|
||||||
Build $BUILD_DIR . '/game/Conscript';
|
Build $BUILD_DIR . '/game/Conscript';
|
||||||
|
|
||||||
$BUILD_DIR = $CONFIG_DIR . '/' . $TARGET_DIR . '/q3_ui';
|
$BUILD_DIR = $CONFIG_DIR . '/' . $TARGET_DIR . '/q3_ui';
|
||||||
Link $BUILD_DIR => '.';
|
Link $BUILD_DIR => '.';
|
||||||
Export qw( BASE_CFLAGS TARGET_DIR INSTALL_DIR NO_VM NO_SO CC CXX LINK );
|
Export qw( BASE_CFLAGS TARGET_DIR INSTALL_DIR NO_VM NO_SO CC CXX LINK );
|
||||||
Build $BUILD_DIR . '/q3_ui/Conscript';
|
Build $BUILD_DIR . '/q3_ui/Conscript';
|
||||||
|
|
||||||
# build TA
|
# build TA
|
||||||
$TARGET_DIR='TA';
|
$TARGET_DIR='TA';
|
||||||
|
|
||||||
$INSTALL_DIR = $INSTALL_BASEDIR . '/missionpack';
|
$INSTALL_DIR = $INSTALL_BASEDIR . '/missionpack';
|
||||||
|
|
||||||
$BUILD_DIR = $CONFIG_DIR . "/" . $TARGET_DIR . '/cgame';
|
$BUILD_DIR = $CONFIG_DIR . "/" . $TARGET_DIR . '/cgame';
|
||||||
Link $BUILD_DIR => '.';
|
Link $BUILD_DIR => '.';
|
||||||
Export qw( BASE_CFLAGS TARGET_DIR INSTALL_DIR NO_VM NO_SO CC CXX LINK );
|
Export qw( BASE_CFLAGS TARGET_DIR INSTALL_DIR NO_VM NO_SO CC CXX LINK );
|
||||||
Build $BUILD_DIR . '/cgame/Conscript';
|
Build $BUILD_DIR . '/cgame/Conscript';
|
||||||
|
|
||||||
$BUILD_DIR = $CONFIG_DIR . "/" . $TARGET_DIR . '/game';
|
$BUILD_DIR = $CONFIG_DIR . "/" . $TARGET_DIR . '/game';
|
||||||
Link $BUILD_DIR => '.';
|
Link $BUILD_DIR => '.';
|
||||||
Export qw( BASE_CFLAGS TARGET_DIR INSTALL_DIR NO_VM NO_SO CC CXX LINK );
|
Export qw( BASE_CFLAGS TARGET_DIR INSTALL_DIR NO_VM NO_SO CC CXX LINK );
|
||||||
Build $BUILD_DIR . '/game/Conscript';
|
Build $BUILD_DIR . '/game/Conscript';
|
||||||
|
|
||||||
$BUILD_DIR = $CONFIG_DIR . '/' . $TARGET_DIR . '/ui';
|
$BUILD_DIR = $CONFIG_DIR . '/' . $TARGET_DIR . '/ui';
|
||||||
Link $BUILD_DIR => '.';
|
Link $BUILD_DIR => '.';
|
||||||
Export qw( BASE_CFLAGS TARGET_DIR INSTALL_DIR NO_VM NO_SO CC CXX LINK );
|
Export qw( BASE_CFLAGS TARGET_DIR INSTALL_DIR NO_VM NO_SO CC CXX LINK );
|
||||||
Build $BUILD_DIR . '/ui/Conscript';
|
Build $BUILD_DIR . '/ui/Conscript';
|
||||||
|
|
||||||
# core
|
# core
|
||||||
if ($no_core eq 1)
|
if ($no_core eq 1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$INSTALL_DIR = $INSTALL_BASEDIR;
|
$INSTALL_DIR = $INSTALL_BASEDIR;
|
||||||
$BUILD_DIR = $CONFIG_DIR . '/core/dedicated';
|
$BUILD_DIR = $CONFIG_DIR . '/core/dedicated';
|
||||||
Link $BUILD_DIR => '.';
|
Link $BUILD_DIR => '.';
|
||||||
$hack = $BASE_CFLAGS; # hit me!
|
$hack = $BASE_CFLAGS; # hit me!
|
||||||
$BASE_CFLAGS .= '-DDEDICATED ';
|
$BASE_CFLAGS .= '-DDEDICATED ';
|
||||||
Export qw( BASE_CFLAGS BUILD_DIR INSTALL_DIR CC CXX LINK );
|
Export qw( BASE_CFLAGS BUILD_DIR INSTALL_DIR CC CXX LINK );
|
||||||
Build $BUILD_DIR . '/unix/Conscript-dedicated';
|
Build $BUILD_DIR . '/unix/Conscript-dedicated';
|
||||||
$BASE_CFLAGS = $hack;
|
$BASE_CFLAGS = $hack;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$TARGETNAME = 'linuxquake3';
|
$TARGETNAME = 'linuxquake3';
|
||||||
$BUILD_DIR = $CONFIG_DIR . '/core/client';
|
$BUILD_DIR = $CONFIG_DIR . '/core/client';
|
||||||
$BASE_LDFLAGS = '';
|
$BASE_LDFLAGS = '';
|
||||||
|
|
||||||
Link $BUILD_DIR => '.';
|
Link $BUILD_DIR => '.';
|
||||||
Export qw( BASE_CFLAGS BASE_LDFLAGS BUILD_DIR INSTALL_DIR TARGETNAME CC CXX LINK );
|
Export qw( BASE_CFLAGS BASE_LDFLAGS BUILD_DIR INSTALL_DIR TARGETNAME CC CXX LINK );
|
||||||
Build $BUILD_DIR . '/unix/Conscript-client';
|
Build $BUILD_DIR . '/unix/Conscript-client';
|
||||||
|
|
||||||
if ($do_smp eq 1)
|
if ($do_smp eq 1)
|
||||||
{
|
{
|
||||||
$TARGETNAME = 'linuxquake3-smp';
|
$TARGETNAME = 'linuxquake3-smp';
|
||||||
$BUILD_DIR = $CONFIG_DIR . '/core/client-smp';
|
$BUILD_DIR = $CONFIG_DIR . '/core/client-smp';
|
||||||
$BASE_CFLAGS .= '-DSMP ';
|
$BASE_CFLAGS .= '-DSMP ';
|
||||||
$BASE_LDFLAGS = '-lpthread ';
|
$BASE_LDFLAGS = '-lpthread ';
|
||||||
|
|
||||||
Link $BUILD_DIR => '.';
|
Link $BUILD_DIR => '.';
|
||||||
Export qw( BASE_CFLAGS BASE_LDFLAGS BUILD_DIR INSTALL_DIR TARGETNAME CC CXX LINK );
|
Export qw( BASE_CFLAGS BASE_LDFLAGS BUILD_DIR INSTALL_DIR TARGETNAME CC CXX LINK );
|
||||||
Build $BUILD_DIR . '/unix/Conscript-client';
|
Build $BUILD_DIR . '/unix/Conscript-client';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($NO_VM eq 0 && $do_pk3 eq 1)
|
if ($NO_VM eq 0 && $do_pk3 eq 1)
|
||||||
{
|
{
|
||||||
# build the PK3s
|
# build the PK3s
|
||||||
$INSTALL_DIR = $INSTALL_BASEDIR;
|
$INSTALL_DIR = $INSTALL_BASEDIR;
|
||||||
$BUILD_DIR = $CONFIG_DIR . '/pk3-builder';
|
$BUILD_DIR = $CONFIG_DIR . '/pk3-builder';
|
||||||
Link $BUILD_DIR => 'unix';
|
Link $BUILD_DIR => 'unix';
|
||||||
Export qw( INSTALL_DIR BUILD_DIR CONFIG_DIR CC CXX LINK );
|
Export qw( INSTALL_DIR BUILD_DIR CONFIG_DIR CC CXX LINK );
|
||||||
Build $BUILD_DIR . '/Conscript-pk3';
|
Build $BUILD_DIR . '/Conscript-pk3';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($do_setup eq 1)
|
if ($do_setup eq 1)
|
||||||
{
|
{
|
||||||
Link $CONFIG_DIR => '.';
|
Link $CONFIG_DIR => '.';
|
||||||
Export qw( INSTALL_BASEDIR );
|
Export qw( INSTALL_BASEDIR );
|
||||||
Build $CONFIG_DIR . '/unix/Conscript-setup';
|
Build $CONFIG_DIR . '/unix/Conscript-setup';
|
||||||
}
|
}
|
||||||
|
|
||||||
Help
|
Help
|
||||||
"
|
"
|
||||||
Usage: cons [-h] [ -- [release|debug] [novm] [noso] [nosmp] [master_server=<adr>] [auth_server=<adr>] [auth_port=<port>] [pk3] [bspc] [setup] [sdk]]
|
Usage: cons [-h] [ -- [release|debug] [novm] [noso] [nosmp] [master_server=<adr>] [auth_server=<adr>] [auth_port=<port>] [pk3] [bspc] [setup] [sdk]]
|
||||||
Default build type is Debug, specifying '-- release' on the
|
Default build type is Debug, specifying '-- release' on the
|
||||||
command line builds a Release version (NOTE that this option
|
command line builds a Release version (NOTE that this option
|
||||||
only affects the native libraries).
|
only affects the native libraries).
|
||||||
|
|
||||||
novm: will not build the VMs
|
novm: will not build the VMs
|
||||||
noso: will not build the so
|
noso: will not build the so
|
||||||
|
|
||||||
below are for core builds only:
|
below are for core builds only:
|
||||||
|
|
||||||
nosmp : do not build the SMP-enabled version of the renderer
|
nosmp : do not build the SMP-enabled version of the renderer
|
||||||
pk3 : generate the pk3s on the fly (defined in unix/Conscript-pk3)
|
pk3 : generate the pk3s on the fly (defined in unix/Conscript-pk3)
|
||||||
bspc : build bspc
|
bspc : build bspc
|
||||||
setup : build setup
|
setup : build setup
|
||||||
sdk : build the mod sdk
|
sdk : build the mod sdk
|
||||||
"
|
"
|
||||||
;
|
;
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
# nasty ugly to get build system working from Anjuta
|
# nasty ugly to get build system working from Anjuta
|
||||||
all:
|
all:
|
||||||
if [ `hostname` == sparkle ] ; then ./unix/pcons-2.3.1 -j4 -- novm noso ; else ./unix/cons ; fi
|
if [ `hostname` == sparkle ] ; then ./unix/pcons-2.3.1 -j4 -- novm noso ; else ./unix/cons ; fi
|
||||||
|
|
|
||||||
|
|
@ -1,267 +1,267 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
//NOTE: int = default signed
|
//NOTE: int = default signed
|
||||||
// default long
|
// default long
|
||||||
|
|
||||||
#define AASID (('S'<<24)+('A'<<16)+('A'<<8)+'E')
|
#define AASID (('S'<<24)+('A'<<16)+('A'<<8)+'E')
|
||||||
#define AASVERSION_OLD 4
|
#define AASVERSION_OLD 4
|
||||||
#define AASVERSION 5
|
#define AASVERSION 5
|
||||||
|
|
||||||
//presence types
|
//presence types
|
||||||
#define PRESENCE_NONE 1
|
#define PRESENCE_NONE 1
|
||||||
#define PRESENCE_NORMAL 2
|
#define PRESENCE_NORMAL 2
|
||||||
#define PRESENCE_CROUCH 4
|
#define PRESENCE_CROUCH 4
|
||||||
|
|
||||||
//travel types
|
//travel types
|
||||||
#define MAX_TRAVELTYPES 32
|
#define MAX_TRAVELTYPES 32
|
||||||
#define TRAVEL_INVALID 1 //temporary not possible
|
#define TRAVEL_INVALID 1 //temporary not possible
|
||||||
#define TRAVEL_WALK 2 //walking
|
#define TRAVEL_WALK 2 //walking
|
||||||
#define TRAVEL_CROUCH 3 //crouching
|
#define TRAVEL_CROUCH 3 //crouching
|
||||||
#define TRAVEL_BARRIERJUMP 4 //jumping onto a barrier
|
#define TRAVEL_BARRIERJUMP 4 //jumping onto a barrier
|
||||||
#define TRAVEL_JUMP 5 //jumping
|
#define TRAVEL_JUMP 5 //jumping
|
||||||
#define TRAVEL_LADDER 6 //climbing a ladder
|
#define TRAVEL_LADDER 6 //climbing a ladder
|
||||||
#define TRAVEL_WALKOFFLEDGE 7 //walking of a ledge
|
#define TRAVEL_WALKOFFLEDGE 7 //walking of a ledge
|
||||||
#define TRAVEL_SWIM 8 //swimming
|
#define TRAVEL_SWIM 8 //swimming
|
||||||
#define TRAVEL_WATERJUMP 9 //jump out of the water
|
#define TRAVEL_WATERJUMP 9 //jump out of the water
|
||||||
#define TRAVEL_TELEPORT 10 //teleportation
|
#define TRAVEL_TELEPORT 10 //teleportation
|
||||||
#define TRAVEL_ELEVATOR 11 //travel by elevator
|
#define TRAVEL_ELEVATOR 11 //travel by elevator
|
||||||
#define TRAVEL_ROCKETJUMP 12 //rocket jumping required for travel
|
#define TRAVEL_ROCKETJUMP 12 //rocket jumping required for travel
|
||||||
#define TRAVEL_BFGJUMP 13 //bfg jumping required for travel
|
#define TRAVEL_BFGJUMP 13 //bfg jumping required for travel
|
||||||
#define TRAVEL_GRAPPLEHOOK 14 //grappling hook required for travel
|
#define TRAVEL_GRAPPLEHOOK 14 //grappling hook required for travel
|
||||||
#define TRAVEL_DOUBLEJUMP 15 //double jump
|
#define TRAVEL_DOUBLEJUMP 15 //double jump
|
||||||
#define TRAVEL_RAMPJUMP 16 //ramp jump
|
#define TRAVEL_RAMPJUMP 16 //ramp jump
|
||||||
#define TRAVEL_STRAFEJUMP 17 //strafe jump
|
#define TRAVEL_STRAFEJUMP 17 //strafe jump
|
||||||
#define TRAVEL_JUMPPAD 18 //jump pad
|
#define TRAVEL_JUMPPAD 18 //jump pad
|
||||||
#define TRAVEL_FUNCBOB 19 //func bob
|
#define TRAVEL_FUNCBOB 19 //func bob
|
||||||
|
|
||||||
//additional travel flags
|
//additional travel flags
|
||||||
#define TRAVELTYPE_MASK 0xFFFFFF
|
#define TRAVELTYPE_MASK 0xFFFFFF
|
||||||
#define TRAVELFLAG_NOTTEAM1 (1 << 24)
|
#define TRAVELFLAG_NOTTEAM1 (1 << 24)
|
||||||
#define TRAVELFLAG_NOTTEAM2 (2 << 24)
|
#define TRAVELFLAG_NOTTEAM2 (2 << 24)
|
||||||
|
|
||||||
//face flags
|
//face flags
|
||||||
#define FACE_SOLID 1 //just solid at the other side
|
#define FACE_SOLID 1 //just solid at the other side
|
||||||
#define FACE_LADDER 2 //ladder
|
#define FACE_LADDER 2 //ladder
|
||||||
#define FACE_GROUND 4 //standing on ground when in this face
|
#define FACE_GROUND 4 //standing on ground when in this face
|
||||||
#define FACE_GAP 8 //gap in the ground
|
#define FACE_GAP 8 //gap in the ground
|
||||||
#define FACE_LIQUID 16 //face seperating two areas with liquid
|
#define FACE_LIQUID 16 //face seperating two areas with liquid
|
||||||
#define FACE_LIQUIDSURFACE 32 //face seperating liquid and air
|
#define FACE_LIQUIDSURFACE 32 //face seperating liquid and air
|
||||||
#define FACE_BRIDGE 64 //can walk over this face if bridge is closed
|
#define FACE_BRIDGE 64 //can walk over this face if bridge is closed
|
||||||
|
|
||||||
//area contents
|
//area contents
|
||||||
#define AREACONTENTS_WATER 1
|
#define AREACONTENTS_WATER 1
|
||||||
#define AREACONTENTS_LAVA 2
|
#define AREACONTENTS_LAVA 2
|
||||||
#define AREACONTENTS_SLIME 4
|
#define AREACONTENTS_SLIME 4
|
||||||
#define AREACONTENTS_CLUSTERPORTAL 8
|
#define AREACONTENTS_CLUSTERPORTAL 8
|
||||||
#define AREACONTENTS_TELEPORTAL 16
|
#define AREACONTENTS_TELEPORTAL 16
|
||||||
#define AREACONTENTS_ROUTEPORTAL 32
|
#define AREACONTENTS_ROUTEPORTAL 32
|
||||||
#define AREACONTENTS_TELEPORTER 64
|
#define AREACONTENTS_TELEPORTER 64
|
||||||
#define AREACONTENTS_JUMPPAD 128
|
#define AREACONTENTS_JUMPPAD 128
|
||||||
#define AREACONTENTS_DONOTENTER 256
|
#define AREACONTENTS_DONOTENTER 256
|
||||||
#define AREACONTENTS_VIEWPORTAL 512
|
#define AREACONTENTS_VIEWPORTAL 512
|
||||||
#define AREACONTENTS_MOVER 1024
|
#define AREACONTENTS_MOVER 1024
|
||||||
#define AREACONTENTS_NOTTEAM1 2048
|
#define AREACONTENTS_NOTTEAM1 2048
|
||||||
#define AREACONTENTS_NOTTEAM2 4096
|
#define AREACONTENTS_NOTTEAM2 4096
|
||||||
//number of model of the mover inside this area
|
//number of model of the mover inside this area
|
||||||
#define AREACONTENTS_MODELNUMSHIFT 24
|
#define AREACONTENTS_MODELNUMSHIFT 24
|
||||||
#define AREACONTENTS_MAXMODELNUM 0xFF
|
#define AREACONTENTS_MAXMODELNUM 0xFF
|
||||||
#define AREACONTENTS_MODELNUM (AREACONTENTS_MAXMODELNUM << AREACONTENTS_MODELNUMSHIFT)
|
#define AREACONTENTS_MODELNUM (AREACONTENTS_MAXMODELNUM << AREACONTENTS_MODELNUMSHIFT)
|
||||||
|
|
||||||
//area flags
|
//area flags
|
||||||
#define AREA_GROUNDED 1 //bot can stand on the ground
|
#define AREA_GROUNDED 1 //bot can stand on the ground
|
||||||
#define AREA_LADDER 2 //area contains one or more ladder faces
|
#define AREA_LADDER 2 //area contains one or more ladder faces
|
||||||
#define AREA_LIQUID 4 //area contains a liquid
|
#define AREA_LIQUID 4 //area contains a liquid
|
||||||
#define AREA_DISABLED 8 //area is disabled for routing when set
|
#define AREA_DISABLED 8 //area is disabled for routing when set
|
||||||
#define AREA_BRIDGE 16 //area ontop of a bridge
|
#define AREA_BRIDGE 16 //area ontop of a bridge
|
||||||
|
|
||||||
//aas file header lumps
|
//aas file header lumps
|
||||||
#define AAS_LUMPS 14
|
#define AAS_LUMPS 14
|
||||||
#define AASLUMP_BBOXES 0
|
#define AASLUMP_BBOXES 0
|
||||||
#define AASLUMP_VERTEXES 1
|
#define AASLUMP_VERTEXES 1
|
||||||
#define AASLUMP_PLANES 2
|
#define AASLUMP_PLANES 2
|
||||||
#define AASLUMP_EDGES 3
|
#define AASLUMP_EDGES 3
|
||||||
#define AASLUMP_EDGEINDEX 4
|
#define AASLUMP_EDGEINDEX 4
|
||||||
#define AASLUMP_FACES 5
|
#define AASLUMP_FACES 5
|
||||||
#define AASLUMP_FACEINDEX 6
|
#define AASLUMP_FACEINDEX 6
|
||||||
#define AASLUMP_AREAS 7
|
#define AASLUMP_AREAS 7
|
||||||
#define AASLUMP_AREASETTINGS 8
|
#define AASLUMP_AREASETTINGS 8
|
||||||
#define AASLUMP_REACHABILITY 9
|
#define AASLUMP_REACHABILITY 9
|
||||||
#define AASLUMP_NODES 10
|
#define AASLUMP_NODES 10
|
||||||
#define AASLUMP_PORTALS 11
|
#define AASLUMP_PORTALS 11
|
||||||
#define AASLUMP_PORTALINDEX 12
|
#define AASLUMP_PORTALINDEX 12
|
||||||
#define AASLUMP_CLUSTERS 13
|
#define AASLUMP_CLUSTERS 13
|
||||||
|
|
||||||
//========== bounding box =========
|
//========== bounding box =========
|
||||||
|
|
||||||
//bounding box
|
//bounding box
|
||||||
typedef struct aas_bbox_s
|
typedef struct aas_bbox_s
|
||||||
{
|
{
|
||||||
int presencetype;
|
int presencetype;
|
||||||
int flags;
|
int flags;
|
||||||
vec3_t mins, maxs;
|
vec3_t mins, maxs;
|
||||||
} aas_bbox_t;
|
} aas_bbox_t;
|
||||||
|
|
||||||
//============ settings ===========
|
//============ settings ===========
|
||||||
|
|
||||||
//reachability to another area
|
//reachability to another area
|
||||||
typedef struct aas_reachability_s
|
typedef struct aas_reachability_s
|
||||||
{
|
{
|
||||||
int areanum; //number of the reachable area
|
int areanum; //number of the reachable area
|
||||||
int facenum; //number of the face towards the other area
|
int facenum; //number of the face towards the other area
|
||||||
int edgenum; //number of the edge towards the other area
|
int edgenum; //number of the edge towards the other area
|
||||||
vec3_t start; //start point of inter area movement
|
vec3_t start; //start point of inter area movement
|
||||||
vec3_t end; //end point of inter area movement
|
vec3_t end; //end point of inter area movement
|
||||||
int traveltype; //type of travel required to get to the area
|
int traveltype; //type of travel required to get to the area
|
||||||
unsigned short int traveltime;//travel time of the inter area movement
|
unsigned short int traveltime;//travel time of the inter area movement
|
||||||
} aas_reachability_t;
|
} aas_reachability_t;
|
||||||
|
|
||||||
//area settings
|
//area settings
|
||||||
typedef struct aas_areasettings_s
|
typedef struct aas_areasettings_s
|
||||||
{
|
{
|
||||||
//could also add all kind of statistic fields
|
//could also add all kind of statistic fields
|
||||||
int contents; //contents of the area
|
int contents; //contents of the area
|
||||||
int areaflags; //several area flags
|
int areaflags; //several area flags
|
||||||
int presencetype; //how a bot can be present in this area
|
int presencetype; //how a bot can be present in this area
|
||||||
int cluster; //cluster the area belongs to, if negative it's a portal
|
int cluster; //cluster the area belongs to, if negative it's a portal
|
||||||
int clusterareanum; //number of the area in the cluster
|
int clusterareanum; //number of the area in the cluster
|
||||||
int numreachableareas; //number of reachable areas from this one
|
int numreachableareas; //number of reachable areas from this one
|
||||||
int firstreachablearea; //first reachable area in the reachable area index
|
int firstreachablearea; //first reachable area in the reachable area index
|
||||||
} aas_areasettings_t;
|
} aas_areasettings_t;
|
||||||
|
|
||||||
//cluster portal
|
//cluster portal
|
||||||
typedef struct aas_portal_s
|
typedef struct aas_portal_s
|
||||||
{
|
{
|
||||||
int areanum; //area that is the actual portal
|
int areanum; //area that is the actual portal
|
||||||
int frontcluster; //cluster at front of portal
|
int frontcluster; //cluster at front of portal
|
||||||
int backcluster; //cluster at back of portal
|
int backcluster; //cluster at back of portal
|
||||||
int clusterareanum[2]; //number of the area in the front and back cluster
|
int clusterareanum[2]; //number of the area in the front and back cluster
|
||||||
} aas_portal_t;
|
} aas_portal_t;
|
||||||
|
|
||||||
//cluster portal index
|
//cluster portal index
|
||||||
typedef int aas_portalindex_t;
|
typedef int aas_portalindex_t;
|
||||||
|
|
||||||
//cluster
|
//cluster
|
||||||
typedef struct aas_cluster_s
|
typedef struct aas_cluster_s
|
||||||
{
|
{
|
||||||
int numareas; //number of areas in the cluster
|
int numareas; //number of areas in the cluster
|
||||||
int numreachabilityareas; //number of areas with reachabilities
|
int numreachabilityareas; //number of areas with reachabilities
|
||||||
int numportals; //number of cluster portals
|
int numportals; //number of cluster portals
|
||||||
int firstportal; //first cluster portal in the index
|
int firstportal; //first cluster portal in the index
|
||||||
} aas_cluster_t;
|
} aas_cluster_t;
|
||||||
|
|
||||||
//============ 3d definition ============
|
//============ 3d definition ============
|
||||||
|
|
||||||
typedef vec3_t aas_vertex_t;
|
typedef vec3_t aas_vertex_t;
|
||||||
|
|
||||||
//just a plane in the third dimension
|
//just a plane in the third dimension
|
||||||
typedef struct aas_plane_s
|
typedef struct aas_plane_s
|
||||||
{
|
{
|
||||||
vec3_t normal; //normal vector of the plane
|
vec3_t normal; //normal vector of the plane
|
||||||
float dist; //distance of the plane (normal vector * distance = point in plane)
|
float dist; //distance of the plane (normal vector * distance = point in plane)
|
||||||
int type;
|
int type;
|
||||||
} aas_plane_t;
|
} aas_plane_t;
|
||||||
|
|
||||||
//edge
|
//edge
|
||||||
typedef struct aas_edge_s
|
typedef struct aas_edge_s
|
||||||
{
|
{
|
||||||
int v[2]; //numbers of the vertexes of this edge
|
int v[2]; //numbers of the vertexes of this edge
|
||||||
} aas_edge_t;
|
} aas_edge_t;
|
||||||
|
|
||||||
//edge index, negative if vertexes are reversed
|
//edge index, negative if vertexes are reversed
|
||||||
typedef int aas_edgeindex_t;
|
typedef int aas_edgeindex_t;
|
||||||
|
|
||||||
//a face bounds an area, often it will also seperate two areas
|
//a face bounds an area, often it will also seperate two areas
|
||||||
typedef struct aas_face_s
|
typedef struct aas_face_s
|
||||||
{
|
{
|
||||||
int planenum; //number of the plane this face is in
|
int planenum; //number of the plane this face is in
|
||||||
int faceflags; //face flags (no use to create face settings for just this field)
|
int faceflags; //face flags (no use to create face settings for just this field)
|
||||||
int numedges; //number of edges in the boundary of the face
|
int numedges; //number of edges in the boundary of the face
|
||||||
int firstedge; //first edge in the edge index
|
int firstedge; //first edge in the edge index
|
||||||
int frontarea; //area at the front of this face
|
int frontarea; //area at the front of this face
|
||||||
int backarea; //area at the back of this face
|
int backarea; //area at the back of this face
|
||||||
} aas_face_t;
|
} aas_face_t;
|
||||||
|
|
||||||
//face index, stores a negative index if backside of face
|
//face index, stores a negative index if backside of face
|
||||||
typedef int aas_faceindex_t;
|
typedef int aas_faceindex_t;
|
||||||
|
|
||||||
//area with a boundary of faces
|
//area with a boundary of faces
|
||||||
typedef struct aas_area_s
|
typedef struct aas_area_s
|
||||||
{
|
{
|
||||||
int areanum; //number of this area
|
int areanum; //number of this area
|
||||||
//3d definition
|
//3d definition
|
||||||
int numfaces; //number of faces used for the boundary of the area
|
int numfaces; //number of faces used for the boundary of the area
|
||||||
int firstface; //first face in the face index used for the boundary of the area
|
int firstface; //first face in the face index used for the boundary of the area
|
||||||
vec3_t mins; //mins of the area
|
vec3_t mins; //mins of the area
|
||||||
vec3_t maxs; //maxs of the area
|
vec3_t maxs; //maxs of the area
|
||||||
vec3_t center; //'center' of the area
|
vec3_t center; //'center' of the area
|
||||||
} aas_area_t;
|
} aas_area_t;
|
||||||
|
|
||||||
//nodes of the bsp tree
|
//nodes of the bsp tree
|
||||||
typedef struct aas_node_s
|
typedef struct aas_node_s
|
||||||
{
|
{
|
||||||
int planenum;
|
int planenum;
|
||||||
int children[2]; //child nodes of this node, or areas as leaves when negative
|
int children[2]; //child nodes of this node, or areas as leaves when negative
|
||||||
//when a child is zero it's a solid leaf
|
//when a child is zero it's a solid leaf
|
||||||
} aas_node_t;
|
} aas_node_t;
|
||||||
|
|
||||||
//=========== aas file ===============
|
//=========== aas file ===============
|
||||||
|
|
||||||
//header lump
|
//header lump
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int fileofs;
|
int fileofs;
|
||||||
int filelen;
|
int filelen;
|
||||||
} aas_lump_t;
|
} aas_lump_t;
|
||||||
|
|
||||||
//aas file header
|
//aas file header
|
||||||
typedef struct aas_header_s
|
typedef struct aas_header_s
|
||||||
{
|
{
|
||||||
int ident;
|
int ident;
|
||||||
int version;
|
int version;
|
||||||
int bspchecksum;
|
int bspchecksum;
|
||||||
//data entries
|
//data entries
|
||||||
aas_lump_t lumps[AAS_LUMPS];
|
aas_lump_t lumps[AAS_LUMPS];
|
||||||
} aas_header_t;
|
} aas_header_t;
|
||||||
|
|
||||||
|
|
||||||
//====== additional information ======
|
//====== additional information ======
|
||||||
/*
|
/*
|
||||||
|
|
||||||
- when a node child is a solid leaf the node child number is zero
|
- when a node child is a solid leaf the node child number is zero
|
||||||
- two adjacent areas (sharing a plane at opposite sides) share a face
|
- two adjacent areas (sharing a plane at opposite sides) share a face
|
||||||
this face is a portal between the areas
|
this face is a portal between the areas
|
||||||
- when an area uses a face from the faceindex with a positive index
|
- when an area uses a face from the faceindex with a positive index
|
||||||
then the face plane normal points into the area
|
then the face plane normal points into the area
|
||||||
- the face edges are stored counter clockwise using the edgeindex
|
- the face edges are stored counter clockwise using the edgeindex
|
||||||
- two adjacent convex areas (sharing a face) only share One face
|
- two adjacent convex areas (sharing a face) only share One face
|
||||||
this is a simple result of the areas being convex
|
this is a simple result of the areas being convex
|
||||||
- the areas can't have a mixture of ground and gap faces
|
- the areas can't have a mixture of ground and gap faces
|
||||||
other mixtures of faces in one area are allowed
|
other mixtures of faces in one area are allowed
|
||||||
- areas with the AREACONTENTS_CLUSTERPORTAL in the settings have
|
- areas with the AREACONTENTS_CLUSTERPORTAL in the settings have
|
||||||
the cluster number set to the negative portal number
|
the cluster number set to the negative portal number
|
||||||
- edge zero is a dummy
|
- edge zero is a dummy
|
||||||
- face zero is a dummy
|
- face zero is a dummy
|
||||||
- area zero is a dummy
|
- area zero is a dummy
|
||||||
- node zero is a dummy
|
- node zero is a dummy
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1,89 +1,89 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: be_aas_bsp.h
|
* name: be_aas_bsp.h
|
||||||
*
|
*
|
||||||
* desc: AAS
|
* desc: AAS
|
||||||
*
|
*
|
||||||
* $Archive: /source/code/botlib/be_aas_bsp.h $
|
* $Archive: /source/code/botlib/be_aas_bsp.h $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#ifdef AASINTERN
|
#ifdef AASINTERN
|
||||||
//loads the given BSP file
|
//loads the given BSP file
|
||||||
int AAS_LoadBSPFile(void);
|
int AAS_LoadBSPFile(void);
|
||||||
//dump the loaded BSP data
|
//dump the loaded BSP data
|
||||||
void AAS_DumpBSPData(void);
|
void AAS_DumpBSPData(void);
|
||||||
//unlink the given entity from the bsp tree leaves
|
//unlink the given entity from the bsp tree leaves
|
||||||
void AAS_UnlinkFromBSPLeaves(bsp_link_t *leaves);
|
void AAS_UnlinkFromBSPLeaves(bsp_link_t *leaves);
|
||||||
//link the given entity to the bsp tree leaves of the given model
|
//link the given entity to the bsp tree leaves of the given model
|
||||||
bsp_link_t *AAS_BSPLinkEntity(vec3_t absmins,
|
bsp_link_t *AAS_BSPLinkEntity(vec3_t absmins,
|
||||||
vec3_t absmaxs,
|
vec3_t absmaxs,
|
||||||
int entnum,
|
int entnum,
|
||||||
int modelnum);
|
int modelnum);
|
||||||
|
|
||||||
//calculates collision with given entity
|
//calculates collision with given entity
|
||||||
qboolean AAS_EntityCollision(int entnum,
|
qboolean AAS_EntityCollision(int entnum,
|
||||||
vec3_t start,
|
vec3_t start,
|
||||||
vec3_t boxmins,
|
vec3_t boxmins,
|
||||||
vec3_t boxmaxs,
|
vec3_t boxmaxs,
|
||||||
vec3_t end,
|
vec3_t end,
|
||||||
int contentmask,
|
int contentmask,
|
||||||
bsp_trace_t *trace);
|
bsp_trace_t *trace);
|
||||||
//for debugging
|
//for debugging
|
||||||
void AAS_PrintFreeBSPLinks(char *str);
|
void AAS_PrintFreeBSPLinks(char *str);
|
||||||
//
|
//
|
||||||
#endif //AASINTERN
|
#endif //AASINTERN
|
||||||
|
|
||||||
#define MAX_EPAIRKEY 128
|
#define MAX_EPAIRKEY 128
|
||||||
|
|
||||||
//trace through the world
|
//trace through the world
|
||||||
bsp_trace_t AAS_Trace( vec3_t start,
|
bsp_trace_t AAS_Trace( vec3_t start,
|
||||||
vec3_t mins,
|
vec3_t mins,
|
||||||
vec3_t maxs,
|
vec3_t maxs,
|
||||||
vec3_t end,
|
vec3_t end,
|
||||||
int passent,
|
int passent,
|
||||||
int contentmask);
|
int contentmask);
|
||||||
//returns the contents at the given point
|
//returns the contents at the given point
|
||||||
int AAS_PointContents(vec3_t point);
|
int AAS_PointContents(vec3_t point);
|
||||||
//returns true when p2 is in the PVS of p1
|
//returns true when p2 is in the PVS of p1
|
||||||
qboolean AAS_inPVS(vec3_t p1, vec3_t p2);
|
qboolean AAS_inPVS(vec3_t p1, vec3_t p2);
|
||||||
//returns true when p2 is in the PHS of p1
|
//returns true when p2 is in the PHS of p1
|
||||||
qboolean AAS_inPHS(vec3_t p1, vec3_t p2);
|
qboolean AAS_inPHS(vec3_t p1, vec3_t p2);
|
||||||
//returns true if the given areas are connected
|
//returns true if the given areas are connected
|
||||||
qboolean AAS_AreasConnected(int area1, int area2);
|
qboolean AAS_AreasConnected(int area1, int area2);
|
||||||
//creates a list with entities totally or partly within the given box
|
//creates a list with entities totally or partly within the given box
|
||||||
int AAS_BoxEntities(vec3_t absmins, vec3_t absmaxs, int *list, int maxcount);
|
int AAS_BoxEntities(vec3_t absmins, vec3_t absmaxs, int *list, int maxcount);
|
||||||
//gets the mins, maxs and origin of a BSP model
|
//gets the mins, maxs and origin of a BSP model
|
||||||
void AAS_BSPModelMinsMaxsOrigin(int modelnum, vec3_t angles, vec3_t mins, vec3_t maxs, vec3_t origin);
|
void AAS_BSPModelMinsMaxsOrigin(int modelnum, vec3_t angles, vec3_t mins, vec3_t maxs, vec3_t origin);
|
||||||
//handle to the next bsp entity
|
//handle to the next bsp entity
|
||||||
int AAS_NextBSPEntity(int ent);
|
int AAS_NextBSPEntity(int ent);
|
||||||
//return the value of the BSP epair key
|
//return the value of the BSP epair key
|
||||||
int AAS_ValueForBSPEpairKey(int ent, char *key, char *value, int size);
|
int AAS_ValueForBSPEpairKey(int ent, char *key, char *value, int size);
|
||||||
//get a vector for the BSP epair key
|
//get a vector for the BSP epair key
|
||||||
int AAS_VectorForBSPEpairKey(int ent, char *key, vec3_t v);
|
int AAS_VectorForBSPEpairKey(int ent, char *key, vec3_t v);
|
||||||
//get a float for the BSP epair key
|
//get a float for the BSP epair key
|
||||||
int AAS_FloatForBSPEpairKey(int ent, char *key, float *value);
|
int AAS_FloatForBSPEpairKey(int ent, char *key, float *value);
|
||||||
//get an integer for the BSP epair key
|
//get an integer for the BSP epair key
|
||||||
int AAS_IntForBSPEpairKey(int ent, char *key, int *value);
|
int AAS_IntForBSPEpairKey(int ent, char *key, int *value);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,487 +1,487 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: be_aas_bspq3.c
|
* name: be_aas_bspq3.c
|
||||||
*
|
*
|
||||||
* desc: BSP, Environment Sampling
|
* desc: BSP, Environment Sampling
|
||||||
*
|
*
|
||||||
* $Archive: /MissionPack/code/botlib/be_aas_bspq3.c $
|
* $Archive: /MissionPack/code/botlib/be_aas_bspq3.c $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "../game/q_shared.h"
|
#include "../game/q_shared.h"
|
||||||
#include "l_memory.h"
|
#include "l_memory.h"
|
||||||
#include "l_script.h"
|
#include "l_script.h"
|
||||||
#include "l_precomp.h"
|
#include "l_precomp.h"
|
||||||
#include "l_struct.h"
|
#include "l_struct.h"
|
||||||
#include "aasfile.h"
|
#include "aasfile.h"
|
||||||
#include "../game/botlib.h"
|
#include "../game/botlib.h"
|
||||||
#include "../game/be_aas.h"
|
#include "../game/be_aas.h"
|
||||||
#include "be_aas_funcs.h"
|
#include "be_aas_funcs.h"
|
||||||
#include "be_aas_def.h"
|
#include "be_aas_def.h"
|
||||||
|
|
||||||
extern botlib_import_t botimport;
|
extern botlib_import_t botimport;
|
||||||
|
|
||||||
//#define TRACE_DEBUG
|
//#define TRACE_DEBUG
|
||||||
|
|
||||||
#define ON_EPSILON 0.005
|
#define ON_EPSILON 0.005
|
||||||
//#define DEG2RAD( a ) (( a * M_PI ) / 180.0F)
|
//#define DEG2RAD( a ) (( a * M_PI ) / 180.0F)
|
||||||
|
|
||||||
#define MAX_BSPENTITIES 2048
|
#define MAX_BSPENTITIES 2048
|
||||||
|
|
||||||
typedef struct rgb_s
|
typedef struct rgb_s
|
||||||
{
|
{
|
||||||
int red;
|
int red;
|
||||||
int green;
|
int green;
|
||||||
int blue;
|
int blue;
|
||||||
} rgb_t;
|
} rgb_t;
|
||||||
|
|
||||||
//bsp entity epair
|
//bsp entity epair
|
||||||
typedef struct bsp_epair_s
|
typedef struct bsp_epair_s
|
||||||
{
|
{
|
||||||
char *key;
|
char *key;
|
||||||
char *value;
|
char *value;
|
||||||
struct bsp_epair_s *next;
|
struct bsp_epair_s *next;
|
||||||
} bsp_epair_t;
|
} bsp_epair_t;
|
||||||
|
|
||||||
//bsp data entity
|
//bsp data entity
|
||||||
typedef struct bsp_entity_s
|
typedef struct bsp_entity_s
|
||||||
{
|
{
|
||||||
bsp_epair_t *epairs;
|
bsp_epair_t *epairs;
|
||||||
} bsp_entity_t;
|
} bsp_entity_t;
|
||||||
|
|
||||||
//id Sofware BSP data
|
//id Sofware BSP data
|
||||||
typedef struct bsp_s
|
typedef struct bsp_s
|
||||||
{
|
{
|
||||||
//true when bsp file is loaded
|
//true when bsp file is loaded
|
||||||
int loaded;
|
int loaded;
|
||||||
//entity data
|
//entity data
|
||||||
int entdatasize;
|
int entdatasize;
|
||||||
char *dentdata;
|
char *dentdata;
|
||||||
//bsp entities
|
//bsp entities
|
||||||
int numentities;
|
int numentities;
|
||||||
bsp_entity_t entities[MAX_BSPENTITIES];
|
bsp_entity_t entities[MAX_BSPENTITIES];
|
||||||
} bsp_t;
|
} bsp_t;
|
||||||
|
|
||||||
//global bsp
|
//global bsp
|
||||||
bsp_t bspworld;
|
bsp_t bspworld;
|
||||||
|
|
||||||
|
|
||||||
#ifdef BSP_DEBUG
|
#ifdef BSP_DEBUG
|
||||||
typedef struct cname_s
|
typedef struct cname_s
|
||||||
{
|
{
|
||||||
int value;
|
int value;
|
||||||
char *name;
|
char *name;
|
||||||
} cname_t;
|
} cname_t;
|
||||||
|
|
||||||
cname_t contentnames[] =
|
cname_t contentnames[] =
|
||||||
{
|
{
|
||||||
{CONTENTS_SOLID,"CONTENTS_SOLID"},
|
{CONTENTS_SOLID,"CONTENTS_SOLID"},
|
||||||
{CONTENTS_WINDOW,"CONTENTS_WINDOW"},
|
{CONTENTS_WINDOW,"CONTENTS_WINDOW"},
|
||||||
{CONTENTS_AUX,"CONTENTS_AUX"},
|
{CONTENTS_AUX,"CONTENTS_AUX"},
|
||||||
{CONTENTS_LAVA,"CONTENTS_LAVA"},
|
{CONTENTS_LAVA,"CONTENTS_LAVA"},
|
||||||
{CONTENTS_SLIME,"CONTENTS_SLIME"},
|
{CONTENTS_SLIME,"CONTENTS_SLIME"},
|
||||||
{CONTENTS_WATER,"CONTENTS_WATER"},
|
{CONTENTS_WATER,"CONTENTS_WATER"},
|
||||||
{CONTENTS_MIST,"CONTENTS_MIST"},
|
{CONTENTS_MIST,"CONTENTS_MIST"},
|
||||||
{LAST_VISIBLE_CONTENTS,"LAST_VISIBLE_CONTENTS"},
|
{LAST_VISIBLE_CONTENTS,"LAST_VISIBLE_CONTENTS"},
|
||||||
|
|
||||||
{CONTENTS_AREAPORTAL,"CONTENTS_AREAPORTAL"},
|
{CONTENTS_AREAPORTAL,"CONTENTS_AREAPORTAL"},
|
||||||
{CONTENTS_PLAYERCLIP,"CONTENTS_PLAYERCLIP"},
|
{CONTENTS_PLAYERCLIP,"CONTENTS_PLAYERCLIP"},
|
||||||
{CONTENTS_MONSTERCLIP,"CONTENTS_MONSTERCLIP"},
|
{CONTENTS_MONSTERCLIP,"CONTENTS_MONSTERCLIP"},
|
||||||
{CONTENTS_CURRENT_0,"CONTENTS_CURRENT_0"},
|
{CONTENTS_CURRENT_0,"CONTENTS_CURRENT_0"},
|
||||||
{CONTENTS_CURRENT_90,"CONTENTS_CURRENT_90"},
|
{CONTENTS_CURRENT_90,"CONTENTS_CURRENT_90"},
|
||||||
{CONTENTS_CURRENT_180,"CONTENTS_CURRENT_180"},
|
{CONTENTS_CURRENT_180,"CONTENTS_CURRENT_180"},
|
||||||
{CONTENTS_CURRENT_270,"CONTENTS_CURRENT_270"},
|
{CONTENTS_CURRENT_270,"CONTENTS_CURRENT_270"},
|
||||||
{CONTENTS_CURRENT_UP,"CONTENTS_CURRENT_UP"},
|
{CONTENTS_CURRENT_UP,"CONTENTS_CURRENT_UP"},
|
||||||
{CONTENTS_CURRENT_DOWN,"CONTENTS_CURRENT_DOWN"},
|
{CONTENTS_CURRENT_DOWN,"CONTENTS_CURRENT_DOWN"},
|
||||||
{CONTENTS_ORIGIN,"CONTENTS_ORIGIN"},
|
{CONTENTS_ORIGIN,"CONTENTS_ORIGIN"},
|
||||||
{CONTENTS_MONSTER,"CONTENTS_MONSTER"},
|
{CONTENTS_MONSTER,"CONTENTS_MONSTER"},
|
||||||
{CONTENTS_DEADMONSTER,"CONTENTS_DEADMONSTER"},
|
{CONTENTS_DEADMONSTER,"CONTENTS_DEADMONSTER"},
|
||||||
{CONTENTS_DETAIL,"CONTENTS_DETAIL"},
|
{CONTENTS_DETAIL,"CONTENTS_DETAIL"},
|
||||||
{CONTENTS_TRANSLUCENT,"CONTENTS_TRANSLUCENT"},
|
{CONTENTS_TRANSLUCENT,"CONTENTS_TRANSLUCENT"},
|
||||||
{CONTENTS_LADDER,"CONTENTS_LADDER"},
|
{CONTENTS_LADDER,"CONTENTS_LADDER"},
|
||||||
{0, 0}
|
{0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
void PrintContents(int contents)
|
void PrintContents(int contents)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; contentnames[i].value; i++)
|
for (i = 0; contentnames[i].value; i++)
|
||||||
{
|
{
|
||||||
if (contents & contentnames[i].value)
|
if (contents & contentnames[i].value)
|
||||||
{
|
{
|
||||||
botimport.Print(PRT_MESSAGE, "%s\n", contentnames[i].name);
|
botimport.Print(PRT_MESSAGE, "%s\n", contentnames[i].name);
|
||||||
} //end if
|
} //end if
|
||||||
} //end for
|
} //end for
|
||||||
} //end of the function PrintContents
|
} //end of the function PrintContents
|
||||||
|
|
||||||
#endif // BSP_DEBUG
|
#endif // BSP_DEBUG
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
// traces axial boxes of any size through the world
|
// traces axial boxes of any size through the world
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
bsp_trace_t AAS_Trace(vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int passent, int contentmask)
|
bsp_trace_t AAS_Trace(vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int passent, int contentmask)
|
||||||
{
|
{
|
||||||
bsp_trace_t bsptrace;
|
bsp_trace_t bsptrace;
|
||||||
botimport.Trace(&bsptrace, start, mins, maxs, end, passent, contentmask);
|
botimport.Trace(&bsptrace, start, mins, maxs, end, passent, contentmask);
|
||||||
return bsptrace;
|
return bsptrace;
|
||||||
} //end of the function AAS_Trace
|
} //end of the function AAS_Trace
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
// returns the contents at the given point
|
// returns the contents at the given point
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_PointContents(vec3_t point)
|
int AAS_PointContents(vec3_t point)
|
||||||
{
|
{
|
||||||
return botimport.PointContents(point);
|
return botimport.PointContents(point);
|
||||||
} //end of the function AAS_PointContents
|
} //end of the function AAS_PointContents
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
qboolean AAS_EntityCollision(int entnum,
|
qboolean AAS_EntityCollision(int entnum,
|
||||||
vec3_t start, vec3_t boxmins, vec3_t boxmaxs, vec3_t end,
|
vec3_t start, vec3_t boxmins, vec3_t boxmaxs, vec3_t end,
|
||||||
int contentmask, bsp_trace_t *trace)
|
int contentmask, bsp_trace_t *trace)
|
||||||
{
|
{
|
||||||
bsp_trace_t enttrace;
|
bsp_trace_t enttrace;
|
||||||
|
|
||||||
botimport.EntityTrace(&enttrace, start, boxmins, boxmaxs, end, entnum, contentmask);
|
botimport.EntityTrace(&enttrace, start, boxmins, boxmaxs, end, entnum, contentmask);
|
||||||
if (enttrace.fraction < trace->fraction)
|
if (enttrace.fraction < trace->fraction)
|
||||||
{
|
{
|
||||||
Com_Memcpy(trace, &enttrace, sizeof(bsp_trace_t));
|
Com_Memcpy(trace, &enttrace, sizeof(bsp_trace_t));
|
||||||
return qtrue;
|
return qtrue;
|
||||||
} //end if
|
} //end if
|
||||||
return qfalse;
|
return qfalse;
|
||||||
} //end of the function AAS_EntityCollision
|
} //end of the function AAS_EntityCollision
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
// returns true if in Potentially Hearable Set
|
// returns true if in Potentially Hearable Set
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
qboolean AAS_inPVS(vec3_t p1, vec3_t p2)
|
qboolean AAS_inPVS(vec3_t p1, vec3_t p2)
|
||||||
{
|
{
|
||||||
return botimport.inPVS(p1, p2);
|
return botimport.inPVS(p1, p2);
|
||||||
} //end of the function AAS_InPVS
|
} //end of the function AAS_InPVS
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
// returns true if in Potentially Visible Set
|
// returns true if in Potentially Visible Set
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
qboolean AAS_inPHS(vec3_t p1, vec3_t p2)
|
qboolean AAS_inPHS(vec3_t p1, vec3_t p2)
|
||||||
{
|
{
|
||||||
return qtrue;
|
return qtrue;
|
||||||
} //end of the function AAS_inPHS
|
} //end of the function AAS_inPHS
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_BSPModelMinsMaxsOrigin(int modelnum, vec3_t angles, vec3_t mins, vec3_t maxs, vec3_t origin)
|
void AAS_BSPModelMinsMaxsOrigin(int modelnum, vec3_t angles, vec3_t mins, vec3_t maxs, vec3_t origin)
|
||||||
{
|
{
|
||||||
botimport.BSPModelMinsMaxsOrigin(modelnum, angles, mins, maxs, origin);
|
botimport.BSPModelMinsMaxsOrigin(modelnum, angles, mins, maxs, origin);
|
||||||
} //end of the function AAS_BSPModelMinsMaxs
|
} //end of the function AAS_BSPModelMinsMaxs
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
// unlinks the entity from all leaves
|
// unlinks the entity from all leaves
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_UnlinkFromBSPLeaves(bsp_link_t *leaves)
|
void AAS_UnlinkFromBSPLeaves(bsp_link_t *leaves)
|
||||||
{
|
{
|
||||||
} //end of the function AAS_UnlinkFromBSPLeaves
|
} //end of the function AAS_UnlinkFromBSPLeaves
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
bsp_link_t *AAS_BSPLinkEntity(vec3_t absmins, vec3_t absmaxs, int entnum, int modelnum)
|
bsp_link_t *AAS_BSPLinkEntity(vec3_t absmins, vec3_t absmaxs, int entnum, int modelnum)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
} //end of the function AAS_BSPLinkEntity
|
} //end of the function AAS_BSPLinkEntity
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_BoxEntities(vec3_t absmins, vec3_t absmaxs, int *list, int maxcount)
|
int AAS_BoxEntities(vec3_t absmins, vec3_t absmaxs, int *list, int maxcount)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
} //end of the function AAS_BoxEntities
|
} //end of the function AAS_BoxEntities
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_NextBSPEntity(int ent)
|
int AAS_NextBSPEntity(int ent)
|
||||||
{
|
{
|
||||||
ent++;
|
ent++;
|
||||||
if (ent >= 1 && ent < bspworld.numentities) return ent;
|
if (ent >= 1 && ent < bspworld.numentities) return ent;
|
||||||
return 0;
|
return 0;
|
||||||
} //end of the function AAS_NextBSPEntity
|
} //end of the function AAS_NextBSPEntity
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_BSPEntityInRange(int ent)
|
int AAS_BSPEntityInRange(int ent)
|
||||||
{
|
{
|
||||||
if (ent <= 0 || ent >= bspworld.numentities)
|
if (ent <= 0 || ent >= bspworld.numentities)
|
||||||
{
|
{
|
||||||
botimport.Print(PRT_MESSAGE, "bsp entity out of range\n");
|
botimport.Print(PRT_MESSAGE, "bsp entity out of range\n");
|
||||||
return qfalse;
|
return qfalse;
|
||||||
} //end if
|
} //end if
|
||||||
return qtrue;
|
return qtrue;
|
||||||
} //end of the function AAS_BSPEntityInRange
|
} //end of the function AAS_BSPEntityInRange
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_ValueForBSPEpairKey(int ent, char *key, char *value, int size)
|
int AAS_ValueForBSPEpairKey(int ent, char *key, char *value, int size)
|
||||||
{
|
{
|
||||||
bsp_epair_t *epair;
|
bsp_epair_t *epair;
|
||||||
|
|
||||||
value[0] = '\0';
|
value[0] = '\0';
|
||||||
if (!AAS_BSPEntityInRange(ent)) return qfalse;
|
if (!AAS_BSPEntityInRange(ent)) return qfalse;
|
||||||
for (epair = bspworld.entities[ent].epairs; epair; epair = epair->next)
|
for (epair = bspworld.entities[ent].epairs; epair; epair = epair->next)
|
||||||
{
|
{
|
||||||
if (!strcmp(epair->key, key))
|
if (!strcmp(epair->key, key))
|
||||||
{
|
{
|
||||||
strncpy(value, epair->value, size-1);
|
strncpy(value, epair->value, size-1);
|
||||||
value[size-1] = '\0';
|
value[size-1] = '\0';
|
||||||
return qtrue;
|
return qtrue;
|
||||||
} //end if
|
} //end if
|
||||||
} //end for
|
} //end for
|
||||||
return qfalse;
|
return qfalse;
|
||||||
} //end of the function AAS_FindBSPEpair
|
} //end of the function AAS_FindBSPEpair
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_VectorForBSPEpairKey(int ent, char *key, vec3_t v)
|
int AAS_VectorForBSPEpairKey(int ent, char *key, vec3_t v)
|
||||||
{
|
{
|
||||||
char buf[MAX_EPAIRKEY];
|
char buf[MAX_EPAIRKEY];
|
||||||
double v1, v2, v3;
|
double v1, v2, v3;
|
||||||
|
|
||||||
VectorClear(v);
|
VectorClear(v);
|
||||||
if (!AAS_ValueForBSPEpairKey(ent, key, buf, MAX_EPAIRKEY)) return qfalse;
|
if (!AAS_ValueForBSPEpairKey(ent, key, buf, MAX_EPAIRKEY)) return qfalse;
|
||||||
//scanf into doubles, then assign, so it is vec_t size independent
|
//scanf into doubles, then assign, so it is vec_t size independent
|
||||||
v1 = v2 = v3 = 0;
|
v1 = v2 = v3 = 0;
|
||||||
sscanf(buf, "%lf %lf %lf", &v1, &v2, &v3);
|
sscanf(buf, "%lf %lf %lf", &v1, &v2, &v3);
|
||||||
v[0] = v1;
|
v[0] = v1;
|
||||||
v[1] = v2;
|
v[1] = v2;
|
||||||
v[2] = v3;
|
v[2] = v3;
|
||||||
return qtrue;
|
return qtrue;
|
||||||
} //end of the function AAS_VectorForBSPEpairKey
|
} //end of the function AAS_VectorForBSPEpairKey
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_FloatForBSPEpairKey(int ent, char *key, float *value)
|
int AAS_FloatForBSPEpairKey(int ent, char *key, float *value)
|
||||||
{
|
{
|
||||||
char buf[MAX_EPAIRKEY];
|
char buf[MAX_EPAIRKEY];
|
||||||
|
|
||||||
*value = 0;
|
*value = 0;
|
||||||
if (!AAS_ValueForBSPEpairKey(ent, key, buf, MAX_EPAIRKEY)) return qfalse;
|
if (!AAS_ValueForBSPEpairKey(ent, key, buf, MAX_EPAIRKEY)) return qfalse;
|
||||||
*value = atof(buf);
|
*value = atof(buf);
|
||||||
return qtrue;
|
return qtrue;
|
||||||
} //end of the function AAS_FloatForBSPEpairKey
|
} //end of the function AAS_FloatForBSPEpairKey
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_IntForBSPEpairKey(int ent, char *key, int *value)
|
int AAS_IntForBSPEpairKey(int ent, char *key, int *value)
|
||||||
{
|
{
|
||||||
char buf[MAX_EPAIRKEY];
|
char buf[MAX_EPAIRKEY];
|
||||||
|
|
||||||
*value = 0;
|
*value = 0;
|
||||||
if (!AAS_ValueForBSPEpairKey(ent, key, buf, MAX_EPAIRKEY)) return qfalse;
|
if (!AAS_ValueForBSPEpairKey(ent, key, buf, MAX_EPAIRKEY)) return qfalse;
|
||||||
*value = atoi(buf);
|
*value = atoi(buf);
|
||||||
return qtrue;
|
return qtrue;
|
||||||
} //end of the function AAS_IntForBSPEpairKey
|
} //end of the function AAS_IntForBSPEpairKey
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_FreeBSPEntities(void)
|
void AAS_FreeBSPEntities(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
bsp_entity_t *ent;
|
bsp_entity_t *ent;
|
||||||
bsp_epair_t *epair, *nextepair;
|
bsp_epair_t *epair, *nextepair;
|
||||||
|
|
||||||
for (i = 1; i < bspworld.numentities; i++)
|
for (i = 1; i < bspworld.numentities; i++)
|
||||||
{
|
{
|
||||||
ent = &bspworld.entities[i];
|
ent = &bspworld.entities[i];
|
||||||
for (epair = ent->epairs; epair; epair = nextepair)
|
for (epair = ent->epairs; epair; epair = nextepair)
|
||||||
{
|
{
|
||||||
nextepair = epair->next;
|
nextepair = epair->next;
|
||||||
//
|
//
|
||||||
if (epair->key) FreeMemory(epair->key);
|
if (epair->key) FreeMemory(epair->key);
|
||||||
if (epair->value) FreeMemory(epair->value);
|
if (epair->value) FreeMemory(epair->value);
|
||||||
FreeMemory(epair);
|
FreeMemory(epair);
|
||||||
} //end for
|
} //end for
|
||||||
} //end for
|
} //end for
|
||||||
bspworld.numentities = 0;
|
bspworld.numentities = 0;
|
||||||
} //end of the function AAS_FreeBSPEntities
|
} //end of the function AAS_FreeBSPEntities
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_ParseBSPEntities(void)
|
void AAS_ParseBSPEntities(void)
|
||||||
{
|
{
|
||||||
script_t *script;
|
script_t *script;
|
||||||
token_t token;
|
token_t token;
|
||||||
bsp_entity_t *ent;
|
bsp_entity_t *ent;
|
||||||
bsp_epair_t *epair;
|
bsp_epair_t *epair;
|
||||||
|
|
||||||
script = LoadScriptMemory(bspworld.dentdata, bspworld.entdatasize, "entdata");
|
script = LoadScriptMemory(bspworld.dentdata, bspworld.entdatasize, "entdata");
|
||||||
SetScriptFlags(script, SCFL_NOSTRINGWHITESPACES|SCFL_NOSTRINGESCAPECHARS);//SCFL_PRIMITIVE);
|
SetScriptFlags(script, SCFL_NOSTRINGWHITESPACES|SCFL_NOSTRINGESCAPECHARS);//SCFL_PRIMITIVE);
|
||||||
|
|
||||||
bspworld.numentities = 1;
|
bspworld.numentities = 1;
|
||||||
|
|
||||||
while(PS_ReadToken(script, &token))
|
while(PS_ReadToken(script, &token))
|
||||||
{
|
{
|
||||||
if (strcmp(token.string, "{"))
|
if (strcmp(token.string, "{"))
|
||||||
{
|
{
|
||||||
ScriptError(script, "invalid %s\n", token.string);
|
ScriptError(script, "invalid %s\n", token.string);
|
||||||
AAS_FreeBSPEntities();
|
AAS_FreeBSPEntities();
|
||||||
FreeScript(script);
|
FreeScript(script);
|
||||||
return;
|
return;
|
||||||
} //end if
|
} //end if
|
||||||
if (bspworld.numentities >= MAX_BSPENTITIES)
|
if (bspworld.numentities >= MAX_BSPENTITIES)
|
||||||
{
|
{
|
||||||
botimport.Print(PRT_MESSAGE, "too many entities in BSP file\n");
|
botimport.Print(PRT_MESSAGE, "too many entities in BSP file\n");
|
||||||
break;
|
break;
|
||||||
} //end if
|
} //end if
|
||||||
ent = &bspworld.entities[bspworld.numentities];
|
ent = &bspworld.entities[bspworld.numentities];
|
||||||
bspworld.numentities++;
|
bspworld.numentities++;
|
||||||
ent->epairs = NULL;
|
ent->epairs = NULL;
|
||||||
while(PS_ReadToken(script, &token))
|
while(PS_ReadToken(script, &token))
|
||||||
{
|
{
|
||||||
if (!strcmp(token.string, "}")) break;
|
if (!strcmp(token.string, "}")) break;
|
||||||
epair = (bsp_epair_t *) GetClearedHunkMemory(sizeof(bsp_epair_t));
|
epair = (bsp_epair_t *) GetClearedHunkMemory(sizeof(bsp_epair_t));
|
||||||
epair->next = ent->epairs;
|
epair->next = ent->epairs;
|
||||||
ent->epairs = epair;
|
ent->epairs = epair;
|
||||||
if (token.type != TT_STRING)
|
if (token.type != TT_STRING)
|
||||||
{
|
{
|
||||||
ScriptError(script, "invalid %s\n", token.string);
|
ScriptError(script, "invalid %s\n", token.string);
|
||||||
AAS_FreeBSPEntities();
|
AAS_FreeBSPEntities();
|
||||||
FreeScript(script);
|
FreeScript(script);
|
||||||
return;
|
return;
|
||||||
} //end if
|
} //end if
|
||||||
StripDoubleQuotes(token.string);
|
StripDoubleQuotes(token.string);
|
||||||
epair->key = (char *) GetHunkMemory(strlen(token.string) + 1);
|
epair->key = (char *) GetHunkMemory(strlen(token.string) + 1);
|
||||||
strcpy(epair->key, token.string);
|
strcpy(epair->key, token.string);
|
||||||
if (!PS_ExpectTokenType(script, TT_STRING, 0, &token))
|
if (!PS_ExpectTokenType(script, TT_STRING, 0, &token))
|
||||||
{
|
{
|
||||||
AAS_FreeBSPEntities();
|
AAS_FreeBSPEntities();
|
||||||
FreeScript(script);
|
FreeScript(script);
|
||||||
return;
|
return;
|
||||||
} //end if
|
} //end if
|
||||||
StripDoubleQuotes(token.string);
|
StripDoubleQuotes(token.string);
|
||||||
epair->value = (char *) GetHunkMemory(strlen(token.string) + 1);
|
epair->value = (char *) GetHunkMemory(strlen(token.string) + 1);
|
||||||
strcpy(epair->value, token.string);
|
strcpy(epair->value, token.string);
|
||||||
} //end while
|
} //end while
|
||||||
if (strcmp(token.string, "}"))
|
if (strcmp(token.string, "}"))
|
||||||
{
|
{
|
||||||
ScriptError(script, "missing }\n");
|
ScriptError(script, "missing }\n");
|
||||||
AAS_FreeBSPEntities();
|
AAS_FreeBSPEntities();
|
||||||
FreeScript(script);
|
FreeScript(script);
|
||||||
return;
|
return;
|
||||||
} //end if
|
} //end if
|
||||||
} //end while
|
} //end while
|
||||||
FreeScript(script);
|
FreeScript(script);
|
||||||
} //end of the function AAS_ParseBSPEntities
|
} //end of the function AAS_ParseBSPEntities
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_BSPTraceLight(vec3_t start, vec3_t end, vec3_t endpos, int *red, int *green, int *blue)
|
int AAS_BSPTraceLight(vec3_t start, vec3_t end, vec3_t endpos, int *red, int *green, int *blue)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
} //end of the function AAS_BSPTraceLight
|
} //end of the function AAS_BSPTraceLight
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_DumpBSPData(void)
|
void AAS_DumpBSPData(void)
|
||||||
{
|
{
|
||||||
AAS_FreeBSPEntities();
|
AAS_FreeBSPEntities();
|
||||||
|
|
||||||
if (bspworld.dentdata) FreeMemory(bspworld.dentdata);
|
if (bspworld.dentdata) FreeMemory(bspworld.dentdata);
|
||||||
bspworld.dentdata = NULL;
|
bspworld.dentdata = NULL;
|
||||||
bspworld.entdatasize = 0;
|
bspworld.entdatasize = 0;
|
||||||
//
|
//
|
||||||
bspworld.loaded = qfalse;
|
bspworld.loaded = qfalse;
|
||||||
Com_Memset( &bspworld, 0, sizeof(bspworld) );
|
Com_Memset( &bspworld, 0, sizeof(bspworld) );
|
||||||
} //end of the function AAS_DumpBSPData
|
} //end of the function AAS_DumpBSPData
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
// load an bsp file
|
// load an bsp file
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_LoadBSPFile(void)
|
int AAS_LoadBSPFile(void)
|
||||||
{
|
{
|
||||||
AAS_DumpBSPData();
|
AAS_DumpBSPData();
|
||||||
bspworld.entdatasize = strlen(botimport.BSPEntityData()) + 1;
|
bspworld.entdatasize = strlen(botimport.BSPEntityData()) + 1;
|
||||||
bspworld.dentdata = (char *) GetClearedHunkMemory(bspworld.entdatasize);
|
bspworld.dentdata = (char *) GetClearedHunkMemory(bspworld.entdatasize);
|
||||||
Com_Memcpy(bspworld.dentdata, botimport.BSPEntityData(), bspworld.entdatasize);
|
Com_Memcpy(bspworld.dentdata, botimport.BSPEntityData(), bspworld.entdatasize);
|
||||||
AAS_ParseBSPEntities();
|
AAS_ParseBSPEntities();
|
||||||
bspworld.loaded = qtrue;
|
bspworld.loaded = qtrue;
|
||||||
return BLERR_NOERROR;
|
return BLERR_NOERROR;
|
||||||
} //end of the function AAS_LoadBSPFile
|
} //end of the function AAS_LoadBSPFile
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,38 +1,38 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: be_aas_cluster.h
|
* name: be_aas_cluster.h
|
||||||
*
|
*
|
||||||
* desc: AAS
|
* desc: AAS
|
||||||
*
|
*
|
||||||
* $Archive: /source/code/botlib/be_aas_cluster.h $
|
* $Archive: /source/code/botlib/be_aas_cluster.h $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#ifdef AASINTERN
|
#ifdef AASINTERN
|
||||||
//initialize the AAS clustering
|
//initialize the AAS clustering
|
||||||
void AAS_InitClustering(void);
|
void AAS_InitClustering(void);
|
||||||
//
|
//
|
||||||
void AAS_SetViewPortalsAsClusterPortals(void);
|
void AAS_SetViewPortalsAsClusterPortals(void);
|
||||||
#endif //AASINTERN
|
#endif //AASINTERN
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,62 +1,62 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: be_aas_debug.h
|
* name: be_aas_debug.h
|
||||||
*
|
*
|
||||||
* desc: AAS
|
* desc: AAS
|
||||||
*
|
*
|
||||||
* $Archive: /source/code/botlib/be_aas_debug.h $
|
* $Archive: /source/code/botlib/be_aas_debug.h $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//clear the shown debug lines
|
//clear the shown debug lines
|
||||||
void AAS_ClearShownDebugLines(void);
|
void AAS_ClearShownDebugLines(void);
|
||||||
//
|
//
|
||||||
void AAS_ClearShownPolygons(void);
|
void AAS_ClearShownPolygons(void);
|
||||||
//show a debug line
|
//show a debug line
|
||||||
void AAS_DebugLine(vec3_t start, vec3_t end, int color);
|
void AAS_DebugLine(vec3_t start, vec3_t end, int color);
|
||||||
//show a permenent line
|
//show a permenent line
|
||||||
void AAS_PermanentLine(vec3_t start, vec3_t end, int color);
|
void AAS_PermanentLine(vec3_t start, vec3_t end, int color);
|
||||||
//show a permanent cross
|
//show a permanent cross
|
||||||
void AAS_DrawPermanentCross(vec3_t origin, float size, int color);
|
void AAS_DrawPermanentCross(vec3_t origin, float size, int color);
|
||||||
//draw a cross in the plane
|
//draw a cross in the plane
|
||||||
void AAS_DrawPlaneCross(vec3_t point, vec3_t normal, float dist, int type, int color);
|
void AAS_DrawPlaneCross(vec3_t point, vec3_t normal, float dist, int type, int color);
|
||||||
//show a bounding box
|
//show a bounding box
|
||||||
void AAS_ShowBoundingBox(vec3_t origin, vec3_t mins, vec3_t maxs);
|
void AAS_ShowBoundingBox(vec3_t origin, vec3_t mins, vec3_t maxs);
|
||||||
//show a face
|
//show a face
|
||||||
void AAS_ShowFace(int facenum);
|
void AAS_ShowFace(int facenum);
|
||||||
//show an area
|
//show an area
|
||||||
void AAS_ShowArea(int areanum, int groundfacesonly);
|
void AAS_ShowArea(int areanum, int groundfacesonly);
|
||||||
//
|
//
|
||||||
void AAS_ShowAreaPolygons(int areanum, int color, int groundfacesonly);
|
void AAS_ShowAreaPolygons(int areanum, int color, int groundfacesonly);
|
||||||
//draw a cros
|
//draw a cros
|
||||||
void AAS_DrawCross(vec3_t origin, float size, int color);
|
void AAS_DrawCross(vec3_t origin, float size, int color);
|
||||||
//print the travel type
|
//print the travel type
|
||||||
void AAS_PrintTravelType(int traveltype);
|
void AAS_PrintTravelType(int traveltype);
|
||||||
//draw an arrow
|
//draw an arrow
|
||||||
void AAS_DrawArrow(vec3_t start, vec3_t end, int linecolor, int arrowcolor);
|
void AAS_DrawArrow(vec3_t start, vec3_t end, int linecolor, int arrowcolor);
|
||||||
//visualize the given reachability
|
//visualize the given reachability
|
||||||
void AAS_ShowReachability(struct aas_reachability_s *reach);
|
void AAS_ShowReachability(struct aas_reachability_s *reach);
|
||||||
//show the reachable areas from the given area
|
//show the reachable areas from the given area
|
||||||
void AAS_ShowReachableAreas(int areanum);
|
void AAS_ShowReachableAreas(int areanum);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,306 +1,306 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: be_aas_def.h
|
* name: be_aas_def.h
|
||||||
*
|
*
|
||||||
* desc: AAS
|
* desc: AAS
|
||||||
*
|
*
|
||||||
* $Archive: /source/code/botlib/be_aas_def.h $
|
* $Archive: /source/code/botlib/be_aas_def.h $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//debugging on
|
//debugging on
|
||||||
#define AAS_DEBUG
|
#define AAS_DEBUG
|
||||||
|
|
||||||
#define MAX_CLIENTS 64
|
#define MAX_CLIENTS 64
|
||||||
#define MAX_MODELS 256 // these are sent over the net as 8 bits
|
#define MAX_MODELS 256 // these are sent over the net as 8 bits
|
||||||
#define MAX_SOUNDS 256 // so they cannot be blindly increased
|
#define MAX_SOUNDS 256 // so they cannot be blindly increased
|
||||||
#define MAX_CONFIGSTRINGS 1024
|
#define MAX_CONFIGSTRINGS 1024
|
||||||
|
|
||||||
#define CS_SCORES 32
|
#define CS_SCORES 32
|
||||||
#define CS_MODELS (CS_SCORES+MAX_CLIENTS)
|
#define CS_MODELS (CS_SCORES+MAX_CLIENTS)
|
||||||
#define CS_SOUNDS (CS_MODELS+MAX_MODELS)
|
#define CS_SOUNDS (CS_MODELS+MAX_MODELS)
|
||||||
|
|
||||||
#define DF_AASENTNUMBER(x) (x - aasworld.entities)
|
#define DF_AASENTNUMBER(x) (x - aasworld.entities)
|
||||||
#define DF_NUMBERAASENT(x) (&aasworld.entities[x])
|
#define DF_NUMBERAASENT(x) (&aasworld.entities[x])
|
||||||
#define DF_AASENTCLIENT(x) (x - aasworld.entities - 1)
|
#define DF_AASENTCLIENT(x) (x - aasworld.entities - 1)
|
||||||
#define DF_CLIENTAASENT(x) (&aasworld.entities[x + 1])
|
#define DF_CLIENTAASENT(x) (&aasworld.entities[x + 1])
|
||||||
|
|
||||||
#ifndef MAX_PATH
|
#ifndef MAX_PATH
|
||||||
#define MAX_PATH MAX_QPATH
|
#define MAX_PATH MAX_QPATH
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//string index (for model, sound and image index)
|
//string index (for model, sound and image index)
|
||||||
typedef struct aas_stringindex_s
|
typedef struct aas_stringindex_s
|
||||||
{
|
{
|
||||||
int numindexes;
|
int numindexes;
|
||||||
char **index;
|
char **index;
|
||||||
} aas_stringindex_t;
|
} aas_stringindex_t;
|
||||||
|
|
||||||
//structure to link entities to areas and areas to entities
|
//structure to link entities to areas and areas to entities
|
||||||
typedef struct aas_link_s
|
typedef struct aas_link_s
|
||||||
{
|
{
|
||||||
int entnum;
|
int entnum;
|
||||||
int areanum;
|
int areanum;
|
||||||
struct aas_link_s *next_ent, *prev_ent;
|
struct aas_link_s *next_ent, *prev_ent;
|
||||||
struct aas_link_s *next_area, *prev_area;
|
struct aas_link_s *next_area, *prev_area;
|
||||||
} aas_link_t;
|
} aas_link_t;
|
||||||
|
|
||||||
//structure to link entities to leaves and leaves to entities
|
//structure to link entities to leaves and leaves to entities
|
||||||
typedef struct bsp_link_s
|
typedef struct bsp_link_s
|
||||||
{
|
{
|
||||||
int entnum;
|
int entnum;
|
||||||
int leafnum;
|
int leafnum;
|
||||||
struct bsp_link_s *next_ent, *prev_ent;
|
struct bsp_link_s *next_ent, *prev_ent;
|
||||||
struct bsp_link_s *next_leaf, *prev_leaf;
|
struct bsp_link_s *next_leaf, *prev_leaf;
|
||||||
} bsp_link_t;
|
} bsp_link_t;
|
||||||
|
|
||||||
typedef struct bsp_entdata_s
|
typedef struct bsp_entdata_s
|
||||||
{
|
{
|
||||||
vec3_t origin;
|
vec3_t origin;
|
||||||
vec3_t angles;
|
vec3_t angles;
|
||||||
vec3_t absmins;
|
vec3_t absmins;
|
||||||
vec3_t absmaxs;
|
vec3_t absmaxs;
|
||||||
int solid;
|
int solid;
|
||||||
int modelnum;
|
int modelnum;
|
||||||
} bsp_entdata_t;
|
} bsp_entdata_t;
|
||||||
|
|
||||||
//entity
|
//entity
|
||||||
typedef struct aas_entity_s
|
typedef struct aas_entity_s
|
||||||
{
|
{
|
||||||
//entity info
|
//entity info
|
||||||
aas_entityinfo_t i;
|
aas_entityinfo_t i;
|
||||||
//links into the AAS areas
|
//links into the AAS areas
|
||||||
aas_link_t *areas;
|
aas_link_t *areas;
|
||||||
//links into the BSP leaves
|
//links into the BSP leaves
|
||||||
bsp_link_t *leaves;
|
bsp_link_t *leaves;
|
||||||
} aas_entity_t;
|
} aas_entity_t;
|
||||||
|
|
||||||
typedef struct aas_settings_s
|
typedef struct aas_settings_s
|
||||||
{
|
{
|
||||||
vec3_t phys_gravitydirection;
|
vec3_t phys_gravitydirection;
|
||||||
float phys_friction;
|
float phys_friction;
|
||||||
float phys_stopspeed;
|
float phys_stopspeed;
|
||||||
float phys_gravity;
|
float phys_gravity;
|
||||||
float phys_waterfriction;
|
float phys_waterfriction;
|
||||||
float phys_watergravity;
|
float phys_watergravity;
|
||||||
float phys_maxvelocity;
|
float phys_maxvelocity;
|
||||||
float phys_maxwalkvelocity;
|
float phys_maxwalkvelocity;
|
||||||
float phys_maxcrouchvelocity;
|
float phys_maxcrouchvelocity;
|
||||||
float phys_maxswimvelocity;
|
float phys_maxswimvelocity;
|
||||||
float phys_walkaccelerate;
|
float phys_walkaccelerate;
|
||||||
float phys_airaccelerate;
|
float phys_airaccelerate;
|
||||||
float phys_swimaccelerate;
|
float phys_swimaccelerate;
|
||||||
float phys_maxstep;
|
float phys_maxstep;
|
||||||
float phys_maxsteepness;
|
float phys_maxsteepness;
|
||||||
float phys_maxwaterjump;
|
float phys_maxwaterjump;
|
||||||
float phys_maxbarrier;
|
float phys_maxbarrier;
|
||||||
float phys_jumpvel;
|
float phys_jumpvel;
|
||||||
float phys_falldelta5;
|
float phys_falldelta5;
|
||||||
float phys_falldelta10;
|
float phys_falldelta10;
|
||||||
float rs_waterjump;
|
float rs_waterjump;
|
||||||
float rs_teleport;
|
float rs_teleport;
|
||||||
float rs_barrierjump;
|
float rs_barrierjump;
|
||||||
float rs_startcrouch;
|
float rs_startcrouch;
|
||||||
float rs_startgrapple;
|
float rs_startgrapple;
|
||||||
float rs_startwalkoffledge;
|
float rs_startwalkoffledge;
|
||||||
float rs_startjump;
|
float rs_startjump;
|
||||||
float rs_rocketjump;
|
float rs_rocketjump;
|
||||||
float rs_bfgjump;
|
float rs_bfgjump;
|
||||||
float rs_jumppad;
|
float rs_jumppad;
|
||||||
float rs_aircontrolledjumppad;
|
float rs_aircontrolledjumppad;
|
||||||
float rs_funcbob;
|
float rs_funcbob;
|
||||||
float rs_startelevator;
|
float rs_startelevator;
|
||||||
float rs_falldamage5;
|
float rs_falldamage5;
|
||||||
float rs_falldamage10;
|
float rs_falldamage10;
|
||||||
float rs_maxfallheight;
|
float rs_maxfallheight;
|
||||||
float rs_maxjumpfallheight;
|
float rs_maxjumpfallheight;
|
||||||
} aas_settings_t;
|
} aas_settings_t;
|
||||||
|
|
||||||
#define CACHETYPE_PORTAL 0
|
#define CACHETYPE_PORTAL 0
|
||||||
#define CACHETYPE_AREA 1
|
#define CACHETYPE_AREA 1
|
||||||
|
|
||||||
//routing cache
|
//routing cache
|
||||||
typedef struct aas_routingcache_s
|
typedef struct aas_routingcache_s
|
||||||
{
|
{
|
||||||
byte type; //portal or area cache
|
byte type; //portal or area cache
|
||||||
float time; //last time accessed or updated
|
float time; //last time accessed or updated
|
||||||
int size; //size of the routing cache
|
int size; //size of the routing cache
|
||||||
int cluster; //cluster the cache is for
|
int cluster; //cluster the cache is for
|
||||||
int areanum; //area the cache is created for
|
int areanum; //area the cache is created for
|
||||||
vec3_t origin; //origin within the area
|
vec3_t origin; //origin within the area
|
||||||
float starttraveltime; //travel time to start with
|
float starttraveltime; //travel time to start with
|
||||||
int travelflags; //combinations of the travel flags
|
int travelflags; //combinations of the travel flags
|
||||||
struct aas_routingcache_s *prev, *next;
|
struct aas_routingcache_s *prev, *next;
|
||||||
struct aas_routingcache_s *time_prev, *time_next;
|
struct aas_routingcache_s *time_prev, *time_next;
|
||||||
unsigned char *reachabilities; //reachabilities used for routing
|
unsigned char *reachabilities; //reachabilities used for routing
|
||||||
unsigned short int traveltimes[1]; //travel time for every area (variable sized)
|
unsigned short int traveltimes[1]; //travel time for every area (variable sized)
|
||||||
} aas_routingcache_t;
|
} aas_routingcache_t;
|
||||||
|
|
||||||
//fields for the routing algorithm
|
//fields for the routing algorithm
|
||||||
typedef struct aas_routingupdate_s
|
typedef struct aas_routingupdate_s
|
||||||
{
|
{
|
||||||
int cluster;
|
int cluster;
|
||||||
int areanum; //area number of the update
|
int areanum; //area number of the update
|
||||||
vec3_t start; //start point the area was entered
|
vec3_t start; //start point the area was entered
|
||||||
unsigned short int tmptraveltime; //temporary travel time
|
unsigned short int tmptraveltime; //temporary travel time
|
||||||
unsigned short int *areatraveltimes; //travel times within the area
|
unsigned short int *areatraveltimes; //travel times within the area
|
||||||
qboolean inlist; //true if the update is in the list
|
qboolean inlist; //true if the update is in the list
|
||||||
struct aas_routingupdate_s *next;
|
struct aas_routingupdate_s *next;
|
||||||
struct aas_routingupdate_s *prev;
|
struct aas_routingupdate_s *prev;
|
||||||
} aas_routingupdate_t;
|
} aas_routingupdate_t;
|
||||||
|
|
||||||
//reversed reachability link
|
//reversed reachability link
|
||||||
typedef struct aas_reversedlink_s
|
typedef struct aas_reversedlink_s
|
||||||
{
|
{
|
||||||
int linknum; //the aas_areareachability_t
|
int linknum; //the aas_areareachability_t
|
||||||
int areanum; //reachable from this area
|
int areanum; //reachable from this area
|
||||||
struct aas_reversedlink_s *next; //next link
|
struct aas_reversedlink_s *next; //next link
|
||||||
} aas_reversedlink_t;
|
} aas_reversedlink_t;
|
||||||
|
|
||||||
//reversed area reachability
|
//reversed area reachability
|
||||||
typedef struct aas_reversedreachability_s
|
typedef struct aas_reversedreachability_s
|
||||||
{
|
{
|
||||||
int numlinks;
|
int numlinks;
|
||||||
aas_reversedlink_t *first;
|
aas_reversedlink_t *first;
|
||||||
} aas_reversedreachability_t;
|
} aas_reversedreachability_t;
|
||||||
|
|
||||||
//areas a reachability goes through
|
//areas a reachability goes through
|
||||||
typedef struct aas_reachabilityareas_s
|
typedef struct aas_reachabilityareas_s
|
||||||
{
|
{
|
||||||
int firstarea, numareas;
|
int firstarea, numareas;
|
||||||
} aas_reachabilityareas_t;
|
} aas_reachabilityareas_t;
|
||||||
|
|
||||||
typedef struct aas_s
|
typedef struct aas_s
|
||||||
{
|
{
|
||||||
int loaded; //true when an AAS file is loaded
|
int loaded; //true when an AAS file is loaded
|
||||||
int initialized; //true when AAS has been initialized
|
int initialized; //true when AAS has been initialized
|
||||||
int savefile; //set true when file should be saved
|
int savefile; //set true when file should be saved
|
||||||
int bspchecksum;
|
int bspchecksum;
|
||||||
//current time
|
//current time
|
||||||
float time;
|
float time;
|
||||||
int numframes;
|
int numframes;
|
||||||
//name of the aas file
|
//name of the aas file
|
||||||
char filename[MAX_PATH];
|
char filename[MAX_PATH];
|
||||||
char mapname[MAX_PATH];
|
char mapname[MAX_PATH];
|
||||||
//bounding boxes
|
//bounding boxes
|
||||||
int numbboxes;
|
int numbboxes;
|
||||||
aas_bbox_t *bboxes;
|
aas_bbox_t *bboxes;
|
||||||
//vertexes
|
//vertexes
|
||||||
int numvertexes;
|
int numvertexes;
|
||||||
aas_vertex_t *vertexes;
|
aas_vertex_t *vertexes;
|
||||||
//planes
|
//planes
|
||||||
int numplanes;
|
int numplanes;
|
||||||
aas_plane_t *planes;
|
aas_plane_t *planes;
|
||||||
//edges
|
//edges
|
||||||
int numedges;
|
int numedges;
|
||||||
aas_edge_t *edges;
|
aas_edge_t *edges;
|
||||||
//edge index
|
//edge index
|
||||||
int edgeindexsize;
|
int edgeindexsize;
|
||||||
aas_edgeindex_t *edgeindex;
|
aas_edgeindex_t *edgeindex;
|
||||||
//faces
|
//faces
|
||||||
int numfaces;
|
int numfaces;
|
||||||
aas_face_t *faces;
|
aas_face_t *faces;
|
||||||
//face index
|
//face index
|
||||||
int faceindexsize;
|
int faceindexsize;
|
||||||
aas_faceindex_t *faceindex;
|
aas_faceindex_t *faceindex;
|
||||||
//convex areas
|
//convex areas
|
||||||
int numareas;
|
int numareas;
|
||||||
aas_area_t *areas;
|
aas_area_t *areas;
|
||||||
//convex area settings
|
//convex area settings
|
||||||
int numareasettings;
|
int numareasettings;
|
||||||
aas_areasettings_t *areasettings;
|
aas_areasettings_t *areasettings;
|
||||||
//reachablity list
|
//reachablity list
|
||||||
int reachabilitysize;
|
int reachabilitysize;
|
||||||
aas_reachability_t *reachability;
|
aas_reachability_t *reachability;
|
||||||
//nodes of the bsp tree
|
//nodes of the bsp tree
|
||||||
int numnodes;
|
int numnodes;
|
||||||
aas_node_t *nodes;
|
aas_node_t *nodes;
|
||||||
//cluster portals
|
//cluster portals
|
||||||
int numportals;
|
int numportals;
|
||||||
aas_portal_t *portals;
|
aas_portal_t *portals;
|
||||||
//cluster portal index
|
//cluster portal index
|
||||||
int portalindexsize;
|
int portalindexsize;
|
||||||
aas_portalindex_t *portalindex;
|
aas_portalindex_t *portalindex;
|
||||||
//clusters
|
//clusters
|
||||||
int numclusters;
|
int numclusters;
|
||||||
aas_cluster_t *clusters;
|
aas_cluster_t *clusters;
|
||||||
//
|
//
|
||||||
int numreachabilityareas;
|
int numreachabilityareas;
|
||||||
float reachabilitytime;
|
float reachabilitytime;
|
||||||
//enities linked in the areas
|
//enities linked in the areas
|
||||||
aas_link_t *linkheap; //heap with link structures
|
aas_link_t *linkheap; //heap with link structures
|
||||||
int linkheapsize; //size of the link heap
|
int linkheapsize; //size of the link heap
|
||||||
aas_link_t *freelinks; //first free link
|
aas_link_t *freelinks; //first free link
|
||||||
aas_link_t **arealinkedentities; //entities linked into areas
|
aas_link_t **arealinkedentities; //entities linked into areas
|
||||||
//entities
|
//entities
|
||||||
int maxentities;
|
int maxentities;
|
||||||
int maxclients;
|
int maxclients;
|
||||||
aas_entity_t *entities;
|
aas_entity_t *entities;
|
||||||
//string indexes
|
//string indexes
|
||||||
char *configstrings[MAX_CONFIGSTRINGS];
|
char *configstrings[MAX_CONFIGSTRINGS];
|
||||||
int indexessetup;
|
int indexessetup;
|
||||||
//index to retrieve travel flag for a travel type
|
//index to retrieve travel flag for a travel type
|
||||||
int travelflagfortype[MAX_TRAVELTYPES];
|
int travelflagfortype[MAX_TRAVELTYPES];
|
||||||
//travel flags for each area based on contents
|
//travel flags for each area based on contents
|
||||||
int *areacontentstravelflags;
|
int *areacontentstravelflags;
|
||||||
//routing update
|
//routing update
|
||||||
aas_routingupdate_t *areaupdate;
|
aas_routingupdate_t *areaupdate;
|
||||||
aas_routingupdate_t *portalupdate;
|
aas_routingupdate_t *portalupdate;
|
||||||
//number of routing updates during a frame (reset every frame)
|
//number of routing updates during a frame (reset every frame)
|
||||||
int frameroutingupdates;
|
int frameroutingupdates;
|
||||||
//reversed reachability links
|
//reversed reachability links
|
||||||
aas_reversedreachability_t *reversedreachability;
|
aas_reversedreachability_t *reversedreachability;
|
||||||
//travel times within the areas
|
//travel times within the areas
|
||||||
unsigned short ***areatraveltimes;
|
unsigned short ***areatraveltimes;
|
||||||
//array of size numclusters with cluster cache
|
//array of size numclusters with cluster cache
|
||||||
aas_routingcache_t ***clusterareacache;
|
aas_routingcache_t ***clusterareacache;
|
||||||
aas_routingcache_t **portalcache;
|
aas_routingcache_t **portalcache;
|
||||||
//cache list sorted on time
|
//cache list sorted on time
|
||||||
aas_routingcache_t *oldestcache; // start of cache list sorted on time
|
aas_routingcache_t *oldestcache; // start of cache list sorted on time
|
||||||
aas_routingcache_t *newestcache; // end of cache list sorted on time
|
aas_routingcache_t *newestcache; // end of cache list sorted on time
|
||||||
//maximum travel time through portal areas
|
//maximum travel time through portal areas
|
||||||
int *portalmaxtraveltimes;
|
int *portalmaxtraveltimes;
|
||||||
//areas the reachabilities go through
|
//areas the reachabilities go through
|
||||||
int *reachabilityareaindex;
|
int *reachabilityareaindex;
|
||||||
aas_reachabilityareas_t *reachabilityareas;
|
aas_reachabilityareas_t *reachabilityareas;
|
||||||
} aas_t;
|
} aas_t;
|
||||||
|
|
||||||
#define AASINTERN
|
#define AASINTERN
|
||||||
|
|
||||||
#ifndef BSPCINCLUDE
|
#ifndef BSPCINCLUDE
|
||||||
|
|
||||||
#include "be_aas_main.h"
|
#include "be_aas_main.h"
|
||||||
#include "be_aas_entity.h"
|
#include "be_aas_entity.h"
|
||||||
#include "be_aas_sample.h"
|
#include "be_aas_sample.h"
|
||||||
#include "be_aas_cluster.h"
|
#include "be_aas_cluster.h"
|
||||||
#include "be_aas_reach.h"
|
#include "be_aas_reach.h"
|
||||||
#include "be_aas_route.h"
|
#include "be_aas_route.h"
|
||||||
#include "be_aas_routealt.h"
|
#include "be_aas_routealt.h"
|
||||||
#include "be_aas_debug.h"
|
#include "be_aas_debug.h"
|
||||||
#include "be_aas_file.h"
|
#include "be_aas_file.h"
|
||||||
#include "be_aas_optimize.h"
|
#include "be_aas_optimize.h"
|
||||||
#include "be_aas_bsp.h"
|
#include "be_aas_bsp.h"
|
||||||
#include "be_aas_move.h"
|
#include "be_aas_move.h"
|
||||||
|
|
||||||
#endif //BSPCINCLUDE
|
#endif //BSPCINCLUDE
|
||||||
|
|
|
||||||
|
|
@ -1,437 +1,437 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: be_aas_entity.c
|
* name: be_aas_entity.c
|
||||||
*
|
*
|
||||||
* desc: AAS entities
|
* desc: AAS entities
|
||||||
*
|
*
|
||||||
* $Archive: /MissionPack/code/botlib/be_aas_entity.c $
|
* $Archive: /MissionPack/code/botlib/be_aas_entity.c $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "../game/q_shared.h"
|
#include "../game/q_shared.h"
|
||||||
#include "l_memory.h"
|
#include "l_memory.h"
|
||||||
#include "l_script.h"
|
#include "l_script.h"
|
||||||
#include "l_precomp.h"
|
#include "l_precomp.h"
|
||||||
#include "l_struct.h"
|
#include "l_struct.h"
|
||||||
#include "l_utils.h"
|
#include "l_utils.h"
|
||||||
#include "l_log.h"
|
#include "l_log.h"
|
||||||
#include "aasfile.h"
|
#include "aasfile.h"
|
||||||
#include "../game/botlib.h"
|
#include "../game/botlib.h"
|
||||||
#include "../game/be_aas.h"
|
#include "../game/be_aas.h"
|
||||||
#include "be_aas_funcs.h"
|
#include "be_aas_funcs.h"
|
||||||
#include "be_interface.h"
|
#include "be_interface.h"
|
||||||
#include "be_aas_def.h"
|
#include "be_aas_def.h"
|
||||||
|
|
||||||
#define MASK_SOLID CONTENTS_PLAYERCLIP
|
#define MASK_SOLID CONTENTS_PLAYERCLIP
|
||||||
|
|
||||||
//FIXME: these might change
|
//FIXME: these might change
|
||||||
enum {
|
enum {
|
||||||
ET_GENERAL,
|
ET_GENERAL,
|
||||||
ET_PLAYER,
|
ET_PLAYER,
|
||||||
ET_ITEM,
|
ET_ITEM,
|
||||||
ET_MISSILE,
|
ET_MISSILE,
|
||||||
ET_MOVER
|
ET_MOVER
|
||||||
};
|
};
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_UpdateEntity(int entnum, bot_entitystate_t *state)
|
int AAS_UpdateEntity(int entnum, bot_entitystate_t *state)
|
||||||
{
|
{
|
||||||
int relink;
|
int relink;
|
||||||
aas_entity_t *ent;
|
aas_entity_t *ent;
|
||||||
vec3_t absmins, absmaxs;
|
vec3_t absmins, absmaxs;
|
||||||
|
|
||||||
if (!aasworld.loaded)
|
if (!aasworld.loaded)
|
||||||
{
|
{
|
||||||
botimport.Print(PRT_MESSAGE, "AAS_UpdateEntity: not loaded\n");
|
botimport.Print(PRT_MESSAGE, "AAS_UpdateEntity: not loaded\n");
|
||||||
return BLERR_NOAASFILE;
|
return BLERR_NOAASFILE;
|
||||||
} //end if
|
} //end if
|
||||||
|
|
||||||
ent = &aasworld.entities[entnum];
|
ent = &aasworld.entities[entnum];
|
||||||
|
|
||||||
if (!state) {
|
if (!state) {
|
||||||
//unlink the entity
|
//unlink the entity
|
||||||
AAS_UnlinkFromAreas(ent->areas);
|
AAS_UnlinkFromAreas(ent->areas);
|
||||||
//unlink the entity from the BSP leaves
|
//unlink the entity from the BSP leaves
|
||||||
AAS_UnlinkFromBSPLeaves(ent->leaves);
|
AAS_UnlinkFromBSPLeaves(ent->leaves);
|
||||||
//
|
//
|
||||||
ent->areas = NULL;
|
ent->areas = NULL;
|
||||||
//
|
//
|
||||||
ent->leaves = NULL;
|
ent->leaves = NULL;
|
||||||
return BLERR_NOERROR;
|
return BLERR_NOERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
ent->i.update_time = AAS_Time() - ent->i.ltime;
|
ent->i.update_time = AAS_Time() - ent->i.ltime;
|
||||||
ent->i.type = state->type;
|
ent->i.type = state->type;
|
||||||
ent->i.flags = state->flags;
|
ent->i.flags = state->flags;
|
||||||
ent->i.ltime = AAS_Time();
|
ent->i.ltime = AAS_Time();
|
||||||
VectorCopy(ent->i.origin, ent->i.lastvisorigin);
|
VectorCopy(ent->i.origin, ent->i.lastvisorigin);
|
||||||
VectorCopy(state->old_origin, ent->i.old_origin);
|
VectorCopy(state->old_origin, ent->i.old_origin);
|
||||||
ent->i.solid = state->solid;
|
ent->i.solid = state->solid;
|
||||||
ent->i.groundent = state->groundent;
|
ent->i.groundent = state->groundent;
|
||||||
ent->i.modelindex = state->modelindex;
|
ent->i.modelindex = state->modelindex;
|
||||||
ent->i.modelindex2 = state->modelindex2;
|
ent->i.modelindex2 = state->modelindex2;
|
||||||
ent->i.frame = state->frame;
|
ent->i.frame = state->frame;
|
||||||
ent->i.event = state->event;
|
ent->i.event = state->event;
|
||||||
ent->i.eventParm = state->eventParm;
|
ent->i.eventParm = state->eventParm;
|
||||||
ent->i.powerups = state->powerups;
|
ent->i.powerups = state->powerups;
|
||||||
ent->i.weapon = state->weapon;
|
ent->i.weapon = state->weapon;
|
||||||
ent->i.legsAnim = state->legsAnim;
|
ent->i.legsAnim = state->legsAnim;
|
||||||
ent->i.torsoAnim = state->torsoAnim;
|
ent->i.torsoAnim = state->torsoAnim;
|
||||||
//number of the entity
|
//number of the entity
|
||||||
ent->i.number = entnum;
|
ent->i.number = entnum;
|
||||||
//updated so set valid flag
|
//updated so set valid flag
|
||||||
ent->i.valid = qtrue;
|
ent->i.valid = qtrue;
|
||||||
//link everything the first frame
|
//link everything the first frame
|
||||||
if (aasworld.numframes == 1) relink = qtrue;
|
if (aasworld.numframes == 1) relink = qtrue;
|
||||||
else relink = qfalse;
|
else relink = qfalse;
|
||||||
//
|
//
|
||||||
if (ent->i.solid == SOLID_BSP)
|
if (ent->i.solid == SOLID_BSP)
|
||||||
{
|
{
|
||||||
//if the angles of the model changed
|
//if the angles of the model changed
|
||||||
if (!VectorCompare(state->angles, ent->i.angles))
|
if (!VectorCompare(state->angles, ent->i.angles))
|
||||||
{
|
{
|
||||||
VectorCopy(state->angles, ent->i.angles);
|
VectorCopy(state->angles, ent->i.angles);
|
||||||
relink = qtrue;
|
relink = qtrue;
|
||||||
} //end if
|
} //end if
|
||||||
//get the mins and maxs of the model
|
//get the mins and maxs of the model
|
||||||
//FIXME: rotate mins and maxs
|
//FIXME: rotate mins and maxs
|
||||||
AAS_BSPModelMinsMaxsOrigin(ent->i.modelindex, ent->i.angles, ent->i.mins, ent->i.maxs, NULL);
|
AAS_BSPModelMinsMaxsOrigin(ent->i.modelindex, ent->i.angles, ent->i.mins, ent->i.maxs, NULL);
|
||||||
} //end if
|
} //end if
|
||||||
else if (ent->i.solid == SOLID_BBOX)
|
else if (ent->i.solid == SOLID_BBOX)
|
||||||
{
|
{
|
||||||
//if the bounding box size changed
|
//if the bounding box size changed
|
||||||
if (!VectorCompare(state->mins, ent->i.mins) ||
|
if (!VectorCompare(state->mins, ent->i.mins) ||
|
||||||
!VectorCompare(state->maxs, ent->i.maxs))
|
!VectorCompare(state->maxs, ent->i.maxs))
|
||||||
{
|
{
|
||||||
VectorCopy(state->mins, ent->i.mins);
|
VectorCopy(state->mins, ent->i.mins);
|
||||||
VectorCopy(state->maxs, ent->i.maxs);
|
VectorCopy(state->maxs, ent->i.maxs);
|
||||||
relink = qtrue;
|
relink = qtrue;
|
||||||
} //end if
|
} //end if
|
||||||
VectorCopy(state->angles, ent->i.angles);
|
VectorCopy(state->angles, ent->i.angles);
|
||||||
} //end if
|
} //end if
|
||||||
//if the origin changed
|
//if the origin changed
|
||||||
if (!VectorCompare(state->origin, ent->i.origin))
|
if (!VectorCompare(state->origin, ent->i.origin))
|
||||||
{
|
{
|
||||||
VectorCopy(state->origin, ent->i.origin);
|
VectorCopy(state->origin, ent->i.origin);
|
||||||
relink = qtrue;
|
relink = qtrue;
|
||||||
} //end if
|
} //end if
|
||||||
//if the entity should be relinked
|
//if the entity should be relinked
|
||||||
if (relink)
|
if (relink)
|
||||||
{
|
{
|
||||||
//don't link the world model
|
//don't link the world model
|
||||||
if (entnum != ENTITYNUM_WORLD)
|
if (entnum != ENTITYNUM_WORLD)
|
||||||
{
|
{
|
||||||
//absolute mins and maxs
|
//absolute mins and maxs
|
||||||
VectorAdd(ent->i.mins, ent->i.origin, absmins);
|
VectorAdd(ent->i.mins, ent->i.origin, absmins);
|
||||||
VectorAdd(ent->i.maxs, ent->i.origin, absmaxs);
|
VectorAdd(ent->i.maxs, ent->i.origin, absmaxs);
|
||||||
//unlink the entity
|
//unlink the entity
|
||||||
AAS_UnlinkFromAreas(ent->areas);
|
AAS_UnlinkFromAreas(ent->areas);
|
||||||
//relink the entity to the AAS areas (use the larges bbox)
|
//relink the entity to the AAS areas (use the larges bbox)
|
||||||
ent->areas = AAS_LinkEntityClientBBox(absmins, absmaxs, entnum, PRESENCE_NORMAL);
|
ent->areas = AAS_LinkEntityClientBBox(absmins, absmaxs, entnum, PRESENCE_NORMAL);
|
||||||
//unlink the entity from the BSP leaves
|
//unlink the entity from the BSP leaves
|
||||||
AAS_UnlinkFromBSPLeaves(ent->leaves);
|
AAS_UnlinkFromBSPLeaves(ent->leaves);
|
||||||
//link the entity to the world BSP tree
|
//link the entity to the world BSP tree
|
||||||
ent->leaves = AAS_BSPLinkEntity(absmins, absmaxs, entnum, 0);
|
ent->leaves = AAS_BSPLinkEntity(absmins, absmaxs, entnum, 0);
|
||||||
} //end if
|
} //end if
|
||||||
} //end if
|
} //end if
|
||||||
return BLERR_NOERROR;
|
return BLERR_NOERROR;
|
||||||
} //end of the function AAS_UpdateEntity
|
} //end of the function AAS_UpdateEntity
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_EntityInfo(int entnum, aas_entityinfo_t *info)
|
void AAS_EntityInfo(int entnum, aas_entityinfo_t *info)
|
||||||
{
|
{
|
||||||
if (!aasworld.initialized)
|
if (!aasworld.initialized)
|
||||||
{
|
{
|
||||||
botimport.Print(PRT_FATAL, "AAS_EntityInfo: aasworld not initialized\n");
|
botimport.Print(PRT_FATAL, "AAS_EntityInfo: aasworld not initialized\n");
|
||||||
Com_Memset(info, 0, sizeof(aas_entityinfo_t));
|
Com_Memset(info, 0, sizeof(aas_entityinfo_t));
|
||||||
return;
|
return;
|
||||||
} //end if
|
} //end if
|
||||||
|
|
||||||
if (entnum < 0 || entnum >= aasworld.maxentities)
|
if (entnum < 0 || entnum >= aasworld.maxentities)
|
||||||
{
|
{
|
||||||
botimport.Print(PRT_FATAL, "AAS_EntityInfo: entnum %d out of range\n", entnum);
|
botimport.Print(PRT_FATAL, "AAS_EntityInfo: entnum %d out of range\n", entnum);
|
||||||
Com_Memset(info, 0, sizeof(aas_entityinfo_t));
|
Com_Memset(info, 0, sizeof(aas_entityinfo_t));
|
||||||
return;
|
return;
|
||||||
} //end if
|
} //end if
|
||||||
|
|
||||||
Com_Memcpy(info, &aasworld.entities[entnum].i, sizeof(aas_entityinfo_t));
|
Com_Memcpy(info, &aasworld.entities[entnum].i, sizeof(aas_entityinfo_t));
|
||||||
} //end of the function AAS_EntityInfo
|
} //end of the function AAS_EntityInfo
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_EntityOrigin(int entnum, vec3_t origin)
|
void AAS_EntityOrigin(int entnum, vec3_t origin)
|
||||||
{
|
{
|
||||||
if (entnum < 0 || entnum >= aasworld.maxentities)
|
if (entnum < 0 || entnum >= aasworld.maxentities)
|
||||||
{
|
{
|
||||||
botimport.Print(PRT_FATAL, "AAS_EntityOrigin: entnum %d out of range\n", entnum);
|
botimport.Print(PRT_FATAL, "AAS_EntityOrigin: entnum %d out of range\n", entnum);
|
||||||
VectorClear(origin);
|
VectorClear(origin);
|
||||||
return;
|
return;
|
||||||
} //end if
|
} //end if
|
||||||
|
|
||||||
VectorCopy(aasworld.entities[entnum].i.origin, origin);
|
VectorCopy(aasworld.entities[entnum].i.origin, origin);
|
||||||
} //end of the function AAS_EntityOrigin
|
} //end of the function AAS_EntityOrigin
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_EntityModelindex(int entnum)
|
int AAS_EntityModelindex(int entnum)
|
||||||
{
|
{
|
||||||
if (entnum < 0 || entnum >= aasworld.maxentities)
|
if (entnum < 0 || entnum >= aasworld.maxentities)
|
||||||
{
|
{
|
||||||
botimport.Print(PRT_FATAL, "AAS_EntityModelindex: entnum %d out of range\n", entnum);
|
botimport.Print(PRT_FATAL, "AAS_EntityModelindex: entnum %d out of range\n", entnum);
|
||||||
return 0;
|
return 0;
|
||||||
} //end if
|
} //end if
|
||||||
return aasworld.entities[entnum].i.modelindex;
|
return aasworld.entities[entnum].i.modelindex;
|
||||||
} //end of the function AAS_EntityModelindex
|
} //end of the function AAS_EntityModelindex
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_EntityType(int entnum)
|
int AAS_EntityType(int entnum)
|
||||||
{
|
{
|
||||||
if (!aasworld.initialized) return 0;
|
if (!aasworld.initialized) return 0;
|
||||||
|
|
||||||
if (entnum < 0 || entnum >= aasworld.maxentities)
|
if (entnum < 0 || entnum >= aasworld.maxentities)
|
||||||
{
|
{
|
||||||
botimport.Print(PRT_FATAL, "AAS_EntityType: entnum %d out of range\n", entnum);
|
botimport.Print(PRT_FATAL, "AAS_EntityType: entnum %d out of range\n", entnum);
|
||||||
return 0;
|
return 0;
|
||||||
} //end if
|
} //end if
|
||||||
return aasworld.entities[entnum].i.type;
|
return aasworld.entities[entnum].i.type;
|
||||||
} //end of the AAS_EntityType
|
} //end of the AAS_EntityType
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_EntityModelNum(int entnum)
|
int AAS_EntityModelNum(int entnum)
|
||||||
{
|
{
|
||||||
if (!aasworld.initialized) return 0;
|
if (!aasworld.initialized) return 0;
|
||||||
|
|
||||||
if (entnum < 0 || entnum >= aasworld.maxentities)
|
if (entnum < 0 || entnum >= aasworld.maxentities)
|
||||||
{
|
{
|
||||||
botimport.Print(PRT_FATAL, "AAS_EntityModelNum: entnum %d out of range\n", entnum);
|
botimport.Print(PRT_FATAL, "AAS_EntityModelNum: entnum %d out of range\n", entnum);
|
||||||
return 0;
|
return 0;
|
||||||
} //end if
|
} //end if
|
||||||
return aasworld.entities[entnum].i.modelindex;
|
return aasworld.entities[entnum].i.modelindex;
|
||||||
} //end of the function AAS_EntityModelNum
|
} //end of the function AAS_EntityModelNum
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_OriginOfMoverWithModelNum(int modelnum, vec3_t origin)
|
int AAS_OriginOfMoverWithModelNum(int modelnum, vec3_t origin)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
aas_entity_t *ent;
|
aas_entity_t *ent;
|
||||||
|
|
||||||
for (i = 0; i < aasworld.maxentities; i++)
|
for (i = 0; i < aasworld.maxentities; i++)
|
||||||
{
|
{
|
||||||
ent = &aasworld.entities[i];
|
ent = &aasworld.entities[i];
|
||||||
if (ent->i.type == ET_MOVER)
|
if (ent->i.type == ET_MOVER)
|
||||||
{
|
{
|
||||||
if (ent->i.modelindex == modelnum)
|
if (ent->i.modelindex == modelnum)
|
||||||
{
|
{
|
||||||
VectorCopy(ent->i.origin, origin);
|
VectorCopy(ent->i.origin, origin);
|
||||||
return qtrue;
|
return qtrue;
|
||||||
} //end if
|
} //end if
|
||||||
} //end if
|
} //end if
|
||||||
} //end for
|
} //end for
|
||||||
return qfalse;
|
return qfalse;
|
||||||
} //end of the function AAS_OriginOfMoverWithModelNum
|
} //end of the function AAS_OriginOfMoverWithModelNum
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_EntitySize(int entnum, vec3_t mins, vec3_t maxs)
|
void AAS_EntitySize(int entnum, vec3_t mins, vec3_t maxs)
|
||||||
{
|
{
|
||||||
aas_entity_t *ent;
|
aas_entity_t *ent;
|
||||||
|
|
||||||
if (!aasworld.initialized) return;
|
if (!aasworld.initialized) return;
|
||||||
|
|
||||||
if (entnum < 0 || entnum >= aasworld.maxentities)
|
if (entnum < 0 || entnum >= aasworld.maxentities)
|
||||||
{
|
{
|
||||||
botimport.Print(PRT_FATAL, "AAS_EntitySize: entnum %d out of range\n", entnum);
|
botimport.Print(PRT_FATAL, "AAS_EntitySize: entnum %d out of range\n", entnum);
|
||||||
return;
|
return;
|
||||||
} //end if
|
} //end if
|
||||||
|
|
||||||
ent = &aasworld.entities[entnum];
|
ent = &aasworld.entities[entnum];
|
||||||
VectorCopy(ent->i.mins, mins);
|
VectorCopy(ent->i.mins, mins);
|
||||||
VectorCopy(ent->i.maxs, maxs);
|
VectorCopy(ent->i.maxs, maxs);
|
||||||
} //end of the function AAS_EntitySize
|
} //end of the function AAS_EntitySize
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_EntityBSPData(int entnum, bsp_entdata_t *entdata)
|
void AAS_EntityBSPData(int entnum, bsp_entdata_t *entdata)
|
||||||
{
|
{
|
||||||
aas_entity_t *ent;
|
aas_entity_t *ent;
|
||||||
|
|
||||||
ent = &aasworld.entities[entnum];
|
ent = &aasworld.entities[entnum];
|
||||||
VectorCopy(ent->i.origin, entdata->origin);
|
VectorCopy(ent->i.origin, entdata->origin);
|
||||||
VectorCopy(ent->i.angles, entdata->angles);
|
VectorCopy(ent->i.angles, entdata->angles);
|
||||||
VectorAdd(ent->i.origin, ent->i.mins, entdata->absmins);
|
VectorAdd(ent->i.origin, ent->i.mins, entdata->absmins);
|
||||||
VectorAdd(ent->i.origin, ent->i.maxs, entdata->absmaxs);
|
VectorAdd(ent->i.origin, ent->i.maxs, entdata->absmaxs);
|
||||||
entdata->solid = ent->i.solid;
|
entdata->solid = ent->i.solid;
|
||||||
entdata->modelnum = ent->i.modelindex - 1;
|
entdata->modelnum = ent->i.modelindex - 1;
|
||||||
} //end of the function AAS_EntityBSPData
|
} //end of the function AAS_EntityBSPData
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_ResetEntityLinks(void)
|
void AAS_ResetEntityLinks(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < aasworld.maxentities; i++)
|
for (i = 0; i < aasworld.maxentities; i++)
|
||||||
{
|
{
|
||||||
aasworld.entities[i].areas = NULL;
|
aasworld.entities[i].areas = NULL;
|
||||||
aasworld.entities[i].leaves = NULL;
|
aasworld.entities[i].leaves = NULL;
|
||||||
} //end for
|
} //end for
|
||||||
} //end of the function AAS_ResetEntityLinks
|
} //end of the function AAS_ResetEntityLinks
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_InvalidateEntities(void)
|
void AAS_InvalidateEntities(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < aasworld.maxentities; i++)
|
for (i = 0; i < aasworld.maxentities; i++)
|
||||||
{
|
{
|
||||||
aasworld.entities[i].i.valid = qfalse;
|
aasworld.entities[i].i.valid = qfalse;
|
||||||
aasworld.entities[i].i.number = i;
|
aasworld.entities[i].i.number = i;
|
||||||
} //end for
|
} //end for
|
||||||
} //end of the function AAS_InvalidateEntities
|
} //end of the function AAS_InvalidateEntities
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_UnlinkInvalidEntities(void)
|
void AAS_UnlinkInvalidEntities(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
aas_entity_t *ent;
|
aas_entity_t *ent;
|
||||||
|
|
||||||
for (i = 0; i < aasworld.maxentities; i++)
|
for (i = 0; i < aasworld.maxentities; i++)
|
||||||
{
|
{
|
||||||
ent = &aasworld.entities[i];
|
ent = &aasworld.entities[i];
|
||||||
if (!ent->i.valid)
|
if (!ent->i.valid)
|
||||||
{
|
{
|
||||||
AAS_UnlinkFromAreas( ent->areas );
|
AAS_UnlinkFromAreas( ent->areas );
|
||||||
ent->areas = NULL;
|
ent->areas = NULL;
|
||||||
AAS_UnlinkFromBSPLeaves( ent->leaves );
|
AAS_UnlinkFromBSPLeaves( ent->leaves );
|
||||||
ent->leaves = NULL;
|
ent->leaves = NULL;
|
||||||
} //end for
|
} //end for
|
||||||
} //end for
|
} //end for
|
||||||
} //end of the function AAS_UnlinkInvalidEntities
|
} //end of the function AAS_UnlinkInvalidEntities
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_NearestEntity(vec3_t origin, int modelindex)
|
int AAS_NearestEntity(vec3_t origin, int modelindex)
|
||||||
{
|
{
|
||||||
int i, bestentnum;
|
int i, bestentnum;
|
||||||
float dist, bestdist;
|
float dist, bestdist;
|
||||||
aas_entity_t *ent;
|
aas_entity_t *ent;
|
||||||
vec3_t dir;
|
vec3_t dir;
|
||||||
|
|
||||||
bestentnum = 0;
|
bestentnum = 0;
|
||||||
bestdist = 99999;
|
bestdist = 99999;
|
||||||
for (i = 0; i < aasworld.maxentities; i++)
|
for (i = 0; i < aasworld.maxentities; i++)
|
||||||
{
|
{
|
||||||
ent = &aasworld.entities[i];
|
ent = &aasworld.entities[i];
|
||||||
if (ent->i.modelindex != modelindex) continue;
|
if (ent->i.modelindex != modelindex) continue;
|
||||||
VectorSubtract(ent->i.origin, origin, dir);
|
VectorSubtract(ent->i.origin, origin, dir);
|
||||||
if (abs(dir[0]) < 40)
|
if (abs(dir[0]) < 40)
|
||||||
{
|
{
|
||||||
if (abs(dir[1]) < 40)
|
if (abs(dir[1]) < 40)
|
||||||
{
|
{
|
||||||
dist = VectorLength(dir);
|
dist = VectorLength(dir);
|
||||||
if (dist < bestdist)
|
if (dist < bestdist)
|
||||||
{
|
{
|
||||||
bestdist = dist;
|
bestdist = dist;
|
||||||
bestentnum = i;
|
bestentnum = i;
|
||||||
} //end if
|
} //end if
|
||||||
} //end if
|
} //end if
|
||||||
} //end if
|
} //end if
|
||||||
} //end for
|
} //end for
|
||||||
return bestentnum;
|
return bestentnum;
|
||||||
} //end of the function AAS_NearestEntity
|
} //end of the function AAS_NearestEntity
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_BestReachableEntityArea(int entnum)
|
int AAS_BestReachableEntityArea(int entnum)
|
||||||
{
|
{
|
||||||
aas_entity_t *ent;
|
aas_entity_t *ent;
|
||||||
|
|
||||||
ent = &aasworld.entities[entnum];
|
ent = &aasworld.entities[entnum];
|
||||||
return AAS_BestReachableLinkArea(ent->areas);
|
return AAS_BestReachableLinkArea(ent->areas);
|
||||||
} //end of the function AAS_BestReachableEntityArea
|
} //end of the function AAS_BestReachableEntityArea
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_NextEntity(int entnum)
|
int AAS_NextEntity(int entnum)
|
||||||
{
|
{
|
||||||
if (!aasworld.loaded) return 0;
|
if (!aasworld.loaded) return 0;
|
||||||
|
|
||||||
if (entnum < 0) entnum = -1;
|
if (entnum < 0) entnum = -1;
|
||||||
while(++entnum < aasworld.maxentities)
|
while(++entnum < aasworld.maxentities)
|
||||||
{
|
{
|
||||||
if (aasworld.entities[entnum].i.valid) return entnum;
|
if (aasworld.entities[entnum].i.valid) return entnum;
|
||||||
} //end while
|
} //end while
|
||||||
return 0;
|
return 0;
|
||||||
} //end of the function AAS_NextEntity
|
} //end of the function AAS_NextEntity
|
||||||
|
|
|
||||||
|
|
@ -1,63 +1,63 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: be_aas_entity.h
|
* name: be_aas_entity.h
|
||||||
*
|
*
|
||||||
* desc: AAS
|
* desc: AAS
|
||||||
*
|
*
|
||||||
* $Archive: /source/code/botlib/be_aas_entity.h $
|
* $Archive: /source/code/botlib/be_aas_entity.h $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#ifdef AASINTERN
|
#ifdef AASINTERN
|
||||||
//invalidates all entity infos
|
//invalidates all entity infos
|
||||||
void AAS_InvalidateEntities(void);
|
void AAS_InvalidateEntities(void);
|
||||||
//unlink not updated entities
|
//unlink not updated entities
|
||||||
void AAS_UnlinkInvalidEntities(void);
|
void AAS_UnlinkInvalidEntities(void);
|
||||||
//resets the entity AAS and BSP links (sets areas and leaves pointers to NULL)
|
//resets the entity AAS and BSP links (sets areas and leaves pointers to NULL)
|
||||||
void AAS_ResetEntityLinks(void);
|
void AAS_ResetEntityLinks(void);
|
||||||
//updates an entity
|
//updates an entity
|
||||||
int AAS_UpdateEntity(int ent, bot_entitystate_t *state);
|
int AAS_UpdateEntity(int ent, bot_entitystate_t *state);
|
||||||
//gives the entity data used for collision detection
|
//gives the entity data used for collision detection
|
||||||
void AAS_EntityBSPData(int entnum, bsp_entdata_t *entdata);
|
void AAS_EntityBSPData(int entnum, bsp_entdata_t *entdata);
|
||||||
#endif //AASINTERN
|
#endif //AASINTERN
|
||||||
|
|
||||||
//returns the size of the entity bounding box in mins and maxs
|
//returns the size of the entity bounding box in mins and maxs
|
||||||
void AAS_EntitySize(int entnum, vec3_t mins, vec3_t maxs);
|
void AAS_EntitySize(int entnum, vec3_t mins, vec3_t maxs);
|
||||||
//returns the BSP model number of the entity
|
//returns the BSP model number of the entity
|
||||||
int AAS_EntityModelNum(int entnum);
|
int AAS_EntityModelNum(int entnum);
|
||||||
//returns the origin of an entity with the given model number
|
//returns the origin of an entity with the given model number
|
||||||
int AAS_OriginOfMoverWithModelNum(int modelnum, vec3_t origin);
|
int AAS_OriginOfMoverWithModelNum(int modelnum, vec3_t origin);
|
||||||
//returns the best reachable area the entity is situated in
|
//returns the best reachable area the entity is situated in
|
||||||
int AAS_BestReachableEntityArea(int entnum);
|
int AAS_BestReachableEntityArea(int entnum);
|
||||||
//returns the info of the given entity
|
//returns the info of the given entity
|
||||||
void AAS_EntityInfo(int entnum, aas_entityinfo_t *info);
|
void AAS_EntityInfo(int entnum, aas_entityinfo_t *info);
|
||||||
//returns the next entity
|
//returns the next entity
|
||||||
int AAS_NextEntity(int entnum);
|
int AAS_NextEntity(int entnum);
|
||||||
//returns the origin of the entity
|
//returns the origin of the entity
|
||||||
void AAS_EntityOrigin(int entnum, vec3_t origin);
|
void AAS_EntityOrigin(int entnum, vec3_t origin);
|
||||||
//returns the entity type
|
//returns the entity type
|
||||||
int AAS_EntityType(int entnum);
|
int AAS_EntityType(int entnum);
|
||||||
//returns the model index of the entity
|
//returns the model index of the entity
|
||||||
int AAS_EntityModelindex(int entnum);
|
int AAS_EntityModelindex(int entnum);
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,42 +1,42 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: be_aas_file.h
|
* name: be_aas_file.h
|
||||||
*
|
*
|
||||||
* desc: AAS
|
* desc: AAS
|
||||||
*
|
*
|
||||||
* $Archive: /source/code/botlib/be_aas_file.h $
|
* $Archive: /source/code/botlib/be_aas_file.h $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#ifdef AASINTERN
|
#ifdef AASINTERN
|
||||||
//loads the AAS file with the given name
|
//loads the AAS file with the given name
|
||||||
int AAS_LoadAASFile(char *filename);
|
int AAS_LoadAASFile(char *filename);
|
||||||
//writes an AAS file with the given name
|
//writes an AAS file with the given name
|
||||||
qboolean AAS_WriteAASFile(char *filename);
|
qboolean AAS_WriteAASFile(char *filename);
|
||||||
//dumps the loaded AAS data
|
//dumps the loaded AAS data
|
||||||
void AAS_DumpAASData(void);
|
void AAS_DumpAASData(void);
|
||||||
//print AAS file information
|
//print AAS file information
|
||||||
void AAS_FileInfo(void);
|
void AAS_FileInfo(void);
|
||||||
#endif //AASINTERN
|
#endif //AASINTERN
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,47 +1,47 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: be_aas_funcs.h
|
* name: be_aas_funcs.h
|
||||||
*
|
*
|
||||||
* desc: AAS
|
* desc: AAS
|
||||||
*
|
*
|
||||||
* $Archive: /source/code/botlib/be_aas_funcs.h $
|
* $Archive: /source/code/botlib/be_aas_funcs.h $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#ifndef BSPCINCLUDE
|
#ifndef BSPCINCLUDE
|
||||||
|
|
||||||
#include "be_aas_main.h"
|
#include "be_aas_main.h"
|
||||||
#include "be_aas_entity.h"
|
#include "be_aas_entity.h"
|
||||||
#include "be_aas_sample.h"
|
#include "be_aas_sample.h"
|
||||||
#include "be_aas_cluster.h"
|
#include "be_aas_cluster.h"
|
||||||
#include "be_aas_reach.h"
|
#include "be_aas_reach.h"
|
||||||
#include "be_aas_route.h"
|
#include "be_aas_route.h"
|
||||||
#include "be_aas_routealt.h"
|
#include "be_aas_routealt.h"
|
||||||
#include "be_aas_debug.h"
|
#include "be_aas_debug.h"
|
||||||
#include "be_aas_file.h"
|
#include "be_aas_file.h"
|
||||||
#include "be_aas_optimize.h"
|
#include "be_aas_optimize.h"
|
||||||
#include "be_aas_bsp.h"
|
#include "be_aas_bsp.h"
|
||||||
#include "be_aas_move.h"
|
#include "be_aas_move.h"
|
||||||
|
|
||||||
#endif //BSPCINCLUDE
|
#endif //BSPCINCLUDE
|
||||||
|
|
|
||||||
|
|
@ -1,429 +1,429 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: be_aas_main.c
|
* name: be_aas_main.c
|
||||||
*
|
*
|
||||||
* desc: AAS
|
* desc: AAS
|
||||||
*
|
*
|
||||||
* $Archive: /MissionPack/code/botlib/be_aas_main.c $
|
* $Archive: /MissionPack/code/botlib/be_aas_main.c $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "../game/q_shared.h"
|
#include "../game/q_shared.h"
|
||||||
#include "l_memory.h"
|
#include "l_memory.h"
|
||||||
#include "l_libvar.h"
|
#include "l_libvar.h"
|
||||||
#include "l_utils.h"
|
#include "l_utils.h"
|
||||||
#include "l_script.h"
|
#include "l_script.h"
|
||||||
#include "l_precomp.h"
|
#include "l_precomp.h"
|
||||||
#include "l_struct.h"
|
#include "l_struct.h"
|
||||||
#include "l_log.h"
|
#include "l_log.h"
|
||||||
#include "aasfile.h"
|
#include "aasfile.h"
|
||||||
#include "../game/botlib.h"
|
#include "../game/botlib.h"
|
||||||
#include "../game/be_aas.h"
|
#include "../game/be_aas.h"
|
||||||
#include "be_aas_funcs.h"
|
#include "be_aas_funcs.h"
|
||||||
#include "be_interface.h"
|
#include "be_interface.h"
|
||||||
#include "be_aas_def.h"
|
#include "be_aas_def.h"
|
||||||
|
|
||||||
aas_t aasworld;
|
aas_t aasworld;
|
||||||
|
|
||||||
libvar_t *saveroutingcache;
|
libvar_t *saveroutingcache;
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void QDECL AAS_Error(char *fmt, ...)
|
void QDECL AAS_Error(char *fmt, ...)
|
||||||
{
|
{
|
||||||
char str[1024];
|
char str[1024];
|
||||||
va_list arglist;
|
va_list arglist;
|
||||||
|
|
||||||
va_start(arglist, fmt);
|
va_start(arglist, fmt);
|
||||||
vsprintf(str, fmt, arglist);
|
vsprintf(str, fmt, arglist);
|
||||||
va_end(arglist);
|
va_end(arglist);
|
||||||
botimport.Print(PRT_FATAL, str);
|
botimport.Print(PRT_FATAL, str);
|
||||||
} //end of the function AAS_Error
|
} //end of the function AAS_Error
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
char *AAS_StringFromIndex(char *indexname, char *stringindex[], int numindexes, int index)
|
char *AAS_StringFromIndex(char *indexname, char *stringindex[], int numindexes, int index)
|
||||||
{
|
{
|
||||||
if (!aasworld.indexessetup)
|
if (!aasworld.indexessetup)
|
||||||
{
|
{
|
||||||
botimport.Print(PRT_ERROR, "%s: index %d not setup\n", indexname, index);
|
botimport.Print(PRT_ERROR, "%s: index %d not setup\n", indexname, index);
|
||||||
return "";
|
return "";
|
||||||
} //end if
|
} //end if
|
||||||
if (index < 0 || index >= numindexes)
|
if (index < 0 || index >= numindexes)
|
||||||
{
|
{
|
||||||
botimport.Print(PRT_ERROR, "%s: index %d out of range\n", indexname, index);
|
botimport.Print(PRT_ERROR, "%s: index %d out of range\n", indexname, index);
|
||||||
return "";
|
return "";
|
||||||
} //end if
|
} //end if
|
||||||
if (!stringindex[index])
|
if (!stringindex[index])
|
||||||
{
|
{
|
||||||
if (index)
|
if (index)
|
||||||
{
|
{
|
||||||
botimport.Print(PRT_ERROR, "%s: reference to unused index %d\n", indexname, index);
|
botimport.Print(PRT_ERROR, "%s: reference to unused index %d\n", indexname, index);
|
||||||
} //end if
|
} //end if
|
||||||
return "";
|
return "";
|
||||||
} //end if
|
} //end if
|
||||||
return stringindex[index];
|
return stringindex[index];
|
||||||
} //end of the function AAS_StringFromIndex
|
} //end of the function AAS_StringFromIndex
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_IndexFromString(char *indexname, char *stringindex[], int numindexes, char *string)
|
int AAS_IndexFromString(char *indexname, char *stringindex[], int numindexes, char *string)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
if (!aasworld.indexessetup)
|
if (!aasworld.indexessetup)
|
||||||
{
|
{
|
||||||
botimport.Print(PRT_ERROR, "%s: index not setup \"%s\"\n", indexname, string);
|
botimport.Print(PRT_ERROR, "%s: index not setup \"%s\"\n", indexname, string);
|
||||||
return 0;
|
return 0;
|
||||||
} //end if
|
} //end if
|
||||||
for (i = 0; i < numindexes; i++)
|
for (i = 0; i < numindexes; i++)
|
||||||
{
|
{
|
||||||
if (!stringindex[i]) continue;
|
if (!stringindex[i]) continue;
|
||||||
if (!Q_stricmp(stringindex[i], string)) return i;
|
if (!Q_stricmp(stringindex[i], string)) return i;
|
||||||
} //end for
|
} //end for
|
||||||
return 0;
|
return 0;
|
||||||
} //end of the function AAS_IndexFromString
|
} //end of the function AAS_IndexFromString
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
char *AAS_ModelFromIndex(int index)
|
char *AAS_ModelFromIndex(int index)
|
||||||
{
|
{
|
||||||
return AAS_StringFromIndex("ModelFromIndex", &aasworld.configstrings[CS_MODELS], MAX_MODELS, index);
|
return AAS_StringFromIndex("ModelFromIndex", &aasworld.configstrings[CS_MODELS], MAX_MODELS, index);
|
||||||
} //end of the function AAS_ModelFromIndex
|
} //end of the function AAS_ModelFromIndex
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_IndexFromModel(char *modelname)
|
int AAS_IndexFromModel(char *modelname)
|
||||||
{
|
{
|
||||||
return AAS_IndexFromString("IndexFromModel", &aasworld.configstrings[CS_MODELS], MAX_MODELS, modelname);
|
return AAS_IndexFromString("IndexFromModel", &aasworld.configstrings[CS_MODELS], MAX_MODELS, modelname);
|
||||||
} //end of the function AAS_IndexFromModel
|
} //end of the function AAS_IndexFromModel
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_UpdateStringIndexes(int numconfigstrings, char *configstrings[])
|
void AAS_UpdateStringIndexes(int numconfigstrings, char *configstrings[])
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
//set string pointers and copy the strings
|
//set string pointers and copy the strings
|
||||||
for (i = 0; i < numconfigstrings; i++)
|
for (i = 0; i < numconfigstrings; i++)
|
||||||
{
|
{
|
||||||
if (configstrings[i])
|
if (configstrings[i])
|
||||||
{
|
{
|
||||||
//if (aasworld.configstrings[i]) FreeMemory(aasworld.configstrings[i]);
|
//if (aasworld.configstrings[i]) FreeMemory(aasworld.configstrings[i]);
|
||||||
aasworld.configstrings[i] = (char *) GetMemory(strlen(configstrings[i]) + 1);
|
aasworld.configstrings[i] = (char *) GetMemory(strlen(configstrings[i]) + 1);
|
||||||
strcpy(aasworld.configstrings[i], configstrings[i]);
|
strcpy(aasworld.configstrings[i], configstrings[i]);
|
||||||
} //end if
|
} //end if
|
||||||
} //end for
|
} //end for
|
||||||
aasworld.indexessetup = qtrue;
|
aasworld.indexessetup = qtrue;
|
||||||
} //end of the function AAS_UpdateStringIndexes
|
} //end of the function AAS_UpdateStringIndexes
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_Loaded(void)
|
int AAS_Loaded(void)
|
||||||
{
|
{
|
||||||
return aasworld.loaded;
|
return aasworld.loaded;
|
||||||
} //end of the function AAS_Loaded
|
} //end of the function AAS_Loaded
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_Initialized(void)
|
int AAS_Initialized(void)
|
||||||
{
|
{
|
||||||
return aasworld.initialized;
|
return aasworld.initialized;
|
||||||
} //end of the function AAS_Initialized
|
} //end of the function AAS_Initialized
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_SetInitialized(void)
|
void AAS_SetInitialized(void)
|
||||||
{
|
{
|
||||||
aasworld.initialized = qtrue;
|
aasworld.initialized = qtrue;
|
||||||
botimport.Print(PRT_MESSAGE, "AAS initialized.\n");
|
botimport.Print(PRT_MESSAGE, "AAS initialized.\n");
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
//create all the routing cache
|
//create all the routing cache
|
||||||
//AAS_CreateAllRoutingCache();
|
//AAS_CreateAllRoutingCache();
|
||||||
//
|
//
|
||||||
//AAS_RoutingInfo();
|
//AAS_RoutingInfo();
|
||||||
#endif
|
#endif
|
||||||
} //end of the function AAS_SetInitialized
|
} //end of the function AAS_SetInitialized
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_ContinueInit(float time)
|
void AAS_ContinueInit(float time)
|
||||||
{
|
{
|
||||||
//if no AAS file loaded
|
//if no AAS file loaded
|
||||||
if (!aasworld.loaded) return;
|
if (!aasworld.loaded) return;
|
||||||
//if AAS is already initialized
|
//if AAS is already initialized
|
||||||
if (aasworld.initialized) return;
|
if (aasworld.initialized) return;
|
||||||
//calculate reachability, if not finished return
|
//calculate reachability, if not finished return
|
||||||
if (AAS_ContinueInitReachability(time)) return;
|
if (AAS_ContinueInitReachability(time)) return;
|
||||||
//initialize clustering for the new map
|
//initialize clustering for the new map
|
||||||
AAS_InitClustering();
|
AAS_InitClustering();
|
||||||
//if reachability has been calculated and an AAS file should be written
|
//if reachability has been calculated and an AAS file should be written
|
||||||
//or there is a forced data optimization
|
//or there is a forced data optimization
|
||||||
if (aasworld.savefile || ((int)LibVarGetValue("forcewrite")))
|
if (aasworld.savefile || ((int)LibVarGetValue("forcewrite")))
|
||||||
{
|
{
|
||||||
//optimize the AAS data
|
//optimize the AAS data
|
||||||
if ((int)LibVarValue("aasoptimize", "0")) AAS_Optimize();
|
if ((int)LibVarValue("aasoptimize", "0")) AAS_Optimize();
|
||||||
//save the AAS file
|
//save the AAS file
|
||||||
if (AAS_WriteAASFile(aasworld.filename))
|
if (AAS_WriteAASFile(aasworld.filename))
|
||||||
{
|
{
|
||||||
botimport.Print(PRT_MESSAGE, "%s written succesfully\n", aasworld.filename);
|
botimport.Print(PRT_MESSAGE, "%s written succesfully\n", aasworld.filename);
|
||||||
} //end if
|
} //end if
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
botimport.Print(PRT_ERROR, "couldn't write %s\n", aasworld.filename);
|
botimport.Print(PRT_ERROR, "couldn't write %s\n", aasworld.filename);
|
||||||
} //end else
|
} //end else
|
||||||
} //end if
|
} //end if
|
||||||
//initialize the routing
|
//initialize the routing
|
||||||
AAS_InitRouting();
|
AAS_InitRouting();
|
||||||
//at this point AAS is initialized
|
//at this point AAS is initialized
|
||||||
AAS_SetInitialized();
|
AAS_SetInitialized();
|
||||||
} //end of the function AAS_ContinueInit
|
} //end of the function AAS_ContinueInit
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
// called at the start of every frame
|
// called at the start of every frame
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_StartFrame(float time)
|
int AAS_StartFrame(float time)
|
||||||
{
|
{
|
||||||
aasworld.time = time;
|
aasworld.time = time;
|
||||||
//unlink all entities that were not updated last frame
|
//unlink all entities that were not updated last frame
|
||||||
AAS_UnlinkInvalidEntities();
|
AAS_UnlinkInvalidEntities();
|
||||||
//invalidate the entities
|
//invalidate the entities
|
||||||
AAS_InvalidateEntities();
|
AAS_InvalidateEntities();
|
||||||
//initialize AAS
|
//initialize AAS
|
||||||
AAS_ContinueInit(time);
|
AAS_ContinueInit(time);
|
||||||
//
|
//
|
||||||
aasworld.frameroutingupdates = 0;
|
aasworld.frameroutingupdates = 0;
|
||||||
//
|
//
|
||||||
if (bot_developer)
|
if (bot_developer)
|
||||||
{
|
{
|
||||||
if (LibVarGetValue("showcacheupdates"))
|
if (LibVarGetValue("showcacheupdates"))
|
||||||
{
|
{
|
||||||
AAS_RoutingInfo();
|
AAS_RoutingInfo();
|
||||||
LibVarSet("showcacheupdates", "0");
|
LibVarSet("showcacheupdates", "0");
|
||||||
} //end if
|
} //end if
|
||||||
if (LibVarGetValue("showmemoryusage"))
|
if (LibVarGetValue("showmemoryusage"))
|
||||||
{
|
{
|
||||||
PrintUsedMemorySize();
|
PrintUsedMemorySize();
|
||||||
LibVarSet("showmemoryusage", "0");
|
LibVarSet("showmemoryusage", "0");
|
||||||
} //end if
|
} //end if
|
||||||
if (LibVarGetValue("memorydump"))
|
if (LibVarGetValue("memorydump"))
|
||||||
{
|
{
|
||||||
PrintMemoryLabels();
|
PrintMemoryLabels();
|
||||||
LibVarSet("memorydump", "0");
|
LibVarSet("memorydump", "0");
|
||||||
} //end if
|
} //end if
|
||||||
} //end if
|
} //end if
|
||||||
//
|
//
|
||||||
if (saveroutingcache->value)
|
if (saveroutingcache->value)
|
||||||
{
|
{
|
||||||
AAS_WriteRouteCache();
|
AAS_WriteRouteCache();
|
||||||
LibVarSet("saveroutingcache", "0");
|
LibVarSet("saveroutingcache", "0");
|
||||||
} //end if
|
} //end if
|
||||||
//
|
//
|
||||||
aasworld.numframes++;
|
aasworld.numframes++;
|
||||||
return BLERR_NOERROR;
|
return BLERR_NOERROR;
|
||||||
} //end of the function AAS_StartFrame
|
} //end of the function AAS_StartFrame
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
float AAS_Time(void)
|
float AAS_Time(void)
|
||||||
{
|
{
|
||||||
return aasworld.time;
|
return aasworld.time;
|
||||||
} //end of the function AAS_Time
|
} //end of the function AAS_Time
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_ProjectPointOntoVector( vec3_t point, vec3_t vStart, vec3_t vEnd, vec3_t vProj )
|
void AAS_ProjectPointOntoVector( vec3_t point, vec3_t vStart, vec3_t vEnd, vec3_t vProj )
|
||||||
{
|
{
|
||||||
vec3_t pVec, vec;
|
vec3_t pVec, vec;
|
||||||
|
|
||||||
VectorSubtract( point, vStart, pVec );
|
VectorSubtract( point, vStart, pVec );
|
||||||
VectorSubtract( vEnd, vStart, vec );
|
VectorSubtract( vEnd, vStart, vec );
|
||||||
VectorNormalize( vec );
|
VectorNormalize( vec );
|
||||||
// project onto the directional vector for this segment
|
// project onto the directional vector for this segment
|
||||||
VectorMA( vStart, DotProduct( pVec, vec ), vec, vProj );
|
VectorMA( vStart, DotProduct( pVec, vec ), vec, vProj );
|
||||||
} //end of the function AAS_ProjectPointOntoVector
|
} //end of the function AAS_ProjectPointOntoVector
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_LoadFiles(const char *mapname)
|
int AAS_LoadFiles(const char *mapname)
|
||||||
{
|
{
|
||||||
int errnum;
|
int errnum;
|
||||||
char aasfile[MAX_PATH];
|
char aasfile[MAX_PATH];
|
||||||
// char bspfile[MAX_PATH];
|
// char bspfile[MAX_PATH];
|
||||||
|
|
||||||
strcpy(aasworld.mapname, mapname);
|
strcpy(aasworld.mapname, mapname);
|
||||||
//NOTE: first reset the entity links into the AAS areas and BSP leaves
|
//NOTE: first reset the entity links into the AAS areas and BSP leaves
|
||||||
// the AAS link heap and BSP link heap are reset after respectively the
|
// the AAS link heap and BSP link heap are reset after respectively the
|
||||||
// AAS file and BSP file are loaded
|
// AAS file and BSP file are loaded
|
||||||
AAS_ResetEntityLinks();
|
AAS_ResetEntityLinks();
|
||||||
// load bsp info
|
// load bsp info
|
||||||
AAS_LoadBSPFile();
|
AAS_LoadBSPFile();
|
||||||
|
|
||||||
//load the aas file
|
//load the aas file
|
||||||
Com_sprintf(aasfile, MAX_PATH, "maps/%s.aas", mapname);
|
Com_sprintf(aasfile, MAX_PATH, "maps/%s.aas", mapname);
|
||||||
errnum = AAS_LoadAASFile(aasfile);
|
errnum = AAS_LoadAASFile(aasfile);
|
||||||
if (errnum != BLERR_NOERROR)
|
if (errnum != BLERR_NOERROR)
|
||||||
return errnum;
|
return errnum;
|
||||||
|
|
||||||
botimport.Print(PRT_MESSAGE, "loaded %s\n", aasfile);
|
botimport.Print(PRT_MESSAGE, "loaded %s\n", aasfile);
|
||||||
strncpy(aasworld.filename, aasfile, MAX_PATH);
|
strncpy(aasworld.filename, aasfile, MAX_PATH);
|
||||||
return BLERR_NOERROR;
|
return BLERR_NOERROR;
|
||||||
} //end of the function AAS_LoadFiles
|
} //end of the function AAS_LoadFiles
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
// called everytime a map changes
|
// called everytime a map changes
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_LoadMap(const char *mapname)
|
int AAS_LoadMap(const char *mapname)
|
||||||
{
|
{
|
||||||
int errnum;
|
int errnum;
|
||||||
|
|
||||||
//if no mapname is provided then the string indexes are updated
|
//if no mapname is provided then the string indexes are updated
|
||||||
if (!mapname)
|
if (!mapname)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
} //end if
|
} //end if
|
||||||
//
|
//
|
||||||
aasworld.initialized = qfalse;
|
aasworld.initialized = qfalse;
|
||||||
//NOTE: free the routing caches before loading a new map because
|
//NOTE: free the routing caches before loading a new map because
|
||||||
// to free the caches the old number of areas, number of clusters
|
// to free the caches the old number of areas, number of clusters
|
||||||
// and number of areas in a clusters must be available
|
// and number of areas in a clusters must be available
|
||||||
AAS_FreeRoutingCaches();
|
AAS_FreeRoutingCaches();
|
||||||
//load the map
|
//load the map
|
||||||
errnum = AAS_LoadFiles(mapname);
|
errnum = AAS_LoadFiles(mapname);
|
||||||
if (errnum != BLERR_NOERROR)
|
if (errnum != BLERR_NOERROR)
|
||||||
{
|
{
|
||||||
aasworld.loaded = qfalse;
|
aasworld.loaded = qfalse;
|
||||||
return errnum;
|
return errnum;
|
||||||
} //end if
|
} //end if
|
||||||
//
|
//
|
||||||
AAS_InitSettings();
|
AAS_InitSettings();
|
||||||
//initialize the AAS link heap for the new map
|
//initialize the AAS link heap for the new map
|
||||||
AAS_InitAASLinkHeap();
|
AAS_InitAASLinkHeap();
|
||||||
//initialize the AAS linked entities for the new map
|
//initialize the AAS linked entities for the new map
|
||||||
AAS_InitAASLinkedEntities();
|
AAS_InitAASLinkedEntities();
|
||||||
//initialize reachability for the new map
|
//initialize reachability for the new map
|
||||||
AAS_InitReachability();
|
AAS_InitReachability();
|
||||||
//initialize the alternative routing
|
//initialize the alternative routing
|
||||||
AAS_InitAlternativeRouting();
|
AAS_InitAlternativeRouting();
|
||||||
//everything went ok
|
//everything went ok
|
||||||
return 0;
|
return 0;
|
||||||
} //end of the function AAS_LoadMap
|
} //end of the function AAS_LoadMap
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
// called when the library is first loaded
|
// called when the library is first loaded
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_Setup(void)
|
int AAS_Setup(void)
|
||||||
{
|
{
|
||||||
aasworld.maxclients = (int) LibVarValue("maxclients", "128");
|
aasworld.maxclients = (int) LibVarValue("maxclients", "128");
|
||||||
aasworld.maxentities = (int) LibVarValue("maxentities", "1024");
|
aasworld.maxentities = (int) LibVarValue("maxentities", "1024");
|
||||||
// as soon as it's set to 1 the routing cache will be saved
|
// as soon as it's set to 1 the routing cache will be saved
|
||||||
saveroutingcache = LibVar("saveroutingcache", "0");
|
saveroutingcache = LibVar("saveroutingcache", "0");
|
||||||
//allocate memory for the entities
|
//allocate memory for the entities
|
||||||
if (aasworld.entities) FreeMemory(aasworld.entities);
|
if (aasworld.entities) FreeMemory(aasworld.entities);
|
||||||
aasworld.entities = (aas_entity_t *) GetClearedHunkMemory(aasworld.maxentities * sizeof(aas_entity_t));
|
aasworld.entities = (aas_entity_t *) GetClearedHunkMemory(aasworld.maxentities * sizeof(aas_entity_t));
|
||||||
//invalidate all the entities
|
//invalidate all the entities
|
||||||
AAS_InvalidateEntities();
|
AAS_InvalidateEntities();
|
||||||
//force some recalculations
|
//force some recalculations
|
||||||
//LibVarSet("forceclustering", "1"); //force clustering calculation
|
//LibVarSet("forceclustering", "1"); //force clustering calculation
|
||||||
//LibVarSet("forcereachability", "1"); //force reachability calculation
|
//LibVarSet("forcereachability", "1"); //force reachability calculation
|
||||||
aasworld.numframes = 0;
|
aasworld.numframes = 0;
|
||||||
return BLERR_NOERROR;
|
return BLERR_NOERROR;
|
||||||
} //end of the function AAS_Setup
|
} //end of the function AAS_Setup
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_Shutdown(void)
|
void AAS_Shutdown(void)
|
||||||
{
|
{
|
||||||
AAS_ShutdownAlternativeRouting();
|
AAS_ShutdownAlternativeRouting();
|
||||||
//
|
//
|
||||||
AAS_DumpBSPData();
|
AAS_DumpBSPData();
|
||||||
//free routing caches
|
//free routing caches
|
||||||
AAS_FreeRoutingCaches();
|
AAS_FreeRoutingCaches();
|
||||||
//free aas link heap
|
//free aas link heap
|
||||||
AAS_FreeAASLinkHeap();
|
AAS_FreeAASLinkHeap();
|
||||||
//free aas linked entities
|
//free aas linked entities
|
||||||
AAS_FreeAASLinkedEntities();
|
AAS_FreeAASLinkedEntities();
|
||||||
//free the aas data
|
//free the aas data
|
||||||
AAS_DumpAASData();
|
AAS_DumpAASData();
|
||||||
//free the entities
|
//free the entities
|
||||||
if (aasworld.entities) FreeMemory(aasworld.entities);
|
if (aasworld.entities) FreeMemory(aasworld.entities);
|
||||||
//clear the aasworld structure
|
//clear the aasworld structure
|
||||||
Com_Memset(&aasworld, 0, sizeof(aas_t));
|
Com_Memset(&aasworld, 0, sizeof(aas_t));
|
||||||
//aas has not been initialized
|
//aas has not been initialized
|
||||||
aasworld.initialized = qfalse;
|
aasworld.initialized = qfalse;
|
||||||
//NOTE: as soon as a new .bsp file is loaded the .bsp file memory is
|
//NOTE: as soon as a new .bsp file is loaded the .bsp file memory is
|
||||||
// freed an reallocated, so there's no need to free that memory here
|
// freed an reallocated, so there's no need to free that memory here
|
||||||
//print shutdown
|
//print shutdown
|
||||||
botimport.Print(PRT_MESSAGE, "AAS shutdown.\n");
|
botimport.Print(PRT_MESSAGE, "AAS shutdown.\n");
|
||||||
} //end of the function AAS_Shutdown
|
} //end of the function AAS_Shutdown
|
||||||
|
|
|
||||||
|
|
@ -1,61 +1,61 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: be_aas_main.h
|
* name: be_aas_main.h
|
||||||
*
|
*
|
||||||
* desc: AAS
|
* desc: AAS
|
||||||
*
|
*
|
||||||
* $Archive: /source/code/botlib/be_aas_main.h $
|
* $Archive: /source/code/botlib/be_aas_main.h $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#ifdef AASINTERN
|
#ifdef AASINTERN
|
||||||
|
|
||||||
extern aas_t aasworld;
|
extern aas_t aasworld;
|
||||||
|
|
||||||
//AAS error message
|
//AAS error message
|
||||||
void QDECL AAS_Error(char *fmt, ...);
|
void QDECL AAS_Error(char *fmt, ...);
|
||||||
//set AAS initialized
|
//set AAS initialized
|
||||||
void AAS_SetInitialized(void);
|
void AAS_SetInitialized(void);
|
||||||
//setup AAS with the given number of entities and clients
|
//setup AAS with the given number of entities and clients
|
||||||
int AAS_Setup(void);
|
int AAS_Setup(void);
|
||||||
//shutdown AAS
|
//shutdown AAS
|
||||||
void AAS_Shutdown(void);
|
void AAS_Shutdown(void);
|
||||||
//start a new map
|
//start a new map
|
||||||
int AAS_LoadMap(const char *mapname);
|
int AAS_LoadMap(const char *mapname);
|
||||||
//start a new time frame
|
//start a new time frame
|
||||||
int AAS_StartFrame(float time);
|
int AAS_StartFrame(float time);
|
||||||
#endif //AASINTERN
|
#endif //AASINTERN
|
||||||
|
|
||||||
//returns true if AAS is initialized
|
//returns true if AAS is initialized
|
||||||
int AAS_Initialized(void);
|
int AAS_Initialized(void);
|
||||||
//returns true if the AAS file is loaded
|
//returns true if the AAS file is loaded
|
||||||
int AAS_Loaded(void);
|
int AAS_Loaded(void);
|
||||||
//returns the model name from the given index
|
//returns the model name from the given index
|
||||||
char *AAS_ModelFromIndex(int index);
|
char *AAS_ModelFromIndex(int index);
|
||||||
//returns the index from the given model name
|
//returns the index from the given model name
|
||||||
int AAS_IndexFromModel(char *modelname);
|
int AAS_IndexFromModel(char *modelname);
|
||||||
//returns the current time
|
//returns the current time
|
||||||
float AAS_Time(void);
|
float AAS_Time(void);
|
||||||
//
|
//
|
||||||
void AAS_ProjectPointOntoVector( vec3_t point, vec3_t vStart, vec3_t vEnd, vec3_t vProj );
|
void AAS_ProjectPointOntoVector( vec3_t point, vec3_t vStart, vec3_t vEnd, vec3_t vProj );
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,71 +1,71 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: be_aas_move.h
|
* name: be_aas_move.h
|
||||||
*
|
*
|
||||||
* desc: AAS
|
* desc: AAS
|
||||||
*
|
*
|
||||||
* $Archive: /source/code/botlib/be_aas_move.h $
|
* $Archive: /source/code/botlib/be_aas_move.h $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#ifdef AASINTERN
|
#ifdef AASINTERN
|
||||||
extern aas_settings_t aassettings;
|
extern aas_settings_t aassettings;
|
||||||
#endif //AASINTERN
|
#endif //AASINTERN
|
||||||
|
|
||||||
//movement prediction
|
//movement prediction
|
||||||
int AAS_PredictClientMovement(struct aas_clientmove_s *move,
|
int AAS_PredictClientMovement(struct aas_clientmove_s *move,
|
||||||
int entnum, vec3_t origin,
|
int entnum, vec3_t origin,
|
||||||
int presencetype, int onground,
|
int presencetype, int onground,
|
||||||
vec3_t velocity, vec3_t cmdmove,
|
vec3_t velocity, vec3_t cmdmove,
|
||||||
int cmdframes,
|
int cmdframes,
|
||||||
int maxframes, float frametime,
|
int maxframes, float frametime,
|
||||||
int stopevent, int stopareanum, int visualize);
|
int stopevent, int stopareanum, int visualize);
|
||||||
//predict movement until bounding box is hit
|
//predict movement until bounding box is hit
|
||||||
int AAS_ClientMovementHitBBox(struct aas_clientmove_s *move,
|
int AAS_ClientMovementHitBBox(struct aas_clientmove_s *move,
|
||||||
int entnum, vec3_t origin,
|
int entnum, vec3_t origin,
|
||||||
int presencetype, int onground,
|
int presencetype, int onground,
|
||||||
vec3_t velocity, vec3_t cmdmove,
|
vec3_t velocity, vec3_t cmdmove,
|
||||||
int cmdframes,
|
int cmdframes,
|
||||||
int maxframes, float frametime,
|
int maxframes, float frametime,
|
||||||
vec3_t mins, vec3_t maxs, int visualize);
|
vec3_t mins, vec3_t maxs, int visualize);
|
||||||
//returns true if on the ground at the given origin
|
//returns true if on the ground at the given origin
|
||||||
int AAS_OnGround(vec3_t origin, int presencetype, int passent);
|
int AAS_OnGround(vec3_t origin, int presencetype, int passent);
|
||||||
//returns true if swimming at the given origin
|
//returns true if swimming at the given origin
|
||||||
int AAS_Swimming(vec3_t origin);
|
int AAS_Swimming(vec3_t origin);
|
||||||
//returns the jump reachability run start point
|
//returns the jump reachability run start point
|
||||||
void AAS_JumpReachRunStart(struct aas_reachability_s *reach, vec3_t runstart);
|
void AAS_JumpReachRunStart(struct aas_reachability_s *reach, vec3_t runstart);
|
||||||
//returns true if against a ladder at the given origin
|
//returns true if against a ladder at the given origin
|
||||||
int AAS_AgainstLadder(vec3_t origin);
|
int AAS_AgainstLadder(vec3_t origin);
|
||||||
//rocket jump Z velocity when rocket-jumping at origin
|
//rocket jump Z velocity when rocket-jumping at origin
|
||||||
float AAS_RocketJumpZVelocity(vec3_t origin);
|
float AAS_RocketJumpZVelocity(vec3_t origin);
|
||||||
//bfg jump Z velocity when bfg-jumping at origin
|
//bfg jump Z velocity when bfg-jumping at origin
|
||||||
float AAS_BFGJumpZVelocity(vec3_t origin);
|
float AAS_BFGJumpZVelocity(vec3_t origin);
|
||||||
//calculates the horizontal velocity needed for a jump and returns true this velocity could be calculated
|
//calculates the horizontal velocity needed for a jump and returns true this velocity could be calculated
|
||||||
int AAS_HorizontalVelocityForJump(float zvel, vec3_t start, vec3_t end, float *velocity);
|
int AAS_HorizontalVelocityForJump(float zvel, vec3_t start, vec3_t end, float *velocity);
|
||||||
//
|
//
|
||||||
void AAS_SetMovedir(vec3_t angles, vec3_t movedir);
|
void AAS_SetMovedir(vec3_t angles, vec3_t movedir);
|
||||||
//
|
//
|
||||||
int AAS_DropToFloor(vec3_t origin, vec3_t mins, vec3_t maxs);
|
int AAS_DropToFloor(vec3_t origin, vec3_t mins, vec3_t maxs);
|
||||||
//
|
//
|
||||||
void AAS_InitSettings(void);
|
void AAS_InitSettings(void);
|
||||||
|
|
|
||||||
|
|
@ -1,312 +1,312 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: be_aas_optimize.c
|
* name: be_aas_optimize.c
|
||||||
*
|
*
|
||||||
* desc: decreases the .aas file size after the reachabilities have
|
* desc: decreases the .aas file size after the reachabilities have
|
||||||
* been calculated, just dumps all the faces, edges and vertexes
|
* been calculated, just dumps all the faces, edges and vertexes
|
||||||
*
|
*
|
||||||
* $Archive: /MissionPack/code/botlib/be_aas_optimize.c $
|
* $Archive: /MissionPack/code/botlib/be_aas_optimize.c $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "../game/q_shared.h"
|
#include "../game/q_shared.h"
|
||||||
#include "l_libvar.h"
|
#include "l_libvar.h"
|
||||||
#include "l_memory.h"
|
#include "l_memory.h"
|
||||||
#include "l_script.h"
|
#include "l_script.h"
|
||||||
#include "l_precomp.h"
|
#include "l_precomp.h"
|
||||||
#include "l_struct.h"
|
#include "l_struct.h"
|
||||||
#include "aasfile.h"
|
#include "aasfile.h"
|
||||||
#include "../game/botlib.h"
|
#include "../game/botlib.h"
|
||||||
#include "../game/be_aas.h"
|
#include "../game/be_aas.h"
|
||||||
#include "be_aas_funcs.h"
|
#include "be_aas_funcs.h"
|
||||||
#include "be_interface.h"
|
#include "be_interface.h"
|
||||||
#include "be_aas_def.h"
|
#include "be_aas_def.h"
|
||||||
|
|
||||||
typedef struct optimized_s
|
typedef struct optimized_s
|
||||||
{
|
{
|
||||||
//vertexes
|
//vertexes
|
||||||
int numvertexes;
|
int numvertexes;
|
||||||
aas_vertex_t *vertexes;
|
aas_vertex_t *vertexes;
|
||||||
//edges
|
//edges
|
||||||
int numedges;
|
int numedges;
|
||||||
aas_edge_t *edges;
|
aas_edge_t *edges;
|
||||||
//edge index
|
//edge index
|
||||||
int edgeindexsize;
|
int edgeindexsize;
|
||||||
aas_edgeindex_t *edgeindex;
|
aas_edgeindex_t *edgeindex;
|
||||||
//faces
|
//faces
|
||||||
int numfaces;
|
int numfaces;
|
||||||
aas_face_t *faces;
|
aas_face_t *faces;
|
||||||
//face index
|
//face index
|
||||||
int faceindexsize;
|
int faceindexsize;
|
||||||
aas_faceindex_t *faceindex;
|
aas_faceindex_t *faceindex;
|
||||||
//convex areas
|
//convex areas
|
||||||
int numareas;
|
int numareas;
|
||||||
aas_area_t *areas;
|
aas_area_t *areas;
|
||||||
//
|
//
|
||||||
int *vertexoptimizeindex;
|
int *vertexoptimizeindex;
|
||||||
int *edgeoptimizeindex;
|
int *edgeoptimizeindex;
|
||||||
int *faceoptimizeindex;
|
int *faceoptimizeindex;
|
||||||
} optimized_t;
|
} optimized_t;
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_KeepEdge(aas_edge_t *edge)
|
int AAS_KeepEdge(aas_edge_t *edge)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
} //end of the function AAS_KeepFace
|
} //end of the function AAS_KeepFace
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_OptimizeEdge(optimized_t *optimized, int edgenum)
|
int AAS_OptimizeEdge(optimized_t *optimized, int edgenum)
|
||||||
{
|
{
|
||||||
int i, optedgenum;
|
int i, optedgenum;
|
||||||
aas_edge_t *edge, *optedge;
|
aas_edge_t *edge, *optedge;
|
||||||
|
|
||||||
edge = &aasworld.edges[abs(edgenum)];
|
edge = &aasworld.edges[abs(edgenum)];
|
||||||
if (!AAS_KeepEdge(edge)) return 0;
|
if (!AAS_KeepEdge(edge)) return 0;
|
||||||
|
|
||||||
optedgenum = optimized->edgeoptimizeindex[abs(edgenum)];
|
optedgenum = optimized->edgeoptimizeindex[abs(edgenum)];
|
||||||
if (optedgenum)
|
if (optedgenum)
|
||||||
{
|
{
|
||||||
//keep the edge reversed sign
|
//keep the edge reversed sign
|
||||||
if (edgenum > 0) return optedgenum;
|
if (edgenum > 0) return optedgenum;
|
||||||
else return -optedgenum;
|
else return -optedgenum;
|
||||||
} //end if
|
} //end if
|
||||||
|
|
||||||
optedge = &optimized->edges[optimized->numedges];
|
optedge = &optimized->edges[optimized->numedges];
|
||||||
|
|
||||||
for (i = 0; i < 2; i++)
|
for (i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
if (optimized->vertexoptimizeindex[edge->v[i]])
|
if (optimized->vertexoptimizeindex[edge->v[i]])
|
||||||
{
|
{
|
||||||
optedge->v[i] = optimized->vertexoptimizeindex[edge->v[i]];
|
optedge->v[i] = optimized->vertexoptimizeindex[edge->v[i]];
|
||||||
} //end if
|
} //end if
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
VectorCopy(aasworld.vertexes[edge->v[i]], optimized->vertexes[optimized->numvertexes]);
|
VectorCopy(aasworld.vertexes[edge->v[i]], optimized->vertexes[optimized->numvertexes]);
|
||||||
optedge->v[i] = optimized->numvertexes;
|
optedge->v[i] = optimized->numvertexes;
|
||||||
optimized->vertexoptimizeindex[edge->v[i]] = optimized->numvertexes;
|
optimized->vertexoptimizeindex[edge->v[i]] = optimized->numvertexes;
|
||||||
optimized->numvertexes++;
|
optimized->numvertexes++;
|
||||||
} //end else
|
} //end else
|
||||||
} //end for
|
} //end for
|
||||||
optimized->edgeoptimizeindex[abs(edgenum)] = optimized->numedges;
|
optimized->edgeoptimizeindex[abs(edgenum)] = optimized->numedges;
|
||||||
optedgenum = optimized->numedges;
|
optedgenum = optimized->numedges;
|
||||||
optimized->numedges++;
|
optimized->numedges++;
|
||||||
//keep the edge reversed sign
|
//keep the edge reversed sign
|
||||||
if (edgenum > 0) return optedgenum;
|
if (edgenum > 0) return optedgenum;
|
||||||
else return -optedgenum;
|
else return -optedgenum;
|
||||||
} //end of the function AAS_OptimizeEdge
|
} //end of the function AAS_OptimizeEdge
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_KeepFace(aas_face_t *face)
|
int AAS_KeepFace(aas_face_t *face)
|
||||||
{
|
{
|
||||||
if (!(face->faceflags & FACE_LADDER)) return 0;
|
if (!(face->faceflags & FACE_LADDER)) return 0;
|
||||||
else return 1;
|
else return 1;
|
||||||
} //end of the function AAS_KeepFace
|
} //end of the function AAS_KeepFace
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_OptimizeFace(optimized_t *optimized, int facenum)
|
int AAS_OptimizeFace(optimized_t *optimized, int facenum)
|
||||||
{
|
{
|
||||||
int i, edgenum, optedgenum, optfacenum;
|
int i, edgenum, optedgenum, optfacenum;
|
||||||
aas_face_t *face, *optface;
|
aas_face_t *face, *optface;
|
||||||
|
|
||||||
face = &aasworld.faces[abs(facenum)];
|
face = &aasworld.faces[abs(facenum)];
|
||||||
if (!AAS_KeepFace(face)) return 0;
|
if (!AAS_KeepFace(face)) return 0;
|
||||||
|
|
||||||
optfacenum = optimized->faceoptimizeindex[abs(facenum)];
|
optfacenum = optimized->faceoptimizeindex[abs(facenum)];
|
||||||
if (optfacenum)
|
if (optfacenum)
|
||||||
{
|
{
|
||||||
//keep the face side sign
|
//keep the face side sign
|
||||||
if (facenum > 0) return optfacenum;
|
if (facenum > 0) return optfacenum;
|
||||||
else return -optfacenum;
|
else return -optfacenum;
|
||||||
} //end if
|
} //end if
|
||||||
|
|
||||||
optface = &optimized->faces[optimized->numfaces];
|
optface = &optimized->faces[optimized->numfaces];
|
||||||
Com_Memcpy(optface, face, sizeof(aas_face_t));
|
Com_Memcpy(optface, face, sizeof(aas_face_t));
|
||||||
|
|
||||||
optface->numedges = 0;
|
optface->numedges = 0;
|
||||||
optface->firstedge = optimized->edgeindexsize;
|
optface->firstedge = optimized->edgeindexsize;
|
||||||
for (i = 0; i < face->numedges; i++)
|
for (i = 0; i < face->numedges; i++)
|
||||||
{
|
{
|
||||||
edgenum = aasworld.edgeindex[face->firstedge + i];
|
edgenum = aasworld.edgeindex[face->firstedge + i];
|
||||||
optedgenum = AAS_OptimizeEdge(optimized, edgenum);
|
optedgenum = AAS_OptimizeEdge(optimized, edgenum);
|
||||||
if (optedgenum)
|
if (optedgenum)
|
||||||
{
|
{
|
||||||
optimized->edgeindex[optface->firstedge + optface->numedges] = optedgenum;
|
optimized->edgeindex[optface->firstedge + optface->numedges] = optedgenum;
|
||||||
optface->numedges++;
|
optface->numedges++;
|
||||||
optimized->edgeindexsize++;
|
optimized->edgeindexsize++;
|
||||||
} //end if
|
} //end if
|
||||||
} //end for
|
} //end for
|
||||||
optimized->faceoptimizeindex[abs(facenum)] = optimized->numfaces;
|
optimized->faceoptimizeindex[abs(facenum)] = optimized->numfaces;
|
||||||
optfacenum = optimized->numfaces;
|
optfacenum = optimized->numfaces;
|
||||||
optimized->numfaces++;
|
optimized->numfaces++;
|
||||||
//keep the face side sign
|
//keep the face side sign
|
||||||
if (facenum > 0) return optfacenum;
|
if (facenum > 0) return optfacenum;
|
||||||
else return -optfacenum;
|
else return -optfacenum;
|
||||||
} //end of the function AAS_OptimizeFace
|
} //end of the function AAS_OptimizeFace
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_OptimizeArea(optimized_t *optimized, int areanum)
|
void AAS_OptimizeArea(optimized_t *optimized, int areanum)
|
||||||
{
|
{
|
||||||
int i, facenum, optfacenum;
|
int i, facenum, optfacenum;
|
||||||
aas_area_t *area, *optarea;
|
aas_area_t *area, *optarea;
|
||||||
|
|
||||||
area = &aasworld.areas[areanum];
|
area = &aasworld.areas[areanum];
|
||||||
optarea = &optimized->areas[areanum];
|
optarea = &optimized->areas[areanum];
|
||||||
Com_Memcpy(optarea, area, sizeof(aas_area_t));
|
Com_Memcpy(optarea, area, sizeof(aas_area_t));
|
||||||
|
|
||||||
optarea->numfaces = 0;
|
optarea->numfaces = 0;
|
||||||
optarea->firstface = optimized->faceindexsize;
|
optarea->firstface = optimized->faceindexsize;
|
||||||
for (i = 0; i < area->numfaces; i++)
|
for (i = 0; i < area->numfaces; i++)
|
||||||
{
|
{
|
||||||
facenum = aasworld.faceindex[area->firstface + i];
|
facenum = aasworld.faceindex[area->firstface + i];
|
||||||
optfacenum = AAS_OptimizeFace(optimized, facenum);
|
optfacenum = AAS_OptimizeFace(optimized, facenum);
|
||||||
if (optfacenum)
|
if (optfacenum)
|
||||||
{
|
{
|
||||||
optimized->faceindex[optarea->firstface + optarea->numfaces] = optfacenum;
|
optimized->faceindex[optarea->firstface + optarea->numfaces] = optfacenum;
|
||||||
optarea->numfaces++;
|
optarea->numfaces++;
|
||||||
optimized->faceindexsize++;
|
optimized->faceindexsize++;
|
||||||
} //end if
|
} //end if
|
||||||
} //end for
|
} //end for
|
||||||
} //end of the function AAS_OptimizeArea
|
} //end of the function AAS_OptimizeArea
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_OptimizeAlloc(optimized_t *optimized)
|
void AAS_OptimizeAlloc(optimized_t *optimized)
|
||||||
{
|
{
|
||||||
optimized->vertexes = (aas_vertex_t *) GetClearedMemory(aasworld.numvertexes * sizeof(aas_vertex_t));
|
optimized->vertexes = (aas_vertex_t *) GetClearedMemory(aasworld.numvertexes * sizeof(aas_vertex_t));
|
||||||
optimized->numvertexes = 0;
|
optimized->numvertexes = 0;
|
||||||
optimized->edges = (aas_edge_t *) GetClearedMemory(aasworld.numedges * sizeof(aas_edge_t));
|
optimized->edges = (aas_edge_t *) GetClearedMemory(aasworld.numedges * sizeof(aas_edge_t));
|
||||||
optimized->numedges = 1; //edge zero is a dummy
|
optimized->numedges = 1; //edge zero is a dummy
|
||||||
optimized->edgeindex = (aas_edgeindex_t *) GetClearedMemory(aasworld.edgeindexsize * sizeof(aas_edgeindex_t));
|
optimized->edgeindex = (aas_edgeindex_t *) GetClearedMemory(aasworld.edgeindexsize * sizeof(aas_edgeindex_t));
|
||||||
optimized->edgeindexsize = 0;
|
optimized->edgeindexsize = 0;
|
||||||
optimized->faces = (aas_face_t *) GetClearedMemory(aasworld.numfaces * sizeof(aas_face_t));
|
optimized->faces = (aas_face_t *) GetClearedMemory(aasworld.numfaces * sizeof(aas_face_t));
|
||||||
optimized->numfaces = 1; //face zero is a dummy
|
optimized->numfaces = 1; //face zero is a dummy
|
||||||
optimized->faceindex = (aas_faceindex_t *) GetClearedMemory(aasworld.faceindexsize * sizeof(aas_faceindex_t));
|
optimized->faceindex = (aas_faceindex_t *) GetClearedMemory(aasworld.faceindexsize * sizeof(aas_faceindex_t));
|
||||||
optimized->faceindexsize = 0;
|
optimized->faceindexsize = 0;
|
||||||
optimized->areas = (aas_area_t *) GetClearedMemory(aasworld.numareas * sizeof(aas_area_t));
|
optimized->areas = (aas_area_t *) GetClearedMemory(aasworld.numareas * sizeof(aas_area_t));
|
||||||
optimized->numareas = aasworld.numareas;
|
optimized->numareas = aasworld.numareas;
|
||||||
//
|
//
|
||||||
optimized->vertexoptimizeindex = (int *) GetClearedMemory(aasworld.numvertexes * sizeof(int));
|
optimized->vertexoptimizeindex = (int *) GetClearedMemory(aasworld.numvertexes * sizeof(int));
|
||||||
optimized->edgeoptimizeindex = (int *) GetClearedMemory(aasworld.numedges * sizeof(int));
|
optimized->edgeoptimizeindex = (int *) GetClearedMemory(aasworld.numedges * sizeof(int));
|
||||||
optimized->faceoptimizeindex = (int *) GetClearedMemory(aasworld.numfaces * sizeof(int));
|
optimized->faceoptimizeindex = (int *) GetClearedMemory(aasworld.numfaces * sizeof(int));
|
||||||
} //end of the function AAS_OptimizeAlloc
|
} //end of the function AAS_OptimizeAlloc
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_OptimizeStore(optimized_t *optimized)
|
void AAS_OptimizeStore(optimized_t *optimized)
|
||||||
{
|
{
|
||||||
//store the optimized vertexes
|
//store the optimized vertexes
|
||||||
if (aasworld.vertexes) FreeMemory(aasworld.vertexes);
|
if (aasworld.vertexes) FreeMemory(aasworld.vertexes);
|
||||||
aasworld.vertexes = optimized->vertexes;
|
aasworld.vertexes = optimized->vertexes;
|
||||||
aasworld.numvertexes = optimized->numvertexes;
|
aasworld.numvertexes = optimized->numvertexes;
|
||||||
//store the optimized edges
|
//store the optimized edges
|
||||||
if (aasworld.edges) FreeMemory(aasworld.edges);
|
if (aasworld.edges) FreeMemory(aasworld.edges);
|
||||||
aasworld.edges = optimized->edges;
|
aasworld.edges = optimized->edges;
|
||||||
aasworld.numedges = optimized->numedges;
|
aasworld.numedges = optimized->numedges;
|
||||||
//store the optimized edge index
|
//store the optimized edge index
|
||||||
if (aasworld.edgeindex) FreeMemory(aasworld.edgeindex);
|
if (aasworld.edgeindex) FreeMemory(aasworld.edgeindex);
|
||||||
aasworld.edgeindex = optimized->edgeindex;
|
aasworld.edgeindex = optimized->edgeindex;
|
||||||
aasworld.edgeindexsize = optimized->edgeindexsize;
|
aasworld.edgeindexsize = optimized->edgeindexsize;
|
||||||
//store the optimized faces
|
//store the optimized faces
|
||||||
if (aasworld.faces) FreeMemory(aasworld.faces);
|
if (aasworld.faces) FreeMemory(aasworld.faces);
|
||||||
aasworld.faces = optimized->faces;
|
aasworld.faces = optimized->faces;
|
||||||
aasworld.numfaces = optimized->numfaces;
|
aasworld.numfaces = optimized->numfaces;
|
||||||
//store the optimized face index
|
//store the optimized face index
|
||||||
if (aasworld.faceindex) FreeMemory(aasworld.faceindex);
|
if (aasworld.faceindex) FreeMemory(aasworld.faceindex);
|
||||||
aasworld.faceindex = optimized->faceindex;
|
aasworld.faceindex = optimized->faceindex;
|
||||||
aasworld.faceindexsize = optimized->faceindexsize;
|
aasworld.faceindexsize = optimized->faceindexsize;
|
||||||
//store the optimized areas
|
//store the optimized areas
|
||||||
if (aasworld.areas) FreeMemory(aasworld.areas);
|
if (aasworld.areas) FreeMemory(aasworld.areas);
|
||||||
aasworld.areas = optimized->areas;
|
aasworld.areas = optimized->areas;
|
||||||
aasworld.numareas = optimized->numareas;
|
aasworld.numareas = optimized->numareas;
|
||||||
//free optimize indexes
|
//free optimize indexes
|
||||||
FreeMemory(optimized->vertexoptimizeindex);
|
FreeMemory(optimized->vertexoptimizeindex);
|
||||||
FreeMemory(optimized->edgeoptimizeindex);
|
FreeMemory(optimized->edgeoptimizeindex);
|
||||||
FreeMemory(optimized->faceoptimizeindex);
|
FreeMemory(optimized->faceoptimizeindex);
|
||||||
} //end of the function AAS_OptimizeStore
|
} //end of the function AAS_OptimizeStore
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_Optimize(void)
|
void AAS_Optimize(void)
|
||||||
{
|
{
|
||||||
int i, sign;
|
int i, sign;
|
||||||
optimized_t optimized;
|
optimized_t optimized;
|
||||||
|
|
||||||
AAS_OptimizeAlloc(&optimized);
|
AAS_OptimizeAlloc(&optimized);
|
||||||
for (i = 1; i < aasworld.numareas; i++)
|
for (i = 1; i < aasworld.numareas; i++)
|
||||||
{
|
{
|
||||||
AAS_OptimizeArea(&optimized, i);
|
AAS_OptimizeArea(&optimized, i);
|
||||||
} //end for
|
} //end for
|
||||||
//reset the reachability face pointers
|
//reset the reachability face pointers
|
||||||
for (i = 0; i < aasworld.reachabilitysize; i++)
|
for (i = 0; i < aasworld.reachabilitysize; i++)
|
||||||
{
|
{
|
||||||
//NOTE: for TRAVEL_ELEVATOR the facenum is the model number of
|
//NOTE: for TRAVEL_ELEVATOR the facenum is the model number of
|
||||||
// the elevator
|
// the elevator
|
||||||
if ((aasworld.reachability[i].traveltype & TRAVELTYPE_MASK) == TRAVEL_ELEVATOR) continue;
|
if ((aasworld.reachability[i].traveltype & TRAVELTYPE_MASK) == TRAVEL_ELEVATOR) continue;
|
||||||
//NOTE: for TRAVEL_JUMPPAD the facenum is the Z velocity and the edgenum is the hor velocity
|
//NOTE: for TRAVEL_JUMPPAD the facenum is the Z velocity and the edgenum is the hor velocity
|
||||||
if ((aasworld.reachability[i].traveltype & TRAVELTYPE_MASK) == TRAVEL_JUMPPAD) continue;
|
if ((aasworld.reachability[i].traveltype & TRAVELTYPE_MASK) == TRAVEL_JUMPPAD) continue;
|
||||||
//NOTE: for TRAVEL_FUNCBOB the facenum and edgenum contain other coded information
|
//NOTE: for TRAVEL_FUNCBOB the facenum and edgenum contain other coded information
|
||||||
if ((aasworld.reachability[i].traveltype & TRAVELTYPE_MASK) == TRAVEL_FUNCBOB) continue;
|
if ((aasworld.reachability[i].traveltype & TRAVELTYPE_MASK) == TRAVEL_FUNCBOB) continue;
|
||||||
//
|
//
|
||||||
sign = aasworld.reachability[i].facenum;
|
sign = aasworld.reachability[i].facenum;
|
||||||
aasworld.reachability[i].facenum = optimized.faceoptimizeindex[abs(aasworld.reachability[i].facenum)];
|
aasworld.reachability[i].facenum = optimized.faceoptimizeindex[abs(aasworld.reachability[i].facenum)];
|
||||||
if (sign < 0) aasworld.reachability[i].facenum = -aasworld.reachability[i].facenum;
|
if (sign < 0) aasworld.reachability[i].facenum = -aasworld.reachability[i].facenum;
|
||||||
sign = aasworld.reachability[i].edgenum;
|
sign = aasworld.reachability[i].edgenum;
|
||||||
aasworld.reachability[i].edgenum = optimized.edgeoptimizeindex[abs(aasworld.reachability[i].edgenum)];
|
aasworld.reachability[i].edgenum = optimized.edgeoptimizeindex[abs(aasworld.reachability[i].edgenum)];
|
||||||
if (sign < 0) aasworld.reachability[i].edgenum = -aasworld.reachability[i].edgenum;
|
if (sign < 0) aasworld.reachability[i].edgenum = -aasworld.reachability[i].edgenum;
|
||||||
} //end for
|
} //end for
|
||||||
//store the optimized AAS data into aasworld
|
//store the optimized AAS data into aasworld
|
||||||
AAS_OptimizeStore(&optimized);
|
AAS_OptimizeStore(&optimized);
|
||||||
//print some nice stuff :)
|
//print some nice stuff :)
|
||||||
botimport.Print(PRT_MESSAGE, "AAS data optimized.\n");
|
botimport.Print(PRT_MESSAGE, "AAS data optimized.\n");
|
||||||
} //end of the function AAS_Optimize
|
} //end of the function AAS_Optimize
|
||||||
|
|
|
||||||
|
|
@ -1,33 +1,33 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: be_aas_optimize.h
|
* name: be_aas_optimize.h
|
||||||
*
|
*
|
||||||
* desc: AAS
|
* desc: AAS
|
||||||
*
|
*
|
||||||
* $Archive: /source/code/botlib/be_aas_optimize.h $
|
* $Archive: /source/code/botlib/be_aas_optimize.h $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
void AAS_Optimize(void);
|
void AAS_Optimize(void);
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,68 +1,68 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: be_aas_reach.h
|
* name: be_aas_reach.h
|
||||||
*
|
*
|
||||||
* desc: AAS
|
* desc: AAS
|
||||||
*
|
*
|
||||||
* $Archive: /source/code/botlib/be_aas_reach.h $
|
* $Archive: /source/code/botlib/be_aas_reach.h $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#ifdef AASINTERN
|
#ifdef AASINTERN
|
||||||
//initialize calculating the reachabilities
|
//initialize calculating the reachabilities
|
||||||
void AAS_InitReachability(void);
|
void AAS_InitReachability(void);
|
||||||
//continue calculating the reachabilities
|
//continue calculating the reachabilities
|
||||||
int AAS_ContinueInitReachability(float time);
|
int AAS_ContinueInitReachability(float time);
|
||||||
//
|
//
|
||||||
int AAS_BestReachableLinkArea(aas_link_t *areas);
|
int AAS_BestReachableLinkArea(aas_link_t *areas);
|
||||||
#endif //AASINTERN
|
#endif //AASINTERN
|
||||||
|
|
||||||
//returns true if the are has reachabilities to other areas
|
//returns true if the are has reachabilities to other areas
|
||||||
int AAS_AreaReachability(int areanum);
|
int AAS_AreaReachability(int areanum);
|
||||||
//returns the best reachable area and goal origin for a bounding box at the given origin
|
//returns the best reachable area and goal origin for a bounding box at the given origin
|
||||||
int AAS_BestReachableArea(vec3_t origin, vec3_t mins, vec3_t maxs, vec3_t goalorigin);
|
int AAS_BestReachableArea(vec3_t origin, vec3_t mins, vec3_t maxs, vec3_t goalorigin);
|
||||||
//returns the best jumppad area from which the bbox at origin is reachable
|
//returns the best jumppad area from which the bbox at origin is reachable
|
||||||
int AAS_BestReachableFromJumpPadArea(vec3_t origin, vec3_t mins, vec3_t maxs);
|
int AAS_BestReachableFromJumpPadArea(vec3_t origin, vec3_t mins, vec3_t maxs);
|
||||||
//returns the next reachability using the given model
|
//returns the next reachability using the given model
|
||||||
int AAS_NextModelReachability(int num, int modelnum);
|
int AAS_NextModelReachability(int num, int modelnum);
|
||||||
//returns the total area of the ground faces of the given area
|
//returns the total area of the ground faces of the given area
|
||||||
float AAS_AreaGroundFaceArea(int areanum);
|
float AAS_AreaGroundFaceArea(int areanum);
|
||||||
//returns true if the area is crouch only
|
//returns true if the area is crouch only
|
||||||
int AAS_AreaCrouch(int areanum);
|
int AAS_AreaCrouch(int areanum);
|
||||||
//returns true if a player can swim in this area
|
//returns true if a player can swim in this area
|
||||||
int AAS_AreaSwim(int areanum);
|
int AAS_AreaSwim(int areanum);
|
||||||
//returns true if the area is filled with a liquid
|
//returns true if the area is filled with a liquid
|
||||||
int AAS_AreaLiquid(int areanum);
|
int AAS_AreaLiquid(int areanum);
|
||||||
//returns true if the area contains lava
|
//returns true if the area contains lava
|
||||||
int AAS_AreaLava(int areanum);
|
int AAS_AreaLava(int areanum);
|
||||||
//returns true if the area contains slime
|
//returns true if the area contains slime
|
||||||
int AAS_AreaSlime(int areanum);
|
int AAS_AreaSlime(int areanum);
|
||||||
//returns true if the area has one or more ground faces
|
//returns true if the area has one or more ground faces
|
||||||
int AAS_AreaGrounded(int areanum);
|
int AAS_AreaGrounded(int areanum);
|
||||||
//returns true if the area has one or more ladder faces
|
//returns true if the area has one or more ladder faces
|
||||||
int AAS_AreaLadder(int areanum);
|
int AAS_AreaLadder(int areanum);
|
||||||
//returns true if the area is a jump pad
|
//returns true if the area is a jump pad
|
||||||
int AAS_AreaJumpPad(int areanum);
|
int AAS_AreaJumpPad(int areanum);
|
||||||
//returns true if the area is donotenter
|
//returns true if the area is donotenter
|
||||||
int AAS_AreaDoNotEnter(int areanum);
|
int AAS_AreaDoNotEnter(int areanum);
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,67 +1,67 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: be_aas_route.h
|
* name: be_aas_route.h
|
||||||
*
|
*
|
||||||
* desc: AAS
|
* desc: AAS
|
||||||
*
|
*
|
||||||
* $Archive: /source/code/botlib/be_aas_route.h $
|
* $Archive: /source/code/botlib/be_aas_route.h $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#ifdef AASINTERN
|
#ifdef AASINTERN
|
||||||
//initialize the AAS routing
|
//initialize the AAS routing
|
||||||
void AAS_InitRouting(void);
|
void AAS_InitRouting(void);
|
||||||
//free the AAS routing caches
|
//free the AAS routing caches
|
||||||
void AAS_FreeRoutingCaches(void);
|
void AAS_FreeRoutingCaches(void);
|
||||||
//returns the travel time from start to end in the given area
|
//returns the travel time from start to end in the given area
|
||||||
unsigned short int AAS_AreaTravelTime(int areanum, vec3_t start, vec3_t end);
|
unsigned short int AAS_AreaTravelTime(int areanum, vec3_t start, vec3_t end);
|
||||||
//
|
//
|
||||||
void AAS_CreateAllRoutingCache(void);
|
void AAS_CreateAllRoutingCache(void);
|
||||||
void AAS_WriteRouteCache(void);
|
void AAS_WriteRouteCache(void);
|
||||||
//
|
//
|
||||||
void AAS_RoutingInfo(void);
|
void AAS_RoutingInfo(void);
|
||||||
#endif //AASINTERN
|
#endif //AASINTERN
|
||||||
|
|
||||||
//returns the travel flag for the given travel type
|
//returns the travel flag for the given travel type
|
||||||
int AAS_TravelFlagForType(int traveltype);
|
int AAS_TravelFlagForType(int traveltype);
|
||||||
//return the travel flag(s) for traveling through this area
|
//return the travel flag(s) for traveling through this area
|
||||||
int AAS_AreaContentsTravelFlags(int areanum);
|
int AAS_AreaContentsTravelFlags(int areanum);
|
||||||
//returns the index of the next reachability for the given area
|
//returns the index of the next reachability for the given area
|
||||||
int AAS_NextAreaReachability(int areanum, int reachnum);
|
int AAS_NextAreaReachability(int areanum, int reachnum);
|
||||||
//returns the reachability with the given index
|
//returns the reachability with the given index
|
||||||
void AAS_ReachabilityFromNum(int num, struct aas_reachability_s *reach);
|
void AAS_ReachabilityFromNum(int num, struct aas_reachability_s *reach);
|
||||||
//returns a random goal area and goal origin
|
//returns a random goal area and goal origin
|
||||||
int AAS_RandomGoalArea(int areanum, int travelflags, int *goalareanum, vec3_t goalorigin);
|
int AAS_RandomGoalArea(int areanum, int travelflags, int *goalareanum, vec3_t goalorigin);
|
||||||
//enable or disable an area for routing
|
//enable or disable an area for routing
|
||||||
int AAS_EnableRoutingArea(int areanum, int enable);
|
int AAS_EnableRoutingArea(int areanum, int enable);
|
||||||
//returns the travel time within the given area from start to end
|
//returns the travel time within the given area from start to end
|
||||||
unsigned short int AAS_AreaTravelTime(int areanum, vec3_t start, vec3_t end);
|
unsigned short int AAS_AreaTravelTime(int areanum, vec3_t start, vec3_t end);
|
||||||
//returns the travel time from the area to the goal area using the given travel flags
|
//returns the travel time from the area to the goal area using the given travel flags
|
||||||
int AAS_AreaTravelTimeToGoalArea(int areanum, vec3_t origin, int goalareanum, int travelflags);
|
int AAS_AreaTravelTimeToGoalArea(int areanum, vec3_t origin, int goalareanum, int travelflags);
|
||||||
//predict a route up to a stop event
|
//predict a route up to a stop event
|
||||||
int AAS_PredictRoute(struct aas_predictroute_s *route, int areanum, vec3_t origin,
|
int AAS_PredictRoute(struct aas_predictroute_s *route, int areanum, vec3_t origin,
|
||||||
int goalareanum, int travelflags, int maxareas, int maxtime,
|
int goalareanum, int travelflags, int maxareas, int maxtime,
|
||||||
int stopevent, int stopcontents, int stoptfl, int stopareanum);
|
int stopevent, int stopcontents, int stoptfl, int stopareanum);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,240 +1,240 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: be_aas_routealt.c
|
* name: be_aas_routealt.c
|
||||||
*
|
*
|
||||||
* desc: AAS
|
* desc: AAS
|
||||||
*
|
*
|
||||||
* $Archive: /MissionPack/code/botlib/be_aas_routealt.c $
|
* $Archive: /MissionPack/code/botlib/be_aas_routealt.c $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "../game/q_shared.h"
|
#include "../game/q_shared.h"
|
||||||
#include "l_utils.h"
|
#include "l_utils.h"
|
||||||
#include "l_memory.h"
|
#include "l_memory.h"
|
||||||
#include "l_log.h"
|
#include "l_log.h"
|
||||||
#include "l_script.h"
|
#include "l_script.h"
|
||||||
#include "l_precomp.h"
|
#include "l_precomp.h"
|
||||||
#include "l_struct.h"
|
#include "l_struct.h"
|
||||||
#include "aasfile.h"
|
#include "aasfile.h"
|
||||||
#include "../game/botlib.h"
|
#include "../game/botlib.h"
|
||||||
#include "../game/be_aas.h"
|
#include "../game/be_aas.h"
|
||||||
#include "be_aas_funcs.h"
|
#include "be_aas_funcs.h"
|
||||||
#include "be_interface.h"
|
#include "be_interface.h"
|
||||||
#include "be_aas_def.h"
|
#include "be_aas_def.h"
|
||||||
|
|
||||||
#define ENABLE_ALTROUTING
|
#define ENABLE_ALTROUTING
|
||||||
//#define ALTROUTE_DEBUG
|
//#define ALTROUTE_DEBUG
|
||||||
|
|
||||||
typedef struct midrangearea_s
|
typedef struct midrangearea_s
|
||||||
{
|
{
|
||||||
int valid;
|
int valid;
|
||||||
unsigned short starttime;
|
unsigned short starttime;
|
||||||
unsigned short goaltime;
|
unsigned short goaltime;
|
||||||
} midrangearea_t;
|
} midrangearea_t;
|
||||||
|
|
||||||
midrangearea_t *midrangeareas;
|
midrangearea_t *midrangeareas;
|
||||||
int *clusterareas;
|
int *clusterareas;
|
||||||
int numclusterareas;
|
int numclusterareas;
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_AltRoutingFloodCluster_r(int areanum)
|
void AAS_AltRoutingFloodCluster_r(int areanum)
|
||||||
{
|
{
|
||||||
int i, otherareanum;
|
int i, otherareanum;
|
||||||
aas_area_t *area;
|
aas_area_t *area;
|
||||||
aas_face_t *face;
|
aas_face_t *face;
|
||||||
|
|
||||||
//add the current area to the areas of the current cluster
|
//add the current area to the areas of the current cluster
|
||||||
clusterareas[numclusterareas] = areanum;
|
clusterareas[numclusterareas] = areanum;
|
||||||
numclusterareas++;
|
numclusterareas++;
|
||||||
//remove the area from the mid range areas
|
//remove the area from the mid range areas
|
||||||
midrangeareas[areanum].valid = qfalse;
|
midrangeareas[areanum].valid = qfalse;
|
||||||
//flood to other areas through the faces of this area
|
//flood to other areas through the faces of this area
|
||||||
area = &aasworld.areas[areanum];
|
area = &aasworld.areas[areanum];
|
||||||
for (i = 0; i < area->numfaces; i++)
|
for (i = 0; i < area->numfaces; i++)
|
||||||
{
|
{
|
||||||
face = &aasworld.faces[abs(aasworld.faceindex[area->firstface + i])];
|
face = &aasworld.faces[abs(aasworld.faceindex[area->firstface + i])];
|
||||||
//get the area at the other side of the face
|
//get the area at the other side of the face
|
||||||
if (face->frontarea == areanum) otherareanum = face->backarea;
|
if (face->frontarea == areanum) otherareanum = face->backarea;
|
||||||
else otherareanum = face->frontarea;
|
else otherareanum = face->frontarea;
|
||||||
//if there is an area at the other side of this face
|
//if there is an area at the other side of this face
|
||||||
if (!otherareanum) continue;
|
if (!otherareanum) continue;
|
||||||
//if the other area is not a midrange area
|
//if the other area is not a midrange area
|
||||||
if (!midrangeareas[otherareanum].valid) continue;
|
if (!midrangeareas[otherareanum].valid) continue;
|
||||||
//
|
//
|
||||||
AAS_AltRoutingFloodCluster_r(otherareanum);
|
AAS_AltRoutingFloodCluster_r(otherareanum);
|
||||||
} //end for
|
} //end for
|
||||||
} //end of the function AAS_AltRoutingFloodCluster_r
|
} //end of the function AAS_AltRoutingFloodCluster_r
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_AlternativeRouteGoals(vec3_t start, int startareanum, vec3_t goal, int goalareanum, int travelflags,
|
int AAS_AlternativeRouteGoals(vec3_t start, int startareanum, vec3_t goal, int goalareanum, int travelflags,
|
||||||
aas_altroutegoal_t *altroutegoals, int maxaltroutegoals,
|
aas_altroutegoal_t *altroutegoals, int maxaltroutegoals,
|
||||||
int type)
|
int type)
|
||||||
{
|
{
|
||||||
#ifndef ENABLE_ALTROUTING
|
#ifndef ENABLE_ALTROUTING
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
int i, j, bestareanum;
|
int i, j, bestareanum;
|
||||||
int numaltroutegoals, nummidrangeareas;
|
int numaltroutegoals, nummidrangeareas;
|
||||||
int starttime, goaltime, goaltraveltime;
|
int starttime, goaltime, goaltraveltime;
|
||||||
float dist, bestdist;
|
float dist, bestdist;
|
||||||
vec3_t mid, dir;
|
vec3_t mid, dir;
|
||||||
#ifdef ALTROUTE_DEBUG
|
#ifdef ALTROUTE_DEBUG
|
||||||
int startmillisecs;
|
int startmillisecs;
|
||||||
|
|
||||||
startmillisecs = Sys_MilliSeconds();
|
startmillisecs = Sys_MilliSeconds();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!startareanum || !goalareanum)
|
if (!startareanum || !goalareanum)
|
||||||
return 0;
|
return 0;
|
||||||
//travel time towards the goal area
|
//travel time towards the goal area
|
||||||
goaltraveltime = AAS_AreaTravelTimeToGoalArea(startareanum, start, goalareanum, travelflags);
|
goaltraveltime = AAS_AreaTravelTimeToGoalArea(startareanum, start, goalareanum, travelflags);
|
||||||
//clear the midrange areas
|
//clear the midrange areas
|
||||||
Com_Memset(midrangeareas, 0, aasworld.numareas * sizeof(midrangearea_t));
|
Com_Memset(midrangeareas, 0, aasworld.numareas * sizeof(midrangearea_t));
|
||||||
numaltroutegoals = 0;
|
numaltroutegoals = 0;
|
||||||
//
|
//
|
||||||
nummidrangeareas = 0;
|
nummidrangeareas = 0;
|
||||||
//
|
//
|
||||||
for (i = 1; i < aasworld.numareas; i++)
|
for (i = 1; i < aasworld.numareas; i++)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
if (!(type & ALTROUTEGOAL_ALL))
|
if (!(type & ALTROUTEGOAL_ALL))
|
||||||
{
|
{
|
||||||
if (!(type & ALTROUTEGOAL_CLUSTERPORTALS && (aasworld.areasettings[i].contents & AREACONTENTS_CLUSTERPORTAL)))
|
if (!(type & ALTROUTEGOAL_CLUSTERPORTALS && (aasworld.areasettings[i].contents & AREACONTENTS_CLUSTERPORTAL)))
|
||||||
{
|
{
|
||||||
if (!(type & ALTROUTEGOAL_VIEWPORTALS && (aasworld.areasettings[i].contents & AREACONTENTS_VIEWPORTAL)))
|
if (!(type & ALTROUTEGOAL_VIEWPORTALS && (aasworld.areasettings[i].contents & AREACONTENTS_VIEWPORTAL)))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
} //end if
|
} //end if
|
||||||
} //end if
|
} //end if
|
||||||
} //end if
|
} //end if
|
||||||
//if the area has no reachabilities
|
//if the area has no reachabilities
|
||||||
if (!AAS_AreaReachability(i)) continue;
|
if (!AAS_AreaReachability(i)) continue;
|
||||||
//tavel time from the area to the start area
|
//tavel time from the area to the start area
|
||||||
starttime = AAS_AreaTravelTimeToGoalArea(startareanum, start, i, travelflags);
|
starttime = AAS_AreaTravelTimeToGoalArea(startareanum, start, i, travelflags);
|
||||||
if (!starttime) continue;
|
if (!starttime) continue;
|
||||||
//if the travel time from the start to the area is greater than the shortest goal travel time
|
//if the travel time from the start to the area is greater than the shortest goal travel time
|
||||||
if (starttime > (float) 1.1 * goaltraveltime) continue;
|
if (starttime > (float) 1.1 * goaltraveltime) continue;
|
||||||
//travel time from the area to the goal area
|
//travel time from the area to the goal area
|
||||||
goaltime = AAS_AreaTravelTimeToGoalArea(i, NULL, goalareanum, travelflags);
|
goaltime = AAS_AreaTravelTimeToGoalArea(i, NULL, goalareanum, travelflags);
|
||||||
if (!goaltime) continue;
|
if (!goaltime) continue;
|
||||||
//if the travel time from the area to the goal is greater than the shortest goal travel time
|
//if the travel time from the area to the goal is greater than the shortest goal travel time
|
||||||
if (goaltime > (float) 0.8 * goaltraveltime) continue;
|
if (goaltime > (float) 0.8 * goaltraveltime) continue;
|
||||||
//this is a mid range area
|
//this is a mid range area
|
||||||
midrangeareas[i].valid = qtrue;
|
midrangeareas[i].valid = qtrue;
|
||||||
midrangeareas[i].starttime = starttime;
|
midrangeareas[i].starttime = starttime;
|
||||||
midrangeareas[i].goaltime = goaltime;
|
midrangeareas[i].goaltime = goaltime;
|
||||||
Log_Write("%d midrange area %d", nummidrangeareas, i);
|
Log_Write("%d midrange area %d", nummidrangeareas, i);
|
||||||
nummidrangeareas++;
|
nummidrangeareas++;
|
||||||
} //end for
|
} //end for
|
||||||
//
|
//
|
||||||
for (i = 1; i < aasworld.numareas; i++)
|
for (i = 1; i < aasworld.numareas; i++)
|
||||||
{
|
{
|
||||||
if (!midrangeareas[i].valid) continue;
|
if (!midrangeareas[i].valid) continue;
|
||||||
//get the areas in one cluster
|
//get the areas in one cluster
|
||||||
numclusterareas = 0;
|
numclusterareas = 0;
|
||||||
AAS_AltRoutingFloodCluster_r(i);
|
AAS_AltRoutingFloodCluster_r(i);
|
||||||
//now we've got a cluster with areas through which an alternative route could go
|
//now we've got a cluster with areas through which an alternative route could go
|
||||||
//get the 'center' of the cluster
|
//get the 'center' of the cluster
|
||||||
VectorClear(mid);
|
VectorClear(mid);
|
||||||
for (j = 0; j < numclusterareas; j++)
|
for (j = 0; j < numclusterareas; j++)
|
||||||
{
|
{
|
||||||
VectorAdd(mid, aasworld.areas[clusterareas[j]].center, mid);
|
VectorAdd(mid, aasworld.areas[clusterareas[j]].center, mid);
|
||||||
} //end for
|
} //end for
|
||||||
VectorScale(mid, 1.0 / numclusterareas, mid);
|
VectorScale(mid, 1.0 / numclusterareas, mid);
|
||||||
//get the area closest to the center of the cluster
|
//get the area closest to the center of the cluster
|
||||||
bestdist = 999999;
|
bestdist = 999999;
|
||||||
bestareanum = 0;
|
bestareanum = 0;
|
||||||
for (j = 0; j < numclusterareas; j++)
|
for (j = 0; j < numclusterareas; j++)
|
||||||
{
|
{
|
||||||
VectorSubtract(mid, aasworld.areas[clusterareas[j]].center, dir);
|
VectorSubtract(mid, aasworld.areas[clusterareas[j]].center, dir);
|
||||||
dist = VectorLength(dir);
|
dist = VectorLength(dir);
|
||||||
if (dist < bestdist)
|
if (dist < bestdist)
|
||||||
{
|
{
|
||||||
bestdist = dist;
|
bestdist = dist;
|
||||||
bestareanum = clusterareas[j];
|
bestareanum = clusterareas[j];
|
||||||
} //end if
|
} //end if
|
||||||
} //end for
|
} //end for
|
||||||
//now we've got an area for an alternative route
|
//now we've got an area for an alternative route
|
||||||
//FIXME: add alternative goal origin
|
//FIXME: add alternative goal origin
|
||||||
VectorCopy(aasworld.areas[bestareanum].center, altroutegoals[numaltroutegoals].origin);
|
VectorCopy(aasworld.areas[bestareanum].center, altroutegoals[numaltroutegoals].origin);
|
||||||
altroutegoals[numaltroutegoals].areanum = bestareanum;
|
altroutegoals[numaltroutegoals].areanum = bestareanum;
|
||||||
altroutegoals[numaltroutegoals].starttraveltime = midrangeareas[bestareanum].starttime;
|
altroutegoals[numaltroutegoals].starttraveltime = midrangeareas[bestareanum].starttime;
|
||||||
altroutegoals[numaltroutegoals].goaltraveltime = midrangeareas[bestareanum].goaltime;
|
altroutegoals[numaltroutegoals].goaltraveltime = midrangeareas[bestareanum].goaltime;
|
||||||
altroutegoals[numaltroutegoals].extratraveltime =
|
altroutegoals[numaltroutegoals].extratraveltime =
|
||||||
(midrangeareas[bestareanum].starttime + midrangeareas[bestareanum].goaltime) -
|
(midrangeareas[bestareanum].starttime + midrangeareas[bestareanum].goaltime) -
|
||||||
goaltraveltime;
|
goaltraveltime;
|
||||||
numaltroutegoals++;
|
numaltroutegoals++;
|
||||||
//
|
//
|
||||||
#ifdef ALTROUTE_DEBUG
|
#ifdef ALTROUTE_DEBUG
|
||||||
AAS_ShowAreaPolygons(bestareanum, 1, qtrue);
|
AAS_ShowAreaPolygons(bestareanum, 1, qtrue);
|
||||||
#endif
|
#endif
|
||||||
//don't return more than the maximum alternative route goals
|
//don't return more than the maximum alternative route goals
|
||||||
if (numaltroutegoals >= maxaltroutegoals) break;
|
if (numaltroutegoals >= maxaltroutegoals) break;
|
||||||
} //end for
|
} //end for
|
||||||
#ifdef ALTROUTE_DEBUG
|
#ifdef ALTROUTE_DEBUG
|
||||||
botimport.Print(PRT_MESSAGE, "alternative route goals in %d msec\n", Sys_MilliSeconds() - startmillisecs);
|
botimport.Print(PRT_MESSAGE, "alternative route goals in %d msec\n", Sys_MilliSeconds() - startmillisecs);
|
||||||
#endif
|
#endif
|
||||||
return numaltroutegoals;
|
return numaltroutegoals;
|
||||||
#endif
|
#endif
|
||||||
} //end of the function AAS_AlternativeRouteGoals
|
} //end of the function AAS_AlternativeRouteGoals
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_InitAlternativeRouting(void)
|
void AAS_InitAlternativeRouting(void)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_ALTROUTING
|
#ifdef ENABLE_ALTROUTING
|
||||||
if (midrangeareas) FreeMemory(midrangeareas);
|
if (midrangeareas) FreeMemory(midrangeareas);
|
||||||
midrangeareas = (midrangearea_t *) GetMemory(aasworld.numareas * sizeof(midrangearea_t));
|
midrangeareas = (midrangearea_t *) GetMemory(aasworld.numareas * sizeof(midrangearea_t));
|
||||||
if (clusterareas) FreeMemory(clusterareas);
|
if (clusterareas) FreeMemory(clusterareas);
|
||||||
clusterareas = (int *) GetMemory(aasworld.numareas * sizeof(int));
|
clusterareas = (int *) GetMemory(aasworld.numareas * sizeof(int));
|
||||||
#endif
|
#endif
|
||||||
} //end of the function AAS_InitAlternativeRouting
|
} //end of the function AAS_InitAlternativeRouting
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_ShutdownAlternativeRouting(void)
|
void AAS_ShutdownAlternativeRouting(void)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_ALTROUTING
|
#ifdef ENABLE_ALTROUTING
|
||||||
if (midrangeareas) FreeMemory(midrangeareas);
|
if (midrangeareas) FreeMemory(midrangeareas);
|
||||||
midrangeareas = NULL;
|
midrangeareas = NULL;
|
||||||
if (clusterareas) FreeMemory(clusterareas);
|
if (clusterareas) FreeMemory(clusterareas);
|
||||||
clusterareas = NULL;
|
clusterareas = NULL;
|
||||||
numclusterareas = 0;
|
numclusterareas = 0;
|
||||||
#endif
|
#endif
|
||||||
} //end of the function AAS_ShutdownAlternativeRouting
|
} //end of the function AAS_ShutdownAlternativeRouting
|
||||||
|
|
|
||||||
|
|
@ -1,40 +1,40 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: be_aas_routealt.h
|
* name: be_aas_routealt.h
|
||||||
*
|
*
|
||||||
* desc: AAS
|
* desc: AAS
|
||||||
*
|
*
|
||||||
* $Archive: /source/code/botlib/be_aas_routealt.h $
|
* $Archive: /source/code/botlib/be_aas_routealt.h $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#ifdef AASINTERN
|
#ifdef AASINTERN
|
||||||
void AAS_InitAlternativeRouting(void);
|
void AAS_InitAlternativeRouting(void);
|
||||||
void AAS_ShutdownAlternativeRouting(void);
|
void AAS_ShutdownAlternativeRouting(void);
|
||||||
#endif //AASINTERN
|
#endif //AASINTERN
|
||||||
|
|
||||||
|
|
||||||
int AAS_AlternativeRouteGoals(vec3_t start, int startareanum, vec3_t goal, int goalareanum, int travelflags,
|
int AAS_AlternativeRouteGoals(vec3_t start, int startareanum, vec3_t goal, int goalareanum, int travelflags,
|
||||||
aas_altroutegoal_t *altroutegoals, int maxaltroutegoals,
|
aas_altroutegoal_t *altroutegoals, int maxaltroutegoals,
|
||||||
int type);
|
int type);
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,69 +1,69 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: be_aas_sample.h
|
* name: be_aas_sample.h
|
||||||
*
|
*
|
||||||
* desc: AAS
|
* desc: AAS
|
||||||
*
|
*
|
||||||
* $Archive: /source/code/botlib/be_aas_sample.h $
|
* $Archive: /source/code/botlib/be_aas_sample.h $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#ifdef AASINTERN
|
#ifdef AASINTERN
|
||||||
void AAS_InitAASLinkHeap(void);
|
void AAS_InitAASLinkHeap(void);
|
||||||
void AAS_InitAASLinkedEntities(void);
|
void AAS_InitAASLinkedEntities(void);
|
||||||
void AAS_FreeAASLinkHeap(void);
|
void AAS_FreeAASLinkHeap(void);
|
||||||
void AAS_FreeAASLinkedEntities(void);
|
void AAS_FreeAASLinkedEntities(void);
|
||||||
aas_face_t *AAS_AreaGroundFace(int areanum, vec3_t point);
|
aas_face_t *AAS_AreaGroundFace(int areanum, vec3_t point);
|
||||||
aas_face_t *AAS_TraceEndFace(aas_trace_t *trace);
|
aas_face_t *AAS_TraceEndFace(aas_trace_t *trace);
|
||||||
aas_plane_t *AAS_PlaneFromNum(int planenum);
|
aas_plane_t *AAS_PlaneFromNum(int planenum);
|
||||||
aas_link_t *AAS_AASLinkEntity(vec3_t absmins, vec3_t absmaxs, int entnum);
|
aas_link_t *AAS_AASLinkEntity(vec3_t absmins, vec3_t absmaxs, int entnum);
|
||||||
aas_link_t *AAS_LinkEntityClientBBox(vec3_t absmins, vec3_t absmaxs, int entnum, int presencetype);
|
aas_link_t *AAS_LinkEntityClientBBox(vec3_t absmins, vec3_t absmaxs, int entnum, int presencetype);
|
||||||
qboolean AAS_PointInsideFace(int facenum, vec3_t point, float epsilon);
|
qboolean AAS_PointInsideFace(int facenum, vec3_t point, float epsilon);
|
||||||
qboolean AAS_InsideFace(aas_face_t *face, vec3_t pnormal, vec3_t point, float epsilon);
|
qboolean AAS_InsideFace(aas_face_t *face, vec3_t pnormal, vec3_t point, float epsilon);
|
||||||
void AAS_UnlinkFromAreas(aas_link_t *areas);
|
void AAS_UnlinkFromAreas(aas_link_t *areas);
|
||||||
#endif //AASINTERN
|
#endif //AASINTERN
|
||||||
|
|
||||||
//returns the mins and maxs of the bounding box for the given presence type
|
//returns the mins and maxs of the bounding box for the given presence type
|
||||||
void AAS_PresenceTypeBoundingBox(int presencetype, vec3_t mins, vec3_t maxs);
|
void AAS_PresenceTypeBoundingBox(int presencetype, vec3_t mins, vec3_t maxs);
|
||||||
//returns the cluster the area is in (negative portal number if the area is a portal)
|
//returns the cluster the area is in (negative portal number if the area is a portal)
|
||||||
int AAS_AreaCluster(int areanum);
|
int AAS_AreaCluster(int areanum);
|
||||||
//returns the presence type(s) of the area
|
//returns the presence type(s) of the area
|
||||||
int AAS_AreaPresenceType(int areanum);
|
int AAS_AreaPresenceType(int areanum);
|
||||||
//returns the presence type(s) at the given point
|
//returns the presence type(s) at the given point
|
||||||
int AAS_PointPresenceType(vec3_t point);
|
int AAS_PointPresenceType(vec3_t point);
|
||||||
//returns the result of the trace of a client bbox
|
//returns the result of the trace of a client bbox
|
||||||
aas_trace_t AAS_TraceClientBBox(vec3_t start, vec3_t end, int presencetype, int passent);
|
aas_trace_t AAS_TraceClientBBox(vec3_t start, vec3_t end, int presencetype, int passent);
|
||||||
//stores the areas the trace went through and returns the number of passed areas
|
//stores the areas the trace went through and returns the number of passed areas
|
||||||
int AAS_TraceAreas(vec3_t start, vec3_t end, int *areas, vec3_t *points, int maxareas);
|
int AAS_TraceAreas(vec3_t start, vec3_t end, int *areas, vec3_t *points, int maxareas);
|
||||||
//returns the areas the bounding box is in
|
//returns the areas the bounding box is in
|
||||||
int AAS_BBoxAreas(vec3_t absmins, vec3_t absmaxs, int *areas, int maxareas);
|
int AAS_BBoxAreas(vec3_t absmins, vec3_t absmaxs, int *areas, int maxareas);
|
||||||
//return area information
|
//return area information
|
||||||
int AAS_AreaInfo( int areanum, aas_areainfo_t *info );
|
int AAS_AreaInfo( int areanum, aas_areainfo_t *info );
|
||||||
//returns the area the point is in
|
//returns the area the point is in
|
||||||
int AAS_PointAreaNum(vec3_t point);
|
int AAS_PointAreaNum(vec3_t point);
|
||||||
//
|
//
|
||||||
int AAS_PointReachabilityAreaIndex( vec3_t point );
|
int AAS_PointReachabilityAreaIndex( vec3_t point );
|
||||||
//returns the plane the given face is in
|
//returns the plane the given face is in
|
||||||
void AAS_FacePlane(int facenum, vec3_t normal, float *dist);
|
void AAS_FacePlane(int facenum, vec3_t normal, float *dist);
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,134 +1,134 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: be_ai_gen.c
|
* name: be_ai_gen.c
|
||||||
*
|
*
|
||||||
* desc: genetic selection
|
* desc: genetic selection
|
||||||
*
|
*
|
||||||
* $Archive: /MissionPack/code/botlib/be_ai_gen.c $
|
* $Archive: /MissionPack/code/botlib/be_ai_gen.c $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "../game/q_shared.h"
|
#include "../game/q_shared.h"
|
||||||
#include "l_memory.h"
|
#include "l_memory.h"
|
||||||
#include "l_log.h"
|
#include "l_log.h"
|
||||||
#include "l_utils.h"
|
#include "l_utils.h"
|
||||||
#include "l_script.h"
|
#include "l_script.h"
|
||||||
#include "l_precomp.h"
|
#include "l_precomp.h"
|
||||||
#include "l_struct.h"
|
#include "l_struct.h"
|
||||||
#include "aasfile.h"
|
#include "aasfile.h"
|
||||||
#include "../game/botlib.h"
|
#include "../game/botlib.h"
|
||||||
#include "../game/be_aas.h"
|
#include "../game/be_aas.h"
|
||||||
#include "be_aas_funcs.h"
|
#include "be_aas_funcs.h"
|
||||||
#include "be_interface.h"
|
#include "be_interface.h"
|
||||||
#include "../game/be_ai_gen.h"
|
#include "../game/be_ai_gen.h"
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int GeneticSelection(int numranks, float *rankings)
|
int GeneticSelection(int numranks, float *rankings)
|
||||||
{
|
{
|
||||||
float sum, select;
|
float sum, select;
|
||||||
int i, index;
|
int i, index;
|
||||||
|
|
||||||
sum = 0;
|
sum = 0;
|
||||||
for (i = 0; i < numranks; i++)
|
for (i = 0; i < numranks; i++)
|
||||||
{
|
{
|
||||||
if (rankings[i] < 0) continue;
|
if (rankings[i] < 0) continue;
|
||||||
sum += rankings[i];
|
sum += rankings[i];
|
||||||
} //end for
|
} //end for
|
||||||
if (sum > 0)
|
if (sum > 0)
|
||||||
{
|
{
|
||||||
//select a bot where the ones with the higest rankings have
|
//select a bot where the ones with the higest rankings have
|
||||||
//the highest chance of being selected
|
//the highest chance of being selected
|
||||||
select = random() * sum;
|
select = random() * sum;
|
||||||
for (i = 0; i < numranks; i++)
|
for (i = 0; i < numranks; i++)
|
||||||
{
|
{
|
||||||
if (rankings[i] < 0) continue;
|
if (rankings[i] < 0) continue;
|
||||||
sum -= rankings[i];
|
sum -= rankings[i];
|
||||||
if (sum <= 0) return i;
|
if (sum <= 0) return i;
|
||||||
} //end for
|
} //end for
|
||||||
} //end if
|
} //end if
|
||||||
//select a bot randomly
|
//select a bot randomly
|
||||||
index = random() * numranks;
|
index = random() * numranks;
|
||||||
for (i = 0; i < numranks; i++)
|
for (i = 0; i < numranks; i++)
|
||||||
{
|
{
|
||||||
if (rankings[index] >= 0) return index;
|
if (rankings[index] >= 0) return index;
|
||||||
index = (index + 1) % numranks;
|
index = (index + 1) % numranks;
|
||||||
} //end for
|
} //end for
|
||||||
return 0;
|
return 0;
|
||||||
} //end of the function GeneticSelection
|
} //end of the function GeneticSelection
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int GeneticParentsAndChildSelection(int numranks, float *ranks, int *parent1, int *parent2, int *child)
|
int GeneticParentsAndChildSelection(int numranks, float *ranks, int *parent1, int *parent2, int *child)
|
||||||
{
|
{
|
||||||
float rankings[256], max;
|
float rankings[256], max;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (numranks > 256)
|
if (numranks > 256)
|
||||||
{
|
{
|
||||||
botimport.Print(PRT_WARNING, "GeneticParentsAndChildSelection: too many bots\n");
|
botimport.Print(PRT_WARNING, "GeneticParentsAndChildSelection: too many bots\n");
|
||||||
*parent1 = *parent2 = *child = 0;
|
*parent1 = *parent2 = *child = 0;
|
||||||
return qfalse;
|
return qfalse;
|
||||||
} //end if
|
} //end if
|
||||||
for (max = 0, i = 0; i < numranks; i++)
|
for (max = 0, i = 0; i < numranks; i++)
|
||||||
{
|
{
|
||||||
if (ranks[i] < 0) continue;
|
if (ranks[i] < 0) continue;
|
||||||
max++;
|
max++;
|
||||||
} //end for
|
} //end for
|
||||||
if (max < 3)
|
if (max < 3)
|
||||||
{
|
{
|
||||||
botimport.Print(PRT_WARNING, "GeneticParentsAndChildSelection: too few valid bots\n");
|
botimport.Print(PRT_WARNING, "GeneticParentsAndChildSelection: too few valid bots\n");
|
||||||
*parent1 = *parent2 = *child = 0;
|
*parent1 = *parent2 = *child = 0;
|
||||||
return qfalse;
|
return qfalse;
|
||||||
} //end if
|
} //end if
|
||||||
Com_Memcpy(rankings, ranks, sizeof(float) * numranks);
|
Com_Memcpy(rankings, ranks, sizeof(float) * numranks);
|
||||||
//select first parent
|
//select first parent
|
||||||
*parent1 = GeneticSelection(numranks, rankings);
|
*parent1 = GeneticSelection(numranks, rankings);
|
||||||
rankings[*parent1] = -1;
|
rankings[*parent1] = -1;
|
||||||
//select second parent
|
//select second parent
|
||||||
*parent2 = GeneticSelection(numranks, rankings);
|
*parent2 = GeneticSelection(numranks, rankings);
|
||||||
rankings[*parent2] = -1;
|
rankings[*parent2] = -1;
|
||||||
//reverse the rankings
|
//reverse the rankings
|
||||||
max = 0;
|
max = 0;
|
||||||
for (i = 0; i < numranks; i++)
|
for (i = 0; i < numranks; i++)
|
||||||
{
|
{
|
||||||
if (rankings[i] < 0) continue;
|
if (rankings[i] < 0) continue;
|
||||||
if (rankings[i] > max) max = rankings[i];
|
if (rankings[i] > max) max = rankings[i];
|
||||||
} //end for
|
} //end for
|
||||||
for (i = 0; i < numranks; i++)
|
for (i = 0; i < numranks; i++)
|
||||||
{
|
{
|
||||||
if (rankings[i] < 0) continue;
|
if (rankings[i] < 0) continue;
|
||||||
rankings[i] = max - rankings[i];
|
rankings[i] = max - rankings[i];
|
||||||
} //end for
|
} //end for
|
||||||
//select child
|
//select child
|
||||||
*child = GeneticSelection(numranks, rankings);
|
*child = GeneticSelection(numranks, rankings);
|
||||||
return qtrue;
|
return qtrue;
|
||||||
} //end of the function GeneticParentsAndChildSelection
|
} //end of the function GeneticParentsAndChildSelection
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,83 +1,83 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: be_ai_weight.h
|
* name: be_ai_weight.h
|
||||||
*
|
*
|
||||||
* desc: fuzzy weights
|
* desc: fuzzy weights
|
||||||
*
|
*
|
||||||
* $Archive: /source/code/botlib/be_ai_weight.h $
|
* $Archive: /source/code/botlib/be_ai_weight.h $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#define WT_BALANCE 1
|
#define WT_BALANCE 1
|
||||||
#define MAX_WEIGHTS 128
|
#define MAX_WEIGHTS 128
|
||||||
|
|
||||||
//fuzzy seperator
|
//fuzzy seperator
|
||||||
typedef struct fuzzyseperator_s
|
typedef struct fuzzyseperator_s
|
||||||
{
|
{
|
||||||
int index;
|
int index;
|
||||||
int value;
|
int value;
|
||||||
int type;
|
int type;
|
||||||
float weight;
|
float weight;
|
||||||
float minweight;
|
float minweight;
|
||||||
float maxweight;
|
float maxweight;
|
||||||
struct fuzzyseperator_s *child;
|
struct fuzzyseperator_s *child;
|
||||||
struct fuzzyseperator_s *next;
|
struct fuzzyseperator_s *next;
|
||||||
} fuzzyseperator_t;
|
} fuzzyseperator_t;
|
||||||
|
|
||||||
//fuzzy weight
|
//fuzzy weight
|
||||||
typedef struct weight_s
|
typedef struct weight_s
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
struct fuzzyseperator_s *firstseperator;
|
struct fuzzyseperator_s *firstseperator;
|
||||||
} weight_t;
|
} weight_t;
|
||||||
|
|
||||||
//weight configuration
|
//weight configuration
|
||||||
typedef struct weightconfig_s
|
typedef struct weightconfig_s
|
||||||
{
|
{
|
||||||
int numweights;
|
int numweights;
|
||||||
weight_t weights[MAX_WEIGHTS];
|
weight_t weights[MAX_WEIGHTS];
|
||||||
char filename[MAX_QPATH];
|
char filename[MAX_QPATH];
|
||||||
} weightconfig_t;
|
} weightconfig_t;
|
||||||
|
|
||||||
//reads a weight configuration
|
//reads a weight configuration
|
||||||
weightconfig_t *ReadWeightConfig(char *filename);
|
weightconfig_t *ReadWeightConfig(char *filename);
|
||||||
//free a weight configuration
|
//free a weight configuration
|
||||||
void FreeWeightConfig(weightconfig_t *config);
|
void FreeWeightConfig(weightconfig_t *config);
|
||||||
//writes a weight configuration, returns true if successfull
|
//writes a weight configuration, returns true if successfull
|
||||||
qboolean WriteWeightConfig(char *filename, weightconfig_t *config);
|
qboolean WriteWeightConfig(char *filename, weightconfig_t *config);
|
||||||
//find the fuzzy weight with the given name
|
//find the fuzzy weight with the given name
|
||||||
int FindFuzzyWeight(weightconfig_t *wc, char *name);
|
int FindFuzzyWeight(weightconfig_t *wc, char *name);
|
||||||
//returns the fuzzy weight for the given inventory and weight
|
//returns the fuzzy weight for the given inventory and weight
|
||||||
float FuzzyWeight(int *inventory, weightconfig_t *wc, int weightnum);
|
float FuzzyWeight(int *inventory, weightconfig_t *wc, int weightnum);
|
||||||
float FuzzyWeightUndecided(int *inventory, weightconfig_t *wc, int weightnum);
|
float FuzzyWeightUndecided(int *inventory, weightconfig_t *wc, int weightnum);
|
||||||
//scales the weight with the given name
|
//scales the weight with the given name
|
||||||
void ScaleWeight(weightconfig_t *config, char *name, float scale);
|
void ScaleWeight(weightconfig_t *config, char *name, float scale);
|
||||||
//scale the balance range
|
//scale the balance range
|
||||||
void ScaleBalanceRange(weightconfig_t *config, float scale);
|
void ScaleBalanceRange(weightconfig_t *config, float scale);
|
||||||
//evolves the weight configuration
|
//evolves the weight configuration
|
||||||
void EvolveWeightConfig(weightconfig_t *config);
|
void EvolveWeightConfig(weightconfig_t *config);
|
||||||
//interbreed the weight configurations and stores the interbreeded one in configout
|
//interbreed the weight configurations and stores the interbreeded one in configout
|
||||||
void InterbreedWeightConfigs(weightconfig_t *config1, weightconfig_t *config2, weightconfig_t *configout);
|
void InterbreedWeightConfigs(weightconfig_t *config1, weightconfig_t *config2, weightconfig_t *configout);
|
||||||
//frees cached weight configurations
|
//frees cached weight configurations
|
||||||
void BotShutdownWeights(void);
|
void BotShutdownWeights(void);
|
||||||
|
|
|
||||||
1016
code/botlib/be_ea.c
1016
code/botlib/be_ea.c
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,57 +1,57 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: be_interface.h
|
* name: be_interface.h
|
||||||
*
|
*
|
||||||
* desc: botlib interface
|
* desc: botlib interface
|
||||||
*
|
*
|
||||||
* $Archive: /source/code/botlib/be_interface.h $
|
* $Archive: /source/code/botlib/be_interface.h $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//#define DEBUG //debug code
|
//#define DEBUG //debug code
|
||||||
#define RANDOMIZE //randomize bot behaviour
|
#define RANDOMIZE //randomize bot behaviour
|
||||||
|
|
||||||
//FIXME: get rid of this global structure
|
//FIXME: get rid of this global structure
|
||||||
typedef struct botlib_globals_s
|
typedef struct botlib_globals_s
|
||||||
{
|
{
|
||||||
int botlibsetup; //true when the bot library has been setup
|
int botlibsetup; //true when the bot library has been setup
|
||||||
int maxentities; //maximum number of entities
|
int maxentities; //maximum number of entities
|
||||||
int maxclients; //maximum number of clients
|
int maxclients; //maximum number of clients
|
||||||
float time; //the global time
|
float time; //the global time
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
qboolean debug; //true if debug is on
|
qboolean debug; //true if debug is on
|
||||||
int goalareanum;
|
int goalareanum;
|
||||||
vec3_t goalorigin;
|
vec3_t goalorigin;
|
||||||
int runai;
|
int runai;
|
||||||
#endif
|
#endif
|
||||||
} botlib_globals_t;
|
} botlib_globals_t;
|
||||||
|
|
||||||
|
|
||||||
extern botlib_globals_t botlibglobals;
|
extern botlib_globals_t botlibglobals;
|
||||||
extern botlib_import_t botimport;
|
extern botlib_import_t botimport;
|
||||||
extern int bot_developer; //true if developer is on
|
extern int bot_developer; //true if developer is on
|
||||||
|
|
||||||
//
|
//
|
||||||
int Sys_MilliSeconds(void);
|
int Sys_MilliSeconds(void);
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,151 +1,151 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: l_crc.c
|
* name: l_crc.c
|
||||||
*
|
*
|
||||||
* desc: CRC calculation
|
* desc: CRC calculation
|
||||||
*
|
*
|
||||||
* $Archive: /MissionPack/CODE/botlib/l_crc.c $
|
* $Archive: /MissionPack/CODE/botlib/l_crc.c $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "../game/q_shared.h"
|
#include "../game/q_shared.h"
|
||||||
#include "../game/botlib.h"
|
#include "../game/botlib.h"
|
||||||
#include "be_interface.h" //for botimport.Print
|
#include "be_interface.h" //for botimport.Print
|
||||||
|
|
||||||
|
|
||||||
// FIXME: byte swap?
|
// FIXME: byte swap?
|
||||||
|
|
||||||
// this is a 16 bit, non-reflected CRC using the polynomial 0x1021
|
// this is a 16 bit, non-reflected CRC using the polynomial 0x1021
|
||||||
// and the initial and final xor values shown below... in other words, the
|
// and the initial and final xor values shown below... in other words, the
|
||||||
// CCITT standard CRC used by XMODEM
|
// CCITT standard CRC used by XMODEM
|
||||||
|
|
||||||
#define CRC_INIT_VALUE 0xffff
|
#define CRC_INIT_VALUE 0xffff
|
||||||
#define CRC_XOR_VALUE 0x0000
|
#define CRC_XOR_VALUE 0x0000
|
||||||
|
|
||||||
unsigned short crctable[257] =
|
unsigned short crctable[257] =
|
||||||
{
|
{
|
||||||
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
|
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
|
||||||
0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
|
0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
|
||||||
0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
|
0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
|
||||||
0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
|
0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
|
||||||
0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
|
0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
|
||||||
0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
|
0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
|
||||||
0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
|
0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
|
||||||
0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
|
0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
|
||||||
0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
|
0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
|
||||||
0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
|
0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
|
||||||
0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
|
0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
|
||||||
0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
|
0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
|
||||||
0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
|
0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
|
||||||
0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
|
0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
|
||||||
0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
|
0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
|
||||||
0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
|
0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
|
||||||
0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
|
0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
|
||||||
0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
|
0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
|
||||||
0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
|
0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
|
||||||
0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
|
0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
|
||||||
0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
|
0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
|
||||||
0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
|
0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
|
||||||
0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
|
0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
|
||||||
0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
|
0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
|
||||||
0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
|
0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
|
||||||
0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
|
0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
|
||||||
0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
|
0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
|
||||||
0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
|
0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
|
||||||
0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
|
0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
|
||||||
0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
|
0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
|
||||||
0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
|
0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
|
||||||
0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
|
0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
|
||||||
};
|
};
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void CRC_Init(unsigned short *crcvalue)
|
void CRC_Init(unsigned short *crcvalue)
|
||||||
{
|
{
|
||||||
*crcvalue = CRC_INIT_VALUE;
|
*crcvalue = CRC_INIT_VALUE;
|
||||||
} //end of the function CRC_Init
|
} //end of the function CRC_Init
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void CRC_ProcessByte(unsigned short *crcvalue, byte data)
|
void CRC_ProcessByte(unsigned short *crcvalue, byte data)
|
||||||
{
|
{
|
||||||
*crcvalue = (*crcvalue << 8) ^ crctable[(*crcvalue >> 8) ^ data];
|
*crcvalue = (*crcvalue << 8) ^ crctable[(*crcvalue >> 8) ^ data];
|
||||||
} //end of the function CRC_ProcessByte
|
} //end of the function CRC_ProcessByte
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
unsigned short CRC_Value(unsigned short crcvalue)
|
unsigned short CRC_Value(unsigned short crcvalue)
|
||||||
{
|
{
|
||||||
return crcvalue ^ CRC_XOR_VALUE;
|
return crcvalue ^ CRC_XOR_VALUE;
|
||||||
} //end of the function CRC_Value
|
} //end of the function CRC_Value
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
unsigned short CRC_ProcessString(unsigned char *data, int length)
|
unsigned short CRC_ProcessString(unsigned char *data, int length)
|
||||||
{
|
{
|
||||||
unsigned short crcvalue;
|
unsigned short crcvalue;
|
||||||
int i, ind;
|
int i, ind;
|
||||||
|
|
||||||
CRC_Init(&crcvalue);
|
CRC_Init(&crcvalue);
|
||||||
|
|
||||||
for (i = 0; i < length; i++)
|
for (i = 0; i < length; i++)
|
||||||
{
|
{
|
||||||
ind = (crcvalue >> 8) ^ data[i];
|
ind = (crcvalue >> 8) ^ data[i];
|
||||||
if (ind < 0 || ind > 256) ind = 0;
|
if (ind < 0 || ind > 256) ind = 0;
|
||||||
crcvalue = (crcvalue << 8) ^ crctable[ind];
|
crcvalue = (crcvalue << 8) ^ crctable[ind];
|
||||||
} //end for
|
} //end for
|
||||||
return CRC_Value(crcvalue);
|
return CRC_Value(crcvalue);
|
||||||
} //end of the function CRC_ProcessString
|
} //end of the function CRC_ProcessString
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void CRC_ContinueProcessString(unsigned short *crc, char *data, int length)
|
void CRC_ContinueProcessString(unsigned short *crc, char *data, int length)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < length; i++)
|
for (i = 0; i < length; i++)
|
||||||
{
|
{
|
||||||
*crc = (*crc << 8) ^ crctable[(*crc >> 8) ^ data[i]];
|
*crc = (*crc << 8) ^ crctable[(*crc >> 8) ^ data[i]];
|
||||||
} //end for
|
} //end for
|
||||||
} //end of the function CRC_ProcessString
|
} //end of the function CRC_ProcessString
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,29 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef unsigned short crc_t;
|
typedef unsigned short crc_t;
|
||||||
|
|
||||||
void CRC_Init(unsigned short *crcvalue);
|
void CRC_Init(unsigned short *crcvalue);
|
||||||
void CRC_ProcessByte(unsigned short *crcvalue, byte data);
|
void CRC_ProcessByte(unsigned short *crcvalue, byte data);
|
||||||
unsigned short CRC_Value(unsigned short crcvalue);
|
unsigned short CRC_Value(unsigned short crcvalue);
|
||||||
unsigned short CRC_ProcessString(unsigned char *data, int length);
|
unsigned short CRC_ProcessString(unsigned char *data, int length);
|
||||||
void CRC_ContinueProcessString(unsigned short *crc, char *data, int length);
|
void CRC_ContinueProcessString(unsigned short *crc, char *data, int length);
|
||||||
|
|
|
||||||
|
|
@ -1,294 +1,294 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: l_libvar.c
|
* name: l_libvar.c
|
||||||
*
|
*
|
||||||
* desc: bot library variables
|
* desc: bot library variables
|
||||||
*
|
*
|
||||||
* $Archive: /MissionPack/code/botlib/l_libvar.c $
|
* $Archive: /MissionPack/code/botlib/l_libvar.c $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "../game/q_shared.h"
|
#include "../game/q_shared.h"
|
||||||
#include "l_memory.h"
|
#include "l_memory.h"
|
||||||
#include "l_libvar.h"
|
#include "l_libvar.h"
|
||||||
|
|
||||||
//list with library variables
|
//list with library variables
|
||||||
libvar_t *libvarlist;
|
libvar_t *libvarlist;
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
float LibVarStringValue(char *string)
|
float LibVarStringValue(char *string)
|
||||||
{
|
{
|
||||||
int dotfound = 0;
|
int dotfound = 0;
|
||||||
float value = 0;
|
float value = 0;
|
||||||
|
|
||||||
while(*string)
|
while(*string)
|
||||||
{
|
{
|
||||||
if (*string < '0' || *string > '9')
|
if (*string < '0' || *string > '9')
|
||||||
{
|
{
|
||||||
if (dotfound || *string != '.')
|
if (dotfound || *string != '.')
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
} //end if
|
} //end if
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dotfound = 10;
|
dotfound = 10;
|
||||||
string++;
|
string++;
|
||||||
} //end if
|
} //end if
|
||||||
} //end if
|
} //end if
|
||||||
if (dotfound)
|
if (dotfound)
|
||||||
{
|
{
|
||||||
value = value + (float) (*string - '0') / (float) dotfound;
|
value = value + (float) (*string - '0') / (float) dotfound;
|
||||||
dotfound *= 10;
|
dotfound *= 10;
|
||||||
} //end if
|
} //end if
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
value = value * 10.0 + (float) (*string - '0');
|
value = value * 10.0 + (float) (*string - '0');
|
||||||
} //end else
|
} //end else
|
||||||
string++;
|
string++;
|
||||||
} //end while
|
} //end while
|
||||||
return value;
|
return value;
|
||||||
} //end of the function LibVarStringValue
|
} //end of the function LibVarStringValue
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
libvar_t *LibVarAlloc(char *var_name)
|
libvar_t *LibVarAlloc(char *var_name)
|
||||||
{
|
{
|
||||||
libvar_t *v;
|
libvar_t *v;
|
||||||
|
|
||||||
v = (libvar_t *) GetMemory(sizeof(libvar_t) + strlen(var_name) + 1);
|
v = (libvar_t *) GetMemory(sizeof(libvar_t) + strlen(var_name) + 1);
|
||||||
Com_Memset(v, 0, sizeof(libvar_t));
|
Com_Memset(v, 0, sizeof(libvar_t));
|
||||||
v->name = (char *) v + sizeof(libvar_t);
|
v->name = (char *) v + sizeof(libvar_t);
|
||||||
strcpy(v->name, var_name);
|
strcpy(v->name, var_name);
|
||||||
//add the variable in the list
|
//add the variable in the list
|
||||||
v->next = libvarlist;
|
v->next = libvarlist;
|
||||||
libvarlist = v;
|
libvarlist = v;
|
||||||
return v;
|
return v;
|
||||||
} //end of the function LibVarAlloc
|
} //end of the function LibVarAlloc
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void LibVarDeAlloc(libvar_t *v)
|
void LibVarDeAlloc(libvar_t *v)
|
||||||
{
|
{
|
||||||
if (v->string) FreeMemory(v->string);
|
if (v->string) FreeMemory(v->string);
|
||||||
FreeMemory(v);
|
FreeMemory(v);
|
||||||
} //end of the function LibVarDeAlloc
|
} //end of the function LibVarDeAlloc
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void LibVarDeAllocAll(void)
|
void LibVarDeAllocAll(void)
|
||||||
{
|
{
|
||||||
libvar_t *v;
|
libvar_t *v;
|
||||||
|
|
||||||
for (v = libvarlist; v; v = libvarlist)
|
for (v = libvarlist; v; v = libvarlist)
|
||||||
{
|
{
|
||||||
libvarlist = libvarlist->next;
|
libvarlist = libvarlist->next;
|
||||||
LibVarDeAlloc(v);
|
LibVarDeAlloc(v);
|
||||||
} //end for
|
} //end for
|
||||||
libvarlist = NULL;
|
libvarlist = NULL;
|
||||||
} //end of the function LibVarDeAllocAll
|
} //end of the function LibVarDeAllocAll
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
libvar_t *LibVarGet(char *var_name)
|
libvar_t *LibVarGet(char *var_name)
|
||||||
{
|
{
|
||||||
libvar_t *v;
|
libvar_t *v;
|
||||||
|
|
||||||
for (v = libvarlist; v; v = v->next)
|
for (v = libvarlist; v; v = v->next)
|
||||||
{
|
{
|
||||||
if (!Q_stricmp(v->name, var_name))
|
if (!Q_stricmp(v->name, var_name))
|
||||||
{
|
{
|
||||||
return v;
|
return v;
|
||||||
} //end if
|
} //end if
|
||||||
} //end for
|
} //end for
|
||||||
return NULL;
|
return NULL;
|
||||||
} //end of the function LibVarGet
|
} //end of the function LibVarGet
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
char *LibVarGetString(char *var_name)
|
char *LibVarGetString(char *var_name)
|
||||||
{
|
{
|
||||||
libvar_t *v;
|
libvar_t *v;
|
||||||
|
|
||||||
v = LibVarGet(var_name);
|
v = LibVarGet(var_name);
|
||||||
if (v)
|
if (v)
|
||||||
{
|
{
|
||||||
return v->string;
|
return v->string;
|
||||||
} //end if
|
} //end if
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
} //end else
|
} //end else
|
||||||
} //end of the function LibVarGetString
|
} //end of the function LibVarGetString
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
float LibVarGetValue(char *var_name)
|
float LibVarGetValue(char *var_name)
|
||||||
{
|
{
|
||||||
libvar_t *v;
|
libvar_t *v;
|
||||||
|
|
||||||
v = LibVarGet(var_name);
|
v = LibVarGet(var_name);
|
||||||
if (v)
|
if (v)
|
||||||
{
|
{
|
||||||
return v->value;
|
return v->value;
|
||||||
} //end if
|
} //end if
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
} //end else
|
} //end else
|
||||||
} //end of the function LibVarGetValue
|
} //end of the function LibVarGetValue
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
libvar_t *LibVar(char *var_name, char *value)
|
libvar_t *LibVar(char *var_name, char *value)
|
||||||
{
|
{
|
||||||
libvar_t *v;
|
libvar_t *v;
|
||||||
v = LibVarGet(var_name);
|
v = LibVarGet(var_name);
|
||||||
if (v) return v;
|
if (v) return v;
|
||||||
//create new variable
|
//create new variable
|
||||||
v = LibVarAlloc(var_name);
|
v = LibVarAlloc(var_name);
|
||||||
//variable string
|
//variable string
|
||||||
v->string = (char *) GetMemory(strlen(value) + 1);
|
v->string = (char *) GetMemory(strlen(value) + 1);
|
||||||
strcpy(v->string, value);
|
strcpy(v->string, value);
|
||||||
//the value
|
//the value
|
||||||
v->value = LibVarStringValue(v->string);
|
v->value = LibVarStringValue(v->string);
|
||||||
//variable is modified
|
//variable is modified
|
||||||
v->modified = qtrue;
|
v->modified = qtrue;
|
||||||
//
|
//
|
||||||
return v;
|
return v;
|
||||||
} //end of the function LibVar
|
} //end of the function LibVar
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
char *LibVarString(char *var_name, char *value)
|
char *LibVarString(char *var_name, char *value)
|
||||||
{
|
{
|
||||||
libvar_t *v;
|
libvar_t *v;
|
||||||
|
|
||||||
v = LibVar(var_name, value);
|
v = LibVar(var_name, value);
|
||||||
return v->string;
|
return v->string;
|
||||||
} //end of the function LibVarString
|
} //end of the function LibVarString
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
float LibVarValue(char *var_name, char *value)
|
float LibVarValue(char *var_name, char *value)
|
||||||
{
|
{
|
||||||
libvar_t *v;
|
libvar_t *v;
|
||||||
|
|
||||||
v = LibVar(var_name, value);
|
v = LibVar(var_name, value);
|
||||||
return v->value;
|
return v->value;
|
||||||
} //end of the function LibVarValue
|
} //end of the function LibVarValue
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void LibVarSet(char *var_name, char *value)
|
void LibVarSet(char *var_name, char *value)
|
||||||
{
|
{
|
||||||
libvar_t *v;
|
libvar_t *v;
|
||||||
|
|
||||||
v = LibVarGet(var_name);
|
v = LibVarGet(var_name);
|
||||||
if (v)
|
if (v)
|
||||||
{
|
{
|
||||||
FreeMemory(v->string);
|
FreeMemory(v->string);
|
||||||
} //end if
|
} //end if
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
v = LibVarAlloc(var_name);
|
v = LibVarAlloc(var_name);
|
||||||
} //end else
|
} //end else
|
||||||
//variable string
|
//variable string
|
||||||
v->string = (char *) GetMemory(strlen(value) + 1);
|
v->string = (char *) GetMemory(strlen(value) + 1);
|
||||||
strcpy(v->string, value);
|
strcpy(v->string, value);
|
||||||
//the value
|
//the value
|
||||||
v->value = LibVarStringValue(v->string);
|
v->value = LibVarStringValue(v->string);
|
||||||
//variable is modified
|
//variable is modified
|
||||||
v->modified = qtrue;
|
v->modified = qtrue;
|
||||||
} //end of the function LibVarSet
|
} //end of the function LibVarSet
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
qboolean LibVarChanged(char *var_name)
|
qboolean LibVarChanged(char *var_name)
|
||||||
{
|
{
|
||||||
libvar_t *v;
|
libvar_t *v;
|
||||||
|
|
||||||
v = LibVarGet(var_name);
|
v = LibVarGet(var_name);
|
||||||
if (v)
|
if (v)
|
||||||
{
|
{
|
||||||
return v->modified;
|
return v->modified;
|
||||||
} //end if
|
} //end if
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return qfalse;
|
return qfalse;
|
||||||
} //end else
|
} //end else
|
||||||
} //end of the function LibVarChanged
|
} //end of the function LibVarChanged
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void LibVarSetNotModified(char *var_name)
|
void LibVarSetNotModified(char *var_name)
|
||||||
{
|
{
|
||||||
libvar_t *v;
|
libvar_t *v;
|
||||||
|
|
||||||
v = LibVarGet(var_name);
|
v = LibVarGet(var_name);
|
||||||
if (v)
|
if (v)
|
||||||
{
|
{
|
||||||
v->modified = qfalse;
|
v->modified = qfalse;
|
||||||
} //end if
|
} //end if
|
||||||
} //end of the function LibVarSetNotModified
|
} //end of the function LibVarSetNotModified
|
||||||
|
|
|
||||||
|
|
@ -1,63 +1,63 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: l_libvar.h
|
* name: l_libvar.h
|
||||||
*
|
*
|
||||||
* desc: botlib vars
|
* desc: botlib vars
|
||||||
*
|
*
|
||||||
* $Archive: /source/code/botlib/l_libvar.h $
|
* $Archive: /source/code/botlib/l_libvar.h $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//library variable
|
//library variable
|
||||||
typedef struct libvar_s
|
typedef struct libvar_s
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
char *string;
|
char *string;
|
||||||
int flags;
|
int flags;
|
||||||
qboolean modified; // set each time the cvar is changed
|
qboolean modified; // set each time the cvar is changed
|
||||||
float value;
|
float value;
|
||||||
struct libvar_s *next;
|
struct libvar_s *next;
|
||||||
} libvar_t;
|
} libvar_t;
|
||||||
|
|
||||||
//removes all library variables
|
//removes all library variables
|
||||||
void LibVarDeAllocAll(void);
|
void LibVarDeAllocAll(void);
|
||||||
//gets the library variable with the given name
|
//gets the library variable with the given name
|
||||||
libvar_t *LibVarGet(char *var_name);
|
libvar_t *LibVarGet(char *var_name);
|
||||||
//gets the string of the library variable with the given name
|
//gets the string of the library variable with the given name
|
||||||
char *LibVarGetString(char *var_name);
|
char *LibVarGetString(char *var_name);
|
||||||
//gets the value of the library variable with the given name
|
//gets the value of the library variable with the given name
|
||||||
float LibVarGetValue(char *var_name);
|
float LibVarGetValue(char *var_name);
|
||||||
//creates the library variable if not existing already and returns it
|
//creates the library variable if not existing already and returns it
|
||||||
libvar_t *LibVar(char *var_name, char *value);
|
libvar_t *LibVar(char *var_name, char *value);
|
||||||
//creates the library variable if not existing already and returns the value
|
//creates the library variable if not existing already and returns the value
|
||||||
float LibVarValue(char *var_name, char *value);
|
float LibVarValue(char *var_name, char *value);
|
||||||
//creates the library variable if not existing already and returns the value string
|
//creates the library variable if not existing already and returns the value string
|
||||||
char *LibVarString(char *var_name, char *value);
|
char *LibVarString(char *var_name, char *value);
|
||||||
//sets the library variable
|
//sets the library variable
|
||||||
void LibVarSet(char *var_name, char *value);
|
void LibVarSet(char *var_name, char *value);
|
||||||
//returns true if the library variable has been modified
|
//returns true if the library variable has been modified
|
||||||
qboolean LibVarChanged(char *var_name);
|
qboolean LibVarChanged(char *var_name);
|
||||||
//sets the library variable to unmodified
|
//sets the library variable to unmodified
|
||||||
void LibVarSetNotModified(char *var_name);
|
void LibVarSetNotModified(char *var_name);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,169 +1,169 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: l_log.c
|
* name: l_log.c
|
||||||
*
|
*
|
||||||
* desc: log file
|
* desc: log file
|
||||||
*
|
*
|
||||||
* $Archive: /MissionPack/CODE/botlib/l_log.c $
|
* $Archive: /MissionPack/CODE/botlib/l_log.c $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "../game/q_shared.h"
|
#include "../game/q_shared.h"
|
||||||
#include "../game/botlib.h"
|
#include "../game/botlib.h"
|
||||||
#include "be_interface.h" //for botimport.Print
|
#include "be_interface.h" //for botimport.Print
|
||||||
#include "l_libvar.h"
|
#include "l_libvar.h"
|
||||||
|
|
||||||
#define MAX_LOGFILENAMESIZE 1024
|
#define MAX_LOGFILENAMESIZE 1024
|
||||||
|
|
||||||
typedef struct logfile_s
|
typedef struct logfile_s
|
||||||
{
|
{
|
||||||
char filename[MAX_LOGFILENAMESIZE];
|
char filename[MAX_LOGFILENAMESIZE];
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
int numwrites;
|
int numwrites;
|
||||||
} logfile_t;
|
} logfile_t;
|
||||||
|
|
||||||
static logfile_t logfile;
|
static logfile_t logfile;
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void Log_Open(char *filename)
|
void Log_Open(char *filename)
|
||||||
{
|
{
|
||||||
if (!LibVarValue("log", "0")) return;
|
if (!LibVarValue("log", "0")) return;
|
||||||
if (!filename || !strlen(filename))
|
if (!filename || !strlen(filename))
|
||||||
{
|
{
|
||||||
botimport.Print(PRT_MESSAGE, "openlog <filename>\n");
|
botimport.Print(PRT_MESSAGE, "openlog <filename>\n");
|
||||||
return;
|
return;
|
||||||
} //end if
|
} //end if
|
||||||
if (logfile.fp)
|
if (logfile.fp)
|
||||||
{
|
{
|
||||||
botimport.Print(PRT_ERROR, "log file %s is already opened\n", logfile.filename);
|
botimport.Print(PRT_ERROR, "log file %s is already opened\n", logfile.filename);
|
||||||
return;
|
return;
|
||||||
} //end if
|
} //end if
|
||||||
logfile.fp = fopen(filename, "wb");
|
logfile.fp = fopen(filename, "wb");
|
||||||
if (!logfile.fp)
|
if (!logfile.fp)
|
||||||
{
|
{
|
||||||
botimport.Print(PRT_ERROR, "can't open the log file %s\n", filename);
|
botimport.Print(PRT_ERROR, "can't open the log file %s\n", filename);
|
||||||
return;
|
return;
|
||||||
} //end if
|
} //end if
|
||||||
strncpy(logfile.filename, filename, MAX_LOGFILENAMESIZE);
|
strncpy(logfile.filename, filename, MAX_LOGFILENAMESIZE);
|
||||||
botimport.Print(PRT_MESSAGE, "Opened log %s\n", logfile.filename);
|
botimport.Print(PRT_MESSAGE, "Opened log %s\n", logfile.filename);
|
||||||
} //end of the function Log_Create
|
} //end of the function Log_Create
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void Log_Close(void)
|
void Log_Close(void)
|
||||||
{
|
{
|
||||||
if (!logfile.fp) return;
|
if (!logfile.fp) return;
|
||||||
if (fclose(logfile.fp))
|
if (fclose(logfile.fp))
|
||||||
{
|
{
|
||||||
botimport.Print(PRT_ERROR, "can't close log file %s\n", logfile.filename);
|
botimport.Print(PRT_ERROR, "can't close log file %s\n", logfile.filename);
|
||||||
return;
|
return;
|
||||||
} //end if
|
} //end if
|
||||||
logfile.fp = NULL;
|
logfile.fp = NULL;
|
||||||
botimport.Print(PRT_MESSAGE, "Closed log %s\n", logfile.filename);
|
botimport.Print(PRT_MESSAGE, "Closed log %s\n", logfile.filename);
|
||||||
} //end of the function Log_Close
|
} //end of the function Log_Close
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void Log_Shutdown(void)
|
void Log_Shutdown(void)
|
||||||
{
|
{
|
||||||
if (logfile.fp) Log_Close();
|
if (logfile.fp) Log_Close();
|
||||||
} //end of the function Log_Shutdown
|
} //end of the function Log_Shutdown
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void QDECL Log_Write(char *fmt, ...)
|
void QDECL Log_Write(char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
if (!logfile.fp) return;
|
if (!logfile.fp) return;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
vfprintf(logfile.fp, fmt, ap);
|
vfprintf(logfile.fp, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
//fprintf(logfile.fp, "\r\n");
|
//fprintf(logfile.fp, "\r\n");
|
||||||
fflush(logfile.fp);
|
fflush(logfile.fp);
|
||||||
} //end of the function Log_Write
|
} //end of the function Log_Write
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void QDECL Log_WriteTimeStamped(char *fmt, ...)
|
void QDECL Log_WriteTimeStamped(char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
if (!logfile.fp) return;
|
if (!logfile.fp) return;
|
||||||
fprintf(logfile.fp, "%d %02d:%02d:%02d:%02d ",
|
fprintf(logfile.fp, "%d %02d:%02d:%02d:%02d ",
|
||||||
logfile.numwrites,
|
logfile.numwrites,
|
||||||
(int) (botlibglobals.time / 60 / 60),
|
(int) (botlibglobals.time / 60 / 60),
|
||||||
(int) (botlibglobals.time / 60),
|
(int) (botlibglobals.time / 60),
|
||||||
(int) (botlibglobals.time),
|
(int) (botlibglobals.time),
|
||||||
(int) ((int) (botlibglobals.time * 100)) -
|
(int) ((int) (botlibglobals.time * 100)) -
|
||||||
((int) botlibglobals.time) * 100);
|
((int) botlibglobals.time) * 100);
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
vfprintf(logfile.fp, fmt, ap);
|
vfprintf(logfile.fp, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
fprintf(logfile.fp, "\r\n");
|
fprintf(logfile.fp, "\r\n");
|
||||||
logfile.numwrites++;
|
logfile.numwrites++;
|
||||||
fflush(logfile.fp);
|
fflush(logfile.fp);
|
||||||
} //end of the function Log_Write
|
} //end of the function Log_Write
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
FILE *Log_FilePointer(void)
|
FILE *Log_FilePointer(void)
|
||||||
{
|
{
|
||||||
return logfile.fp;
|
return logfile.fp;
|
||||||
} //end of the function Log_FilePointer
|
} //end of the function Log_FilePointer
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void Log_Flush(void)
|
void Log_Flush(void)
|
||||||
{
|
{
|
||||||
if (logfile.fp) fflush(logfile.fp);
|
if (logfile.fp) fflush(logfile.fp);
|
||||||
} //end of the function Log_Flush
|
} //end of the function Log_Flush
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,46 +1,46 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: l_log.h
|
* name: l_log.h
|
||||||
*
|
*
|
||||||
* desc: log file
|
* desc: log file
|
||||||
*
|
*
|
||||||
* $Archive: /source/code/botlib/l_log.h $
|
* $Archive: /source/code/botlib/l_log.h $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//open a log file
|
//open a log file
|
||||||
void Log_Open(char *filename);
|
void Log_Open(char *filename);
|
||||||
//close the current log file
|
//close the current log file
|
||||||
void Log_Close(void);
|
void Log_Close(void);
|
||||||
//close log file if present
|
//close log file if present
|
||||||
void Log_Shutdown(void);
|
void Log_Shutdown(void);
|
||||||
//write to the current opened log file
|
//write to the current opened log file
|
||||||
void QDECL Log_Write(char *fmt, ...);
|
void QDECL Log_Write(char *fmt, ...);
|
||||||
//write to the current opened log file with a time stamp
|
//write to the current opened log file with a time stamp
|
||||||
void QDECL Log_WriteTimeStamped(char *fmt, ...);
|
void QDECL Log_WriteTimeStamped(char *fmt, ...);
|
||||||
//returns a pointer to the log file
|
//returns a pointer to the log file
|
||||||
FILE *Log_FilePointer(void);
|
FILE *Log_FilePointer(void);
|
||||||
//flush log file
|
//flush log file
|
||||||
void Log_Flush(void);
|
void Log_Flush(void);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,463 +1,463 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: l_memory.c
|
* name: l_memory.c
|
||||||
*
|
*
|
||||||
* desc: memory allocation
|
* desc: memory allocation
|
||||||
*
|
*
|
||||||
* $Archive: /MissionPack/code/botlib/l_memory.c $
|
* $Archive: /MissionPack/code/botlib/l_memory.c $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "../game/q_shared.h"
|
#include "../game/q_shared.h"
|
||||||
#include "../game/botlib.h"
|
#include "../game/botlib.h"
|
||||||
#include "l_log.h"
|
#include "l_log.h"
|
||||||
#include "be_interface.h"
|
#include "be_interface.h"
|
||||||
|
|
||||||
//#define MEMDEBUG
|
//#define MEMDEBUG
|
||||||
//#define MEMORYMANEGER
|
//#define MEMORYMANEGER
|
||||||
|
|
||||||
#define MEM_ID 0x12345678l
|
#define MEM_ID 0x12345678l
|
||||||
#define HUNK_ID 0x87654321l
|
#define HUNK_ID 0x87654321l
|
||||||
|
|
||||||
int allocatedmemory;
|
int allocatedmemory;
|
||||||
int totalmemorysize;
|
int totalmemorysize;
|
||||||
int numblocks;
|
int numblocks;
|
||||||
|
|
||||||
#ifdef MEMORYMANEGER
|
#ifdef MEMORYMANEGER
|
||||||
|
|
||||||
typedef struct memoryblock_s
|
typedef struct memoryblock_s
|
||||||
{
|
{
|
||||||
unsigned long int id;
|
unsigned long int id;
|
||||||
void *ptr;
|
void *ptr;
|
||||||
int size;
|
int size;
|
||||||
#ifdef MEMDEBUG
|
#ifdef MEMDEBUG
|
||||||
char *label;
|
char *label;
|
||||||
char *file;
|
char *file;
|
||||||
int line;
|
int line;
|
||||||
#endif //MEMDEBUG
|
#endif //MEMDEBUG
|
||||||
struct memoryblock_s *prev, *next;
|
struct memoryblock_s *prev, *next;
|
||||||
} memoryblock_t;
|
} memoryblock_t;
|
||||||
|
|
||||||
memoryblock_t *memory;
|
memoryblock_t *memory;
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void LinkMemoryBlock(memoryblock_t *block)
|
void LinkMemoryBlock(memoryblock_t *block)
|
||||||
{
|
{
|
||||||
block->prev = NULL;
|
block->prev = NULL;
|
||||||
block->next = memory;
|
block->next = memory;
|
||||||
if (memory) memory->prev = block;
|
if (memory) memory->prev = block;
|
||||||
memory = block;
|
memory = block;
|
||||||
} //end of the function LinkMemoryBlock
|
} //end of the function LinkMemoryBlock
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void UnlinkMemoryBlock(memoryblock_t *block)
|
void UnlinkMemoryBlock(memoryblock_t *block)
|
||||||
{
|
{
|
||||||
if (block->prev) block->prev->next = block->next;
|
if (block->prev) block->prev->next = block->next;
|
||||||
else memory = block->next;
|
else memory = block->next;
|
||||||
if (block->next) block->next->prev = block->prev;
|
if (block->next) block->next->prev = block->prev;
|
||||||
} //end of the function UnlinkMemoryBlock
|
} //end of the function UnlinkMemoryBlock
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
#ifdef MEMDEBUG
|
#ifdef MEMDEBUG
|
||||||
void *GetMemoryDebug(unsigned long size, char *label, char *file, int line)
|
void *GetMemoryDebug(unsigned long size, char *label, char *file, int line)
|
||||||
#else
|
#else
|
||||||
void *GetMemory(unsigned long size)
|
void *GetMemory(unsigned long size)
|
||||||
#endif //MEMDEBUG
|
#endif //MEMDEBUG
|
||||||
{
|
{
|
||||||
void *ptr;
|
void *ptr;
|
||||||
memoryblock_t *block;
|
memoryblock_t *block;
|
||||||
assert(botimport.GetMemory); // bk001129 - was NULL'ed
|
assert(botimport.GetMemory); // bk001129 - was NULL'ed
|
||||||
ptr = botimport.GetMemory(size + sizeof(memoryblock_t));
|
ptr = botimport.GetMemory(size + sizeof(memoryblock_t));
|
||||||
block = (memoryblock_t *) ptr;
|
block = (memoryblock_t *) ptr;
|
||||||
block->id = MEM_ID;
|
block->id = MEM_ID;
|
||||||
block->ptr = (char *) ptr + sizeof(memoryblock_t);
|
block->ptr = (char *) ptr + sizeof(memoryblock_t);
|
||||||
block->size = size + sizeof(memoryblock_t);
|
block->size = size + sizeof(memoryblock_t);
|
||||||
#ifdef MEMDEBUG
|
#ifdef MEMDEBUG
|
||||||
block->label = label;
|
block->label = label;
|
||||||
block->file = file;
|
block->file = file;
|
||||||
block->line = line;
|
block->line = line;
|
||||||
#endif //MEMDEBUG
|
#endif //MEMDEBUG
|
||||||
LinkMemoryBlock(block);
|
LinkMemoryBlock(block);
|
||||||
allocatedmemory += block->size;
|
allocatedmemory += block->size;
|
||||||
totalmemorysize += block->size + sizeof(memoryblock_t);
|
totalmemorysize += block->size + sizeof(memoryblock_t);
|
||||||
numblocks++;
|
numblocks++;
|
||||||
return block->ptr;
|
return block->ptr;
|
||||||
} //end of the function GetMemoryDebug
|
} //end of the function GetMemoryDebug
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
#ifdef MEMDEBUG
|
#ifdef MEMDEBUG
|
||||||
void *GetClearedMemoryDebug(unsigned long size, char *label, char *file, int line)
|
void *GetClearedMemoryDebug(unsigned long size, char *label, char *file, int line)
|
||||||
#else
|
#else
|
||||||
void *GetClearedMemory(unsigned long size)
|
void *GetClearedMemory(unsigned long size)
|
||||||
#endif //MEMDEBUG
|
#endif //MEMDEBUG
|
||||||
{
|
{
|
||||||
void *ptr;
|
void *ptr;
|
||||||
#ifdef MEMDEBUG
|
#ifdef MEMDEBUG
|
||||||
ptr = GetMemoryDebug(size, label, file, line);
|
ptr = GetMemoryDebug(size, label, file, line);
|
||||||
#else
|
#else
|
||||||
ptr = GetMemory(size);
|
ptr = GetMemory(size);
|
||||||
#endif //MEMDEBUG
|
#endif //MEMDEBUG
|
||||||
Com_Memset(ptr, 0, size);
|
Com_Memset(ptr, 0, size);
|
||||||
return ptr;
|
return ptr;
|
||||||
} //end of the function GetClearedMemory
|
} //end of the function GetClearedMemory
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
#ifdef MEMDEBUG
|
#ifdef MEMDEBUG
|
||||||
void *GetHunkMemoryDebug(unsigned long size, char *label, char *file, int line)
|
void *GetHunkMemoryDebug(unsigned long size, char *label, char *file, int line)
|
||||||
#else
|
#else
|
||||||
void *GetHunkMemory(unsigned long size)
|
void *GetHunkMemory(unsigned long size)
|
||||||
#endif //MEMDEBUG
|
#endif //MEMDEBUG
|
||||||
{
|
{
|
||||||
void *ptr;
|
void *ptr;
|
||||||
memoryblock_t *block;
|
memoryblock_t *block;
|
||||||
|
|
||||||
ptr = botimport.HunkAlloc(size + sizeof(memoryblock_t));
|
ptr = botimport.HunkAlloc(size + sizeof(memoryblock_t));
|
||||||
block = (memoryblock_t *) ptr;
|
block = (memoryblock_t *) ptr;
|
||||||
block->id = HUNK_ID;
|
block->id = HUNK_ID;
|
||||||
block->ptr = (char *) ptr + sizeof(memoryblock_t);
|
block->ptr = (char *) ptr + sizeof(memoryblock_t);
|
||||||
block->size = size + sizeof(memoryblock_t);
|
block->size = size + sizeof(memoryblock_t);
|
||||||
#ifdef MEMDEBUG
|
#ifdef MEMDEBUG
|
||||||
block->label = label;
|
block->label = label;
|
||||||
block->file = file;
|
block->file = file;
|
||||||
block->line = line;
|
block->line = line;
|
||||||
#endif //MEMDEBUG
|
#endif //MEMDEBUG
|
||||||
LinkMemoryBlock(block);
|
LinkMemoryBlock(block);
|
||||||
allocatedmemory += block->size;
|
allocatedmemory += block->size;
|
||||||
totalmemorysize += block->size + sizeof(memoryblock_t);
|
totalmemorysize += block->size + sizeof(memoryblock_t);
|
||||||
numblocks++;
|
numblocks++;
|
||||||
return block->ptr;
|
return block->ptr;
|
||||||
} //end of the function GetHunkMemoryDebug
|
} //end of the function GetHunkMemoryDebug
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
#ifdef MEMDEBUG
|
#ifdef MEMDEBUG
|
||||||
void *GetClearedHunkMemoryDebug(unsigned long size, char *label, char *file, int line)
|
void *GetClearedHunkMemoryDebug(unsigned long size, char *label, char *file, int line)
|
||||||
#else
|
#else
|
||||||
void *GetClearedHunkMemory(unsigned long size)
|
void *GetClearedHunkMemory(unsigned long size)
|
||||||
#endif //MEMDEBUG
|
#endif //MEMDEBUG
|
||||||
{
|
{
|
||||||
void *ptr;
|
void *ptr;
|
||||||
#ifdef MEMDEBUG
|
#ifdef MEMDEBUG
|
||||||
ptr = GetHunkMemoryDebug(size, label, file, line);
|
ptr = GetHunkMemoryDebug(size, label, file, line);
|
||||||
#else
|
#else
|
||||||
ptr = GetHunkMemory(size);
|
ptr = GetHunkMemory(size);
|
||||||
#endif //MEMDEBUG
|
#endif //MEMDEBUG
|
||||||
Com_Memset(ptr, 0, size);
|
Com_Memset(ptr, 0, size);
|
||||||
return ptr;
|
return ptr;
|
||||||
} //end of the function GetClearedHunkMemory
|
} //end of the function GetClearedHunkMemory
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
memoryblock_t *BlockFromPointer(void *ptr, char *str)
|
memoryblock_t *BlockFromPointer(void *ptr, char *str)
|
||||||
{
|
{
|
||||||
memoryblock_t *block;
|
memoryblock_t *block;
|
||||||
|
|
||||||
if (!ptr)
|
if (!ptr)
|
||||||
{
|
{
|
||||||
#ifdef MEMDEBUG
|
#ifdef MEMDEBUG
|
||||||
//char *crash = (char *) NULL;
|
//char *crash = (char *) NULL;
|
||||||
//crash[0] = 1;
|
//crash[0] = 1;
|
||||||
botimport.Print(PRT_FATAL, "%s: NULL pointer\n", str);
|
botimport.Print(PRT_FATAL, "%s: NULL pointer\n", str);
|
||||||
#endif // MEMDEBUG
|
#endif // MEMDEBUG
|
||||||
return NULL;
|
return NULL;
|
||||||
} //end if
|
} //end if
|
||||||
block = (memoryblock_t *) ((char *) ptr - sizeof(memoryblock_t));
|
block = (memoryblock_t *) ((char *) ptr - sizeof(memoryblock_t));
|
||||||
if (block->id != MEM_ID && block->id != HUNK_ID)
|
if (block->id != MEM_ID && block->id != HUNK_ID)
|
||||||
{
|
{
|
||||||
botimport.Print(PRT_FATAL, "%s: invalid memory block\n", str);
|
botimport.Print(PRT_FATAL, "%s: invalid memory block\n", str);
|
||||||
return NULL;
|
return NULL;
|
||||||
} //end if
|
} //end if
|
||||||
if (block->ptr != ptr)
|
if (block->ptr != ptr)
|
||||||
{
|
{
|
||||||
botimport.Print(PRT_FATAL, "%s: memory block pointer invalid\n", str);
|
botimport.Print(PRT_FATAL, "%s: memory block pointer invalid\n", str);
|
||||||
return NULL;
|
return NULL;
|
||||||
} //end if
|
} //end if
|
||||||
return block;
|
return block;
|
||||||
} //end of the function BlockFromPointer
|
} //end of the function BlockFromPointer
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void FreeMemory(void *ptr)
|
void FreeMemory(void *ptr)
|
||||||
{
|
{
|
||||||
memoryblock_t *block;
|
memoryblock_t *block;
|
||||||
|
|
||||||
block = BlockFromPointer(ptr, "FreeMemory");
|
block = BlockFromPointer(ptr, "FreeMemory");
|
||||||
if (!block) return;
|
if (!block) return;
|
||||||
UnlinkMemoryBlock(block);
|
UnlinkMemoryBlock(block);
|
||||||
allocatedmemory -= block->size;
|
allocatedmemory -= block->size;
|
||||||
totalmemorysize -= block->size + sizeof(memoryblock_t);
|
totalmemorysize -= block->size + sizeof(memoryblock_t);
|
||||||
numblocks--;
|
numblocks--;
|
||||||
//
|
//
|
||||||
if (block->id == MEM_ID)
|
if (block->id == MEM_ID)
|
||||||
{
|
{
|
||||||
botimport.FreeMemory(block);
|
botimport.FreeMemory(block);
|
||||||
} //end if
|
} //end if
|
||||||
} //end of the function FreeMemory
|
} //end of the function FreeMemory
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AvailableMemory(void)
|
int AvailableMemory(void)
|
||||||
{
|
{
|
||||||
return botimport.AvailableMemory();
|
return botimport.AvailableMemory();
|
||||||
} //end of the function AvailableMemory
|
} //end of the function AvailableMemory
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int MemoryByteSize(void *ptr)
|
int MemoryByteSize(void *ptr)
|
||||||
{
|
{
|
||||||
memoryblock_t *block;
|
memoryblock_t *block;
|
||||||
|
|
||||||
block = BlockFromPointer(ptr, "MemoryByteSize");
|
block = BlockFromPointer(ptr, "MemoryByteSize");
|
||||||
if (!block) return 0;
|
if (!block) return 0;
|
||||||
return block->size;
|
return block->size;
|
||||||
} //end of the function MemoryByteSize
|
} //end of the function MemoryByteSize
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void PrintUsedMemorySize(void)
|
void PrintUsedMemorySize(void)
|
||||||
{
|
{
|
||||||
botimport.Print(PRT_MESSAGE, "total allocated memory: %d KB\n", allocatedmemory >> 10);
|
botimport.Print(PRT_MESSAGE, "total allocated memory: %d KB\n", allocatedmemory >> 10);
|
||||||
botimport.Print(PRT_MESSAGE, "total botlib memory: %d KB\n", totalmemorysize >> 10);
|
botimport.Print(PRT_MESSAGE, "total botlib memory: %d KB\n", totalmemorysize >> 10);
|
||||||
botimport.Print(PRT_MESSAGE, "total memory blocks: %d\n", numblocks);
|
botimport.Print(PRT_MESSAGE, "total memory blocks: %d\n", numblocks);
|
||||||
} //end of the function PrintUsedMemorySize
|
} //end of the function PrintUsedMemorySize
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void PrintMemoryLabels(void)
|
void PrintMemoryLabels(void)
|
||||||
{
|
{
|
||||||
memoryblock_t *block;
|
memoryblock_t *block;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
PrintUsedMemorySize();
|
PrintUsedMemorySize();
|
||||||
i = 0;
|
i = 0;
|
||||||
Log_Write("============= Botlib memory log ==============\r\n");
|
Log_Write("============= Botlib memory log ==============\r\n");
|
||||||
Log_Write("\r\n");
|
Log_Write("\r\n");
|
||||||
for (block = memory; block; block = block->next)
|
for (block = memory; block; block = block->next)
|
||||||
{
|
{
|
||||||
#ifdef MEMDEBUG
|
#ifdef MEMDEBUG
|
||||||
if (block->id == HUNK_ID)
|
if (block->id == HUNK_ID)
|
||||||
{
|
{
|
||||||
Log_Write("%6d, hunk %p, %8d: %24s line %6d: %s\r\n", i, block->ptr, block->size, block->file, block->line, block->label);
|
Log_Write("%6d, hunk %p, %8d: %24s line %6d: %s\r\n", i, block->ptr, block->size, block->file, block->line, block->label);
|
||||||
} //end if
|
} //end if
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_Write("%6d, %p, %8d: %24s line %6d: %s\r\n", i, block->ptr, block->size, block->file, block->line, block->label);
|
Log_Write("%6d, %p, %8d: %24s line %6d: %s\r\n", i, block->ptr, block->size, block->file, block->line, block->label);
|
||||||
} //end else
|
} //end else
|
||||||
#endif //MEMDEBUG
|
#endif //MEMDEBUG
|
||||||
i++;
|
i++;
|
||||||
} //end for
|
} //end for
|
||||||
} //end of the function PrintMemoryLabels
|
} //end of the function PrintMemoryLabels
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void DumpMemory(void)
|
void DumpMemory(void)
|
||||||
{
|
{
|
||||||
memoryblock_t *block;
|
memoryblock_t *block;
|
||||||
|
|
||||||
for (block = memory; block; block = memory)
|
for (block = memory; block; block = memory)
|
||||||
{
|
{
|
||||||
FreeMemory(block->ptr);
|
FreeMemory(block->ptr);
|
||||||
} //end for
|
} //end for
|
||||||
totalmemorysize = 0;
|
totalmemorysize = 0;
|
||||||
allocatedmemory = 0;
|
allocatedmemory = 0;
|
||||||
} //end of the function DumpMemory
|
} //end of the function DumpMemory
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
#ifdef MEMDEBUG
|
#ifdef MEMDEBUG
|
||||||
void *GetMemoryDebug(unsigned long size, char *label, char *file, int line)
|
void *GetMemoryDebug(unsigned long size, char *label, char *file, int line)
|
||||||
#else
|
#else
|
||||||
void *GetMemory(unsigned long size)
|
void *GetMemory(unsigned long size)
|
||||||
#endif //MEMDEBUG
|
#endif //MEMDEBUG
|
||||||
{
|
{
|
||||||
void *ptr;
|
void *ptr;
|
||||||
unsigned long int *memid;
|
unsigned long int *memid;
|
||||||
|
|
||||||
ptr = botimport.GetMemory(size + sizeof(unsigned long int));
|
ptr = botimport.GetMemory(size + sizeof(unsigned long int));
|
||||||
if (!ptr) return NULL;
|
if (!ptr) return NULL;
|
||||||
memid = (unsigned long int *) ptr;
|
memid = (unsigned long int *) ptr;
|
||||||
*memid = MEM_ID;
|
*memid = MEM_ID;
|
||||||
return (unsigned long int *) ((char *) ptr + sizeof(unsigned long int));
|
return (unsigned long int *) ((char *) ptr + sizeof(unsigned long int));
|
||||||
} //end of the function GetMemory
|
} //end of the function GetMemory
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
#ifdef MEMDEBUG
|
#ifdef MEMDEBUG
|
||||||
void *GetClearedMemoryDebug(unsigned long size, char *label, char *file, int line)
|
void *GetClearedMemoryDebug(unsigned long size, char *label, char *file, int line)
|
||||||
#else
|
#else
|
||||||
void *GetClearedMemory(unsigned long size)
|
void *GetClearedMemory(unsigned long size)
|
||||||
#endif //MEMDEBUG
|
#endif //MEMDEBUG
|
||||||
{
|
{
|
||||||
void *ptr;
|
void *ptr;
|
||||||
#ifdef MEMDEBUG
|
#ifdef MEMDEBUG
|
||||||
ptr = GetMemoryDebug(size, label, file, line);
|
ptr = GetMemoryDebug(size, label, file, line);
|
||||||
#else
|
#else
|
||||||
ptr = GetMemory(size);
|
ptr = GetMemory(size);
|
||||||
#endif //MEMDEBUG
|
#endif //MEMDEBUG
|
||||||
Com_Memset(ptr, 0, size);
|
Com_Memset(ptr, 0, size);
|
||||||
return ptr;
|
return ptr;
|
||||||
} //end of the function GetClearedMemory
|
} //end of the function GetClearedMemory
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
#ifdef MEMDEBUG
|
#ifdef MEMDEBUG
|
||||||
void *GetHunkMemoryDebug(unsigned long size, char *label, char *file, int line)
|
void *GetHunkMemoryDebug(unsigned long size, char *label, char *file, int line)
|
||||||
#else
|
#else
|
||||||
void *GetHunkMemory(unsigned long size)
|
void *GetHunkMemory(unsigned long size)
|
||||||
#endif //MEMDEBUG
|
#endif //MEMDEBUG
|
||||||
{
|
{
|
||||||
void *ptr;
|
void *ptr;
|
||||||
unsigned long int *memid;
|
unsigned long int *memid;
|
||||||
|
|
||||||
ptr = botimport.HunkAlloc(size + sizeof(unsigned long int));
|
ptr = botimport.HunkAlloc(size + sizeof(unsigned long int));
|
||||||
if (!ptr) return NULL;
|
if (!ptr) return NULL;
|
||||||
memid = (unsigned long int *) ptr;
|
memid = (unsigned long int *) ptr;
|
||||||
*memid = HUNK_ID;
|
*memid = HUNK_ID;
|
||||||
return (unsigned long int *) ((char *) ptr + sizeof(unsigned long int));
|
return (unsigned long int *) ((char *) ptr + sizeof(unsigned long int));
|
||||||
} //end of the function GetHunkMemory
|
} //end of the function GetHunkMemory
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
#ifdef MEMDEBUG
|
#ifdef MEMDEBUG
|
||||||
void *GetClearedHunkMemoryDebug(unsigned long size, char *label, char *file, int line)
|
void *GetClearedHunkMemoryDebug(unsigned long size, char *label, char *file, int line)
|
||||||
#else
|
#else
|
||||||
void *GetClearedHunkMemory(unsigned long size)
|
void *GetClearedHunkMemory(unsigned long size)
|
||||||
#endif //MEMDEBUG
|
#endif //MEMDEBUG
|
||||||
{
|
{
|
||||||
void *ptr;
|
void *ptr;
|
||||||
#ifdef MEMDEBUG
|
#ifdef MEMDEBUG
|
||||||
ptr = GetHunkMemoryDebug(size, label, file, line);
|
ptr = GetHunkMemoryDebug(size, label, file, line);
|
||||||
#else
|
#else
|
||||||
ptr = GetHunkMemory(size);
|
ptr = GetHunkMemory(size);
|
||||||
#endif //MEMDEBUG
|
#endif //MEMDEBUG
|
||||||
Com_Memset(ptr, 0, size);
|
Com_Memset(ptr, 0, size);
|
||||||
return ptr;
|
return ptr;
|
||||||
} //end of the function GetClearedHunkMemory
|
} //end of the function GetClearedHunkMemory
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void FreeMemory(void *ptr)
|
void FreeMemory(void *ptr)
|
||||||
{
|
{
|
||||||
unsigned long int *memid;
|
unsigned long int *memid;
|
||||||
|
|
||||||
memid = (unsigned long int *) ((char *) ptr - sizeof(unsigned long int));
|
memid = (unsigned long int *) ((char *) ptr - sizeof(unsigned long int));
|
||||||
|
|
||||||
if (*memid == MEM_ID)
|
if (*memid == MEM_ID)
|
||||||
{
|
{
|
||||||
botimport.FreeMemory(memid);
|
botimport.FreeMemory(memid);
|
||||||
} //end if
|
} //end if
|
||||||
} //end of the function FreeMemory
|
} //end of the function FreeMemory
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AvailableMemory(void)
|
int AvailableMemory(void)
|
||||||
{
|
{
|
||||||
return botimport.AvailableMemory();
|
return botimport.AvailableMemory();
|
||||||
} //end of the function AvailableMemory
|
} //end of the function AvailableMemory
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void PrintUsedMemorySize(void)
|
void PrintUsedMemorySize(void)
|
||||||
{
|
{
|
||||||
} //end of the function PrintUsedMemorySize
|
} //end of the function PrintUsedMemorySize
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void PrintMemoryLabels(void)
|
void PrintMemoryLabels(void)
|
||||||
{
|
{
|
||||||
} //end of the function PrintMemoryLabels
|
} //end of the function PrintMemoryLabels
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,76 +1,76 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: l_memory.h
|
* name: l_memory.h
|
||||||
*
|
*
|
||||||
* desc: memory management
|
* desc: memory management
|
||||||
*
|
*
|
||||||
* $Archive: /source/code/botlib/l_memory.h $
|
* $Archive: /source/code/botlib/l_memory.h $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//#define MEMDEBUG
|
//#define MEMDEBUG
|
||||||
|
|
||||||
#ifdef MEMDEBUG
|
#ifdef MEMDEBUG
|
||||||
#define GetMemory(size) GetMemoryDebug(size, #size, __FILE__, __LINE__);
|
#define GetMemory(size) GetMemoryDebug(size, #size, __FILE__, __LINE__);
|
||||||
#define GetClearedMemory(size) GetClearedMemoryDebug(size, #size, __FILE__, __LINE__);
|
#define GetClearedMemory(size) GetClearedMemoryDebug(size, #size, __FILE__, __LINE__);
|
||||||
//allocate a memory block of the given size
|
//allocate a memory block of the given size
|
||||||
void *GetMemoryDebug(unsigned long size, char *label, char *file, int line);
|
void *GetMemoryDebug(unsigned long size, char *label, char *file, int line);
|
||||||
//allocate a memory block of the given size and clear it
|
//allocate a memory block of the given size and clear it
|
||||||
void *GetClearedMemoryDebug(unsigned long size, char *label, char *file, int line);
|
void *GetClearedMemoryDebug(unsigned long size, char *label, char *file, int line);
|
||||||
//
|
//
|
||||||
#define GetHunkMemory(size) GetHunkMemoryDebug(size, #size, __FILE__, __LINE__);
|
#define GetHunkMemory(size) GetHunkMemoryDebug(size, #size, __FILE__, __LINE__);
|
||||||
#define GetClearedHunkMemory(size) GetClearedHunkMemoryDebug(size, #size, __FILE__, __LINE__);
|
#define GetClearedHunkMemory(size) GetClearedHunkMemoryDebug(size, #size, __FILE__, __LINE__);
|
||||||
//allocate a memory block of the given size
|
//allocate a memory block of the given size
|
||||||
void *GetHunkMemoryDebug(unsigned long size, char *label, char *file, int line);
|
void *GetHunkMemoryDebug(unsigned long size, char *label, char *file, int line);
|
||||||
//allocate a memory block of the given size and clear it
|
//allocate a memory block of the given size and clear it
|
||||||
void *GetClearedHunkMemoryDebug(unsigned long size, char *label, char *file, int line);
|
void *GetClearedHunkMemoryDebug(unsigned long size, char *label, char *file, int line);
|
||||||
#else
|
#else
|
||||||
//allocate a memory block of the given size
|
//allocate a memory block of the given size
|
||||||
void *GetMemory(unsigned long size);
|
void *GetMemory(unsigned long size);
|
||||||
//allocate a memory block of the given size and clear it
|
//allocate a memory block of the given size and clear it
|
||||||
void *GetClearedMemory(unsigned long size);
|
void *GetClearedMemory(unsigned long size);
|
||||||
//
|
//
|
||||||
#ifdef BSPC
|
#ifdef BSPC
|
||||||
#define GetHunkMemory GetMemory
|
#define GetHunkMemory GetMemory
|
||||||
#define GetClearedHunkMemory GetClearedMemory
|
#define GetClearedHunkMemory GetClearedMemory
|
||||||
#else
|
#else
|
||||||
//allocate a memory block of the given size
|
//allocate a memory block of the given size
|
||||||
void *GetHunkMemory(unsigned long size);
|
void *GetHunkMemory(unsigned long size);
|
||||||
//allocate a memory block of the given size and clear it
|
//allocate a memory block of the given size and clear it
|
||||||
void *GetClearedHunkMemory(unsigned long size);
|
void *GetClearedHunkMemory(unsigned long size);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//free the given memory block
|
//free the given memory block
|
||||||
void FreeMemory(void *ptr);
|
void FreeMemory(void *ptr);
|
||||||
//returns the amount available memory
|
//returns the amount available memory
|
||||||
int AvailableMemory(void);
|
int AvailableMemory(void);
|
||||||
//prints the total used memory size
|
//prints the total used memory size
|
||||||
void PrintUsedMemorySize(void);
|
void PrintUsedMemorySize(void);
|
||||||
//print all memory blocks with label
|
//print all memory blocks with label
|
||||||
void PrintMemoryLabels(void);
|
void PrintMemoryLabels(void);
|
||||||
//returns the size of the memory block in bytes
|
//returns the size of the memory block in bytes
|
||||||
int MemoryByteSize(void *ptr);
|
int MemoryByteSize(void *ptr);
|
||||||
//free all allocated memory
|
//free all allocated memory
|
||||||
void DumpMemory(void);
|
void DumpMemory(void);
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,180 +1,180 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: l_precomp.h
|
* name: l_precomp.h
|
||||||
*
|
*
|
||||||
* desc: pre compiler
|
* desc: pre compiler
|
||||||
*
|
*
|
||||||
* $Archive: /source/code/botlib/l_precomp.h $
|
* $Archive: /source/code/botlib/l_precomp.h $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#ifndef MAX_PATH
|
#ifndef MAX_PATH
|
||||||
#define MAX_PATH MAX_QPATH
|
#define MAX_PATH MAX_QPATH
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef PATH_SEPERATORSTR
|
#ifndef PATH_SEPERATORSTR
|
||||||
#if defined(WIN32)|defined(_WIN32)|defined(__NT__)|defined(__WINDOWS__)|defined(__WINDOWS_386__)
|
#if defined(WIN32)|defined(_WIN32)|defined(__NT__)|defined(__WINDOWS__)|defined(__WINDOWS_386__)
|
||||||
#define PATHSEPERATOR_STR "\\"
|
#define PATHSEPERATOR_STR "\\"
|
||||||
#else
|
#else
|
||||||
#define PATHSEPERATOR_STR "/"
|
#define PATHSEPERATOR_STR "/"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#ifndef PATH_SEPERATORCHAR
|
#ifndef PATH_SEPERATORCHAR
|
||||||
#if defined(WIN32)|defined(_WIN32)|defined(__NT__)|defined(__WINDOWS__)|defined(__WINDOWS_386__)
|
#if defined(WIN32)|defined(_WIN32)|defined(__NT__)|defined(__WINDOWS__)|defined(__WINDOWS_386__)
|
||||||
#define PATHSEPERATOR_CHAR '\\'
|
#define PATHSEPERATOR_CHAR '\\'
|
||||||
#else
|
#else
|
||||||
#define PATHSEPERATOR_CHAR '/'
|
#define PATHSEPERATOR_CHAR '/'
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(BSPC) && !defined(QDECL)
|
#if defined(BSPC) && !defined(QDECL)
|
||||||
#define QDECL
|
#define QDECL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define DEFINE_FIXED 0x0001
|
#define DEFINE_FIXED 0x0001
|
||||||
|
|
||||||
#define BUILTIN_LINE 1
|
#define BUILTIN_LINE 1
|
||||||
#define BUILTIN_FILE 2
|
#define BUILTIN_FILE 2
|
||||||
#define BUILTIN_DATE 3
|
#define BUILTIN_DATE 3
|
||||||
#define BUILTIN_TIME 4
|
#define BUILTIN_TIME 4
|
||||||
#define BUILTIN_STDC 5
|
#define BUILTIN_STDC 5
|
||||||
|
|
||||||
#define INDENT_IF 0x0001
|
#define INDENT_IF 0x0001
|
||||||
#define INDENT_ELSE 0x0002
|
#define INDENT_ELSE 0x0002
|
||||||
#define INDENT_ELIF 0x0004
|
#define INDENT_ELIF 0x0004
|
||||||
#define INDENT_IFDEF 0x0008
|
#define INDENT_IFDEF 0x0008
|
||||||
#define INDENT_IFNDEF 0x0010
|
#define INDENT_IFNDEF 0x0010
|
||||||
|
|
||||||
//macro definitions
|
//macro definitions
|
||||||
typedef struct define_s
|
typedef struct define_s
|
||||||
{
|
{
|
||||||
char *name; //define name
|
char *name; //define name
|
||||||
int flags; //define flags
|
int flags; //define flags
|
||||||
int builtin; // > 0 if builtin define
|
int builtin; // > 0 if builtin define
|
||||||
int numparms; //number of define parameters
|
int numparms; //number of define parameters
|
||||||
token_t *parms; //define parameters
|
token_t *parms; //define parameters
|
||||||
token_t *tokens; //macro tokens (possibly containing parm tokens)
|
token_t *tokens; //macro tokens (possibly containing parm tokens)
|
||||||
struct define_s *next; //next defined macro in a list
|
struct define_s *next; //next defined macro in a list
|
||||||
struct define_s *hashnext; //next define in the hash chain
|
struct define_s *hashnext; //next define in the hash chain
|
||||||
} define_t;
|
} define_t;
|
||||||
|
|
||||||
//indents
|
//indents
|
||||||
//used for conditional compilation directives:
|
//used for conditional compilation directives:
|
||||||
//#if, #else, #elif, #ifdef, #ifndef
|
//#if, #else, #elif, #ifdef, #ifndef
|
||||||
typedef struct indent_s
|
typedef struct indent_s
|
||||||
{
|
{
|
||||||
int type; //indent type
|
int type; //indent type
|
||||||
int skip; //true if skipping current indent
|
int skip; //true if skipping current indent
|
||||||
script_t *script; //script the indent was in
|
script_t *script; //script the indent was in
|
||||||
struct indent_s *next; //next indent on the indent stack
|
struct indent_s *next; //next indent on the indent stack
|
||||||
} indent_t;
|
} indent_t;
|
||||||
|
|
||||||
//source file
|
//source file
|
||||||
typedef struct source_s
|
typedef struct source_s
|
||||||
{
|
{
|
||||||
char filename[1024]; //file name of the script
|
char filename[1024]; //file name of the script
|
||||||
char includepath[1024]; //path to include files
|
char includepath[1024]; //path to include files
|
||||||
punctuation_t *punctuations; //punctuations to use
|
punctuation_t *punctuations; //punctuations to use
|
||||||
script_t *scriptstack; //stack with scripts of the source
|
script_t *scriptstack; //stack with scripts of the source
|
||||||
token_t *tokens; //tokens to read first
|
token_t *tokens; //tokens to read first
|
||||||
define_t *defines; //list with macro definitions
|
define_t *defines; //list with macro definitions
|
||||||
define_t **definehash; //hash chain with defines
|
define_t **definehash; //hash chain with defines
|
||||||
indent_t *indentstack; //stack with indents
|
indent_t *indentstack; //stack with indents
|
||||||
int skip; // > 0 if skipping conditional code
|
int skip; // > 0 if skipping conditional code
|
||||||
token_t token; //last read token
|
token_t token; //last read token
|
||||||
} source_t;
|
} source_t;
|
||||||
|
|
||||||
|
|
||||||
//read a token from the source
|
//read a token from the source
|
||||||
int PC_ReadToken(source_t *source, token_t *token);
|
int PC_ReadToken(source_t *source, token_t *token);
|
||||||
//expect a certain token
|
//expect a certain token
|
||||||
int PC_ExpectTokenString(source_t *source, char *string);
|
int PC_ExpectTokenString(source_t *source, char *string);
|
||||||
//expect a certain token type
|
//expect a certain token type
|
||||||
int PC_ExpectTokenType(source_t *source, int type, int subtype, token_t *token);
|
int PC_ExpectTokenType(source_t *source, int type, int subtype, token_t *token);
|
||||||
//expect a token
|
//expect a token
|
||||||
int PC_ExpectAnyToken(source_t *source, token_t *token);
|
int PC_ExpectAnyToken(source_t *source, token_t *token);
|
||||||
//returns true when the token is available
|
//returns true when the token is available
|
||||||
int PC_CheckTokenString(source_t *source, char *string);
|
int PC_CheckTokenString(source_t *source, char *string);
|
||||||
//returns true an reads the token when a token with the given type is available
|
//returns true an reads the token when a token with the given type is available
|
||||||
int PC_CheckTokenType(source_t *source, int type, int subtype, token_t *token);
|
int PC_CheckTokenType(source_t *source, int type, int subtype, token_t *token);
|
||||||
//skip tokens until the given token string is read
|
//skip tokens until the given token string is read
|
||||||
int PC_SkipUntilString(source_t *source, char *string);
|
int PC_SkipUntilString(source_t *source, char *string);
|
||||||
//unread the last token read from the script
|
//unread the last token read from the script
|
||||||
void PC_UnreadLastToken(source_t *source);
|
void PC_UnreadLastToken(source_t *source);
|
||||||
//unread the given token
|
//unread the given token
|
||||||
void PC_UnreadToken(source_t *source, token_t *token);
|
void PC_UnreadToken(source_t *source, token_t *token);
|
||||||
//read a token only if on the same line, lines are concatenated with a slash
|
//read a token only if on the same line, lines are concatenated with a slash
|
||||||
int PC_ReadLine(source_t *source, token_t *token);
|
int PC_ReadLine(source_t *source, token_t *token);
|
||||||
//returns true if there was a white space in front of the token
|
//returns true if there was a white space in front of the token
|
||||||
int PC_WhiteSpaceBeforeToken(token_t *token);
|
int PC_WhiteSpaceBeforeToken(token_t *token);
|
||||||
//add a define to the source
|
//add a define to the source
|
||||||
int PC_AddDefine(source_t *source, char *string);
|
int PC_AddDefine(source_t *source, char *string);
|
||||||
//add a globals define that will be added to all opened sources
|
//add a globals define that will be added to all opened sources
|
||||||
int PC_AddGlobalDefine(char *string);
|
int PC_AddGlobalDefine(char *string);
|
||||||
//remove the given global define
|
//remove the given global define
|
||||||
int PC_RemoveGlobalDefine(char *name);
|
int PC_RemoveGlobalDefine(char *name);
|
||||||
//remove all globals defines
|
//remove all globals defines
|
||||||
void PC_RemoveAllGlobalDefines(void);
|
void PC_RemoveAllGlobalDefines(void);
|
||||||
//add builtin defines
|
//add builtin defines
|
||||||
void PC_AddBuiltinDefines(source_t *source);
|
void PC_AddBuiltinDefines(source_t *source);
|
||||||
//set the source include path
|
//set the source include path
|
||||||
void PC_SetIncludePath(source_t *source, char *path);
|
void PC_SetIncludePath(source_t *source, char *path);
|
||||||
//set the punction set
|
//set the punction set
|
||||||
void PC_SetPunctuations(source_t *source, punctuation_t *p);
|
void PC_SetPunctuations(source_t *source, punctuation_t *p);
|
||||||
//set the base folder to load files from
|
//set the base folder to load files from
|
||||||
void PC_SetBaseFolder(char *path);
|
void PC_SetBaseFolder(char *path);
|
||||||
//load a source file
|
//load a source file
|
||||||
source_t *LoadSourceFile(const char *filename);
|
source_t *LoadSourceFile(const char *filename);
|
||||||
//load a source from memory
|
//load a source from memory
|
||||||
source_t *LoadSourceMemory(char *ptr, int length, char *name);
|
source_t *LoadSourceMemory(char *ptr, int length, char *name);
|
||||||
//free the given source
|
//free the given source
|
||||||
void FreeSource(source_t *source);
|
void FreeSource(source_t *source);
|
||||||
//print a source error
|
//print a source error
|
||||||
void QDECL SourceError(source_t *source, char *str, ...);
|
void QDECL SourceError(source_t *source, char *str, ...);
|
||||||
//print a source warning
|
//print a source warning
|
||||||
void QDECL SourceWarning(source_t *source, char *str, ...);
|
void QDECL SourceWarning(source_t *source, char *str, ...);
|
||||||
|
|
||||||
#ifdef BSPC
|
#ifdef BSPC
|
||||||
// some of BSPC source does include game/q_shared.h and some does not
|
// some of BSPC source does include game/q_shared.h and some does not
|
||||||
// we define pc_token_s pc_token_t if needed (yes, it's ugly)
|
// we define pc_token_s pc_token_t if needed (yes, it's ugly)
|
||||||
#ifndef __Q_SHARED_H
|
#ifndef __Q_SHARED_H
|
||||||
#define MAX_TOKENLENGTH 1024
|
#define MAX_TOKENLENGTH 1024
|
||||||
typedef struct pc_token_s
|
typedef struct pc_token_s
|
||||||
{
|
{
|
||||||
int type;
|
int type;
|
||||||
int subtype;
|
int subtype;
|
||||||
int intvalue;
|
int intvalue;
|
||||||
float floatvalue;
|
float floatvalue;
|
||||||
char string[MAX_TOKENLENGTH];
|
char string[MAX_TOKENLENGTH];
|
||||||
} pc_token_t;
|
} pc_token_t;
|
||||||
#endif //!_Q_SHARED_H
|
#endif //!_Q_SHARED_H
|
||||||
#endif //BSPC
|
#endif //BSPC
|
||||||
|
|
||||||
//
|
//
|
||||||
int PC_LoadSourceHandle(const char *filename);
|
int PC_LoadSourceHandle(const char *filename);
|
||||||
int PC_FreeSourceHandle(int handle);
|
int PC_FreeSourceHandle(int handle);
|
||||||
int PC_ReadTokenHandle(int handle, pc_token_t *pc_token);
|
int PC_ReadTokenHandle(int handle, pc_token_t *pc_token);
|
||||||
int PC_SourceFileAndLine(int handle, char *filename, int *line);
|
int PC_SourceFileAndLine(int handle, char *filename, int *line);
|
||||||
void PC_CheckOpenSourceHandles(void);
|
void PC_CheckOpenSourceHandles(void);
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,247 +1,247 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: l_script.h
|
* name: l_script.h
|
||||||
*
|
*
|
||||||
* desc: lexicographical parser
|
* desc: lexicographical parser
|
||||||
*
|
*
|
||||||
* $Archive: /source/code/botlib/l_script.h $
|
* $Archive: /source/code/botlib/l_script.h $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//undef if binary numbers of the form 0b... or 0B... are not allowed
|
//undef if binary numbers of the form 0b... or 0B... are not allowed
|
||||||
#define BINARYNUMBERS
|
#define BINARYNUMBERS
|
||||||
//undef if not using the token.intvalue and token.floatvalue
|
//undef if not using the token.intvalue and token.floatvalue
|
||||||
#define NUMBERVALUE
|
#define NUMBERVALUE
|
||||||
//use dollar sign also as punctuation
|
//use dollar sign also as punctuation
|
||||||
#define DOLLAR
|
#define DOLLAR
|
||||||
|
|
||||||
//maximum token length
|
//maximum token length
|
||||||
#define MAX_TOKEN 1024
|
#define MAX_TOKEN 1024
|
||||||
|
|
||||||
#if defined(BSPC) && !defined(QDECL)
|
#if defined(BSPC) && !defined(QDECL)
|
||||||
#define QDECL
|
#define QDECL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//script flags
|
//script flags
|
||||||
#define SCFL_NOERRORS 0x0001
|
#define SCFL_NOERRORS 0x0001
|
||||||
#define SCFL_NOWARNINGS 0x0002
|
#define SCFL_NOWARNINGS 0x0002
|
||||||
#define SCFL_NOSTRINGWHITESPACES 0x0004
|
#define SCFL_NOSTRINGWHITESPACES 0x0004
|
||||||
#define SCFL_NOSTRINGESCAPECHARS 0x0008
|
#define SCFL_NOSTRINGESCAPECHARS 0x0008
|
||||||
#define SCFL_PRIMITIVE 0x0010
|
#define SCFL_PRIMITIVE 0x0010
|
||||||
#define SCFL_NOBINARYNUMBERS 0x0020
|
#define SCFL_NOBINARYNUMBERS 0x0020
|
||||||
#define SCFL_NONUMBERVALUES 0x0040
|
#define SCFL_NONUMBERVALUES 0x0040
|
||||||
|
|
||||||
//token types
|
//token types
|
||||||
#define TT_STRING 1 // string
|
#define TT_STRING 1 // string
|
||||||
#define TT_LITERAL 2 // literal
|
#define TT_LITERAL 2 // literal
|
||||||
#define TT_NUMBER 3 // number
|
#define TT_NUMBER 3 // number
|
||||||
#define TT_NAME 4 // name
|
#define TT_NAME 4 // name
|
||||||
#define TT_PUNCTUATION 5 // punctuation
|
#define TT_PUNCTUATION 5 // punctuation
|
||||||
|
|
||||||
//string sub type
|
//string sub type
|
||||||
//---------------
|
//---------------
|
||||||
// the length of the string
|
// the length of the string
|
||||||
//literal sub type
|
//literal sub type
|
||||||
//----------------
|
//----------------
|
||||||
// the ASCII code of the literal
|
// the ASCII code of the literal
|
||||||
//number sub type
|
//number sub type
|
||||||
//---------------
|
//---------------
|
||||||
#define TT_DECIMAL 0x0008 // decimal number
|
#define TT_DECIMAL 0x0008 // decimal number
|
||||||
#define TT_HEX 0x0100 // hexadecimal number
|
#define TT_HEX 0x0100 // hexadecimal number
|
||||||
#define TT_OCTAL 0x0200 // octal number
|
#define TT_OCTAL 0x0200 // octal number
|
||||||
#ifdef BINARYNUMBERS
|
#ifdef BINARYNUMBERS
|
||||||
#define TT_BINARY 0x0400 // binary number
|
#define TT_BINARY 0x0400 // binary number
|
||||||
#endif //BINARYNUMBERS
|
#endif //BINARYNUMBERS
|
||||||
#define TT_FLOAT 0x0800 // floating point number
|
#define TT_FLOAT 0x0800 // floating point number
|
||||||
#define TT_INTEGER 0x1000 // integer number
|
#define TT_INTEGER 0x1000 // integer number
|
||||||
#define TT_LONG 0x2000 // long number
|
#define TT_LONG 0x2000 // long number
|
||||||
#define TT_UNSIGNED 0x4000 // unsigned number
|
#define TT_UNSIGNED 0x4000 // unsigned number
|
||||||
//punctuation sub type
|
//punctuation sub type
|
||||||
//--------------------
|
//--------------------
|
||||||
#define P_RSHIFT_ASSIGN 1
|
#define P_RSHIFT_ASSIGN 1
|
||||||
#define P_LSHIFT_ASSIGN 2
|
#define P_LSHIFT_ASSIGN 2
|
||||||
#define P_PARMS 3
|
#define P_PARMS 3
|
||||||
#define P_PRECOMPMERGE 4
|
#define P_PRECOMPMERGE 4
|
||||||
|
|
||||||
#define P_LOGIC_AND 5
|
#define P_LOGIC_AND 5
|
||||||
#define P_LOGIC_OR 6
|
#define P_LOGIC_OR 6
|
||||||
#define P_LOGIC_GEQ 7
|
#define P_LOGIC_GEQ 7
|
||||||
#define P_LOGIC_LEQ 8
|
#define P_LOGIC_LEQ 8
|
||||||
#define P_LOGIC_EQ 9
|
#define P_LOGIC_EQ 9
|
||||||
#define P_LOGIC_UNEQ 10
|
#define P_LOGIC_UNEQ 10
|
||||||
|
|
||||||
#define P_MUL_ASSIGN 11
|
#define P_MUL_ASSIGN 11
|
||||||
#define P_DIV_ASSIGN 12
|
#define P_DIV_ASSIGN 12
|
||||||
#define P_MOD_ASSIGN 13
|
#define P_MOD_ASSIGN 13
|
||||||
#define P_ADD_ASSIGN 14
|
#define P_ADD_ASSIGN 14
|
||||||
#define P_SUB_ASSIGN 15
|
#define P_SUB_ASSIGN 15
|
||||||
#define P_INC 16
|
#define P_INC 16
|
||||||
#define P_DEC 17
|
#define P_DEC 17
|
||||||
|
|
||||||
#define P_BIN_AND_ASSIGN 18
|
#define P_BIN_AND_ASSIGN 18
|
||||||
#define P_BIN_OR_ASSIGN 19
|
#define P_BIN_OR_ASSIGN 19
|
||||||
#define P_BIN_XOR_ASSIGN 20
|
#define P_BIN_XOR_ASSIGN 20
|
||||||
#define P_RSHIFT 21
|
#define P_RSHIFT 21
|
||||||
#define P_LSHIFT 22
|
#define P_LSHIFT 22
|
||||||
|
|
||||||
#define P_POINTERREF 23
|
#define P_POINTERREF 23
|
||||||
#define P_CPP1 24
|
#define P_CPP1 24
|
||||||
#define P_CPP2 25
|
#define P_CPP2 25
|
||||||
#define P_MUL 26
|
#define P_MUL 26
|
||||||
#define P_DIV 27
|
#define P_DIV 27
|
||||||
#define P_MOD 28
|
#define P_MOD 28
|
||||||
#define P_ADD 29
|
#define P_ADD 29
|
||||||
#define P_SUB 30
|
#define P_SUB 30
|
||||||
#define P_ASSIGN 31
|
#define P_ASSIGN 31
|
||||||
|
|
||||||
#define P_BIN_AND 32
|
#define P_BIN_AND 32
|
||||||
#define P_BIN_OR 33
|
#define P_BIN_OR 33
|
||||||
#define P_BIN_XOR 34
|
#define P_BIN_XOR 34
|
||||||
#define P_BIN_NOT 35
|
#define P_BIN_NOT 35
|
||||||
|
|
||||||
#define P_LOGIC_NOT 36
|
#define P_LOGIC_NOT 36
|
||||||
#define P_LOGIC_GREATER 37
|
#define P_LOGIC_GREATER 37
|
||||||
#define P_LOGIC_LESS 38
|
#define P_LOGIC_LESS 38
|
||||||
|
|
||||||
#define P_REF 39
|
#define P_REF 39
|
||||||
#define P_COMMA 40
|
#define P_COMMA 40
|
||||||
#define P_SEMICOLON 41
|
#define P_SEMICOLON 41
|
||||||
#define P_COLON 42
|
#define P_COLON 42
|
||||||
#define P_QUESTIONMARK 43
|
#define P_QUESTIONMARK 43
|
||||||
|
|
||||||
#define P_PARENTHESESOPEN 44
|
#define P_PARENTHESESOPEN 44
|
||||||
#define P_PARENTHESESCLOSE 45
|
#define P_PARENTHESESCLOSE 45
|
||||||
#define P_BRACEOPEN 46
|
#define P_BRACEOPEN 46
|
||||||
#define P_BRACECLOSE 47
|
#define P_BRACECLOSE 47
|
||||||
#define P_SQBRACKETOPEN 48
|
#define P_SQBRACKETOPEN 48
|
||||||
#define P_SQBRACKETCLOSE 49
|
#define P_SQBRACKETCLOSE 49
|
||||||
#define P_BACKSLASH 50
|
#define P_BACKSLASH 50
|
||||||
|
|
||||||
#define P_PRECOMP 51
|
#define P_PRECOMP 51
|
||||||
#define P_DOLLAR 52
|
#define P_DOLLAR 52
|
||||||
//name sub type
|
//name sub type
|
||||||
//-------------
|
//-------------
|
||||||
// the length of the name
|
// the length of the name
|
||||||
|
|
||||||
//punctuation
|
//punctuation
|
||||||
typedef struct punctuation_s
|
typedef struct punctuation_s
|
||||||
{
|
{
|
||||||
char *p; //punctuation character(s)
|
char *p; //punctuation character(s)
|
||||||
int n; //punctuation indication
|
int n; //punctuation indication
|
||||||
struct punctuation_s *next; //next punctuation
|
struct punctuation_s *next; //next punctuation
|
||||||
} punctuation_t;
|
} punctuation_t;
|
||||||
|
|
||||||
//token
|
//token
|
||||||
typedef struct token_s
|
typedef struct token_s
|
||||||
{
|
{
|
||||||
char string[MAX_TOKEN]; //available token
|
char string[MAX_TOKEN]; //available token
|
||||||
int type; //last read token type
|
int type; //last read token type
|
||||||
int subtype; //last read token sub type
|
int subtype; //last read token sub type
|
||||||
#ifdef NUMBERVALUE
|
#ifdef NUMBERVALUE
|
||||||
unsigned long int intvalue; //integer value
|
unsigned long int intvalue; //integer value
|
||||||
long double floatvalue; //floating point value
|
long double floatvalue; //floating point value
|
||||||
#endif //NUMBERVALUE
|
#endif //NUMBERVALUE
|
||||||
char *whitespace_p; //start of white space before token
|
char *whitespace_p; //start of white space before token
|
||||||
char *endwhitespace_p; //start of white space before token
|
char *endwhitespace_p; //start of white space before token
|
||||||
int line; //line the token was on
|
int line; //line the token was on
|
||||||
int linescrossed; //lines crossed in white space
|
int linescrossed; //lines crossed in white space
|
||||||
struct token_s *next; //next token in chain
|
struct token_s *next; //next token in chain
|
||||||
} token_t;
|
} token_t;
|
||||||
|
|
||||||
//script file
|
//script file
|
||||||
typedef struct script_s
|
typedef struct script_s
|
||||||
{
|
{
|
||||||
char filename[1024]; //file name of the script
|
char filename[1024]; //file name of the script
|
||||||
char *buffer; //buffer containing the script
|
char *buffer; //buffer containing the script
|
||||||
char *script_p; //current pointer in the script
|
char *script_p; //current pointer in the script
|
||||||
char *end_p; //pointer to the end of the script
|
char *end_p; //pointer to the end of the script
|
||||||
char *lastscript_p; //script pointer before reading token
|
char *lastscript_p; //script pointer before reading token
|
||||||
char *whitespace_p; //begin of the white space
|
char *whitespace_p; //begin of the white space
|
||||||
char *endwhitespace_p; //end of the white space
|
char *endwhitespace_p; //end of the white space
|
||||||
int length; //length of the script in bytes
|
int length; //length of the script in bytes
|
||||||
int line; //current line in script
|
int line; //current line in script
|
||||||
int lastline; //line before reading token
|
int lastline; //line before reading token
|
||||||
int tokenavailable; //set by UnreadLastToken
|
int tokenavailable; //set by UnreadLastToken
|
||||||
int flags; //several script flags
|
int flags; //several script flags
|
||||||
punctuation_t *punctuations; //the punctuations used in the script
|
punctuation_t *punctuations; //the punctuations used in the script
|
||||||
punctuation_t **punctuationtable;
|
punctuation_t **punctuationtable;
|
||||||
token_t token; //available token
|
token_t token; //available token
|
||||||
struct script_s *next; //next script in a chain
|
struct script_s *next; //next script in a chain
|
||||||
} script_t;
|
} script_t;
|
||||||
|
|
||||||
//read a token from the script
|
//read a token from the script
|
||||||
int PS_ReadToken(script_t *script, token_t *token);
|
int PS_ReadToken(script_t *script, token_t *token);
|
||||||
//expect a certain token
|
//expect a certain token
|
||||||
int PS_ExpectTokenString(script_t *script, char *string);
|
int PS_ExpectTokenString(script_t *script, char *string);
|
||||||
//expect a certain token type
|
//expect a certain token type
|
||||||
int PS_ExpectTokenType(script_t *script, int type, int subtype, token_t *token);
|
int PS_ExpectTokenType(script_t *script, int type, int subtype, token_t *token);
|
||||||
//expect a token
|
//expect a token
|
||||||
int PS_ExpectAnyToken(script_t *script, token_t *token);
|
int PS_ExpectAnyToken(script_t *script, token_t *token);
|
||||||
//returns true when the token is available
|
//returns true when the token is available
|
||||||
int PS_CheckTokenString(script_t *script, char *string);
|
int PS_CheckTokenString(script_t *script, char *string);
|
||||||
//returns true an reads the token when a token with the given type is available
|
//returns true an reads the token when a token with the given type is available
|
||||||
int PS_CheckTokenType(script_t *script, int type, int subtype, token_t *token);
|
int PS_CheckTokenType(script_t *script, int type, int subtype, token_t *token);
|
||||||
//skip tokens until the given token string is read
|
//skip tokens until the given token string is read
|
||||||
int PS_SkipUntilString(script_t *script, char *string);
|
int PS_SkipUntilString(script_t *script, char *string);
|
||||||
//unread the last token read from the script
|
//unread the last token read from the script
|
||||||
void PS_UnreadLastToken(script_t *script);
|
void PS_UnreadLastToken(script_t *script);
|
||||||
//unread the given token
|
//unread the given token
|
||||||
void PS_UnreadToken(script_t *script, token_t *token);
|
void PS_UnreadToken(script_t *script, token_t *token);
|
||||||
//returns the next character of the read white space, returns NULL if none
|
//returns the next character of the read white space, returns NULL if none
|
||||||
char PS_NextWhiteSpaceChar(script_t *script);
|
char PS_NextWhiteSpaceChar(script_t *script);
|
||||||
//remove any leading and trailing double quotes from the token
|
//remove any leading and trailing double quotes from the token
|
||||||
void StripDoubleQuotes(char *string);
|
void StripDoubleQuotes(char *string);
|
||||||
//remove any leading and trailing single quotes from the token
|
//remove any leading and trailing single quotes from the token
|
||||||
void StripSingleQuotes(char *string);
|
void StripSingleQuotes(char *string);
|
||||||
//read a possible signed integer
|
//read a possible signed integer
|
||||||
signed long int ReadSignedInt(script_t *script);
|
signed long int ReadSignedInt(script_t *script);
|
||||||
//read a possible signed floating point number
|
//read a possible signed floating point number
|
||||||
long double ReadSignedFloat(script_t *script);
|
long double ReadSignedFloat(script_t *script);
|
||||||
//set an array with punctuations, NULL restores default C/C++ set
|
//set an array with punctuations, NULL restores default C/C++ set
|
||||||
void SetScriptPunctuations(script_t *script, punctuation_t *p);
|
void SetScriptPunctuations(script_t *script, punctuation_t *p);
|
||||||
//set script flags
|
//set script flags
|
||||||
void SetScriptFlags(script_t *script, int flags);
|
void SetScriptFlags(script_t *script, int flags);
|
||||||
//get script flags
|
//get script flags
|
||||||
int GetScriptFlags(script_t *script);
|
int GetScriptFlags(script_t *script);
|
||||||
//reset a script
|
//reset a script
|
||||||
void ResetScript(script_t *script);
|
void ResetScript(script_t *script);
|
||||||
//returns true if at the end of the script
|
//returns true if at the end of the script
|
||||||
int EndOfScript(script_t *script);
|
int EndOfScript(script_t *script);
|
||||||
//returns a pointer to the punctuation with the given number
|
//returns a pointer to the punctuation with the given number
|
||||||
char *PunctuationFromNum(script_t *script, int num);
|
char *PunctuationFromNum(script_t *script, int num);
|
||||||
//load a script from the given file at the given offset with the given length
|
//load a script from the given file at the given offset with the given length
|
||||||
script_t *LoadScriptFile(const char *filename);
|
script_t *LoadScriptFile(const char *filename);
|
||||||
//load a script from the given memory with the given length
|
//load a script from the given memory with the given length
|
||||||
script_t *LoadScriptMemory(char *ptr, int length, char *name);
|
script_t *LoadScriptMemory(char *ptr, int length, char *name);
|
||||||
//free a script
|
//free a script
|
||||||
void FreeScript(script_t *script);
|
void FreeScript(script_t *script);
|
||||||
//set the base folder to load files from
|
//set the base folder to load files from
|
||||||
void PS_SetBaseFolder(char *path);
|
void PS_SetBaseFolder(char *path);
|
||||||
//print a script error with filename and line number
|
//print a script error with filename and line number
|
||||||
void QDECL ScriptError(script_t *script, char *str, ...);
|
void QDECL ScriptError(script_t *script, char *str, ...);
|
||||||
//print a script warning with filename and line number
|
//print a script warning with filename and line number
|
||||||
void QDECL ScriptWarning(script_t *script, char *str, ...);
|
void QDECL ScriptWarning(script_t *script, char *str, ...);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,462 +1,462 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: l_struct.c
|
* name: l_struct.c
|
||||||
*
|
*
|
||||||
* desc: structure reading / writing
|
* desc: structure reading / writing
|
||||||
*
|
*
|
||||||
* $Archive: /MissionPack/CODE/botlib/l_struct.c $
|
* $Archive: /MissionPack/CODE/botlib/l_struct.c $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#ifdef BOTLIB
|
#ifdef BOTLIB
|
||||||
#include "../game/q_shared.h"
|
#include "../game/q_shared.h"
|
||||||
#include "../game/botlib.h" //for the include of be_interface.h
|
#include "../game/botlib.h" //for the include of be_interface.h
|
||||||
#include "l_script.h"
|
#include "l_script.h"
|
||||||
#include "l_precomp.h"
|
#include "l_precomp.h"
|
||||||
#include "l_struct.h"
|
#include "l_struct.h"
|
||||||
#include "l_utils.h"
|
#include "l_utils.h"
|
||||||
#include "be_interface.h"
|
#include "be_interface.h"
|
||||||
#endif //BOTLIB
|
#endif //BOTLIB
|
||||||
|
|
||||||
#ifdef BSPC
|
#ifdef BSPC
|
||||||
//include files for usage in the BSP Converter
|
//include files for usage in the BSP Converter
|
||||||
#include "../bspc/qbsp.h"
|
#include "../bspc/qbsp.h"
|
||||||
#include "../bspc/l_log.h"
|
#include "../bspc/l_log.h"
|
||||||
#include "../bspc/l_mem.h"
|
#include "../bspc/l_mem.h"
|
||||||
#include "l_precomp.h"
|
#include "l_precomp.h"
|
||||||
#include "l_struct.h"
|
#include "l_struct.h"
|
||||||
|
|
||||||
#define qtrue true
|
#define qtrue true
|
||||||
#define qfalse false
|
#define qfalse false
|
||||||
#endif //BSPC
|
#endif //BSPC
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
fielddef_t *FindField(fielddef_t *defs, char *name)
|
fielddef_t *FindField(fielddef_t *defs, char *name)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; defs[i].name; i++)
|
for (i = 0; defs[i].name; i++)
|
||||||
{
|
{
|
||||||
if (!strcmp(defs[i].name, name)) return &defs[i];
|
if (!strcmp(defs[i].name, name)) return &defs[i];
|
||||||
} //end for
|
} //end for
|
||||||
return NULL;
|
return NULL;
|
||||||
} //end of the function FindField
|
} //end of the function FindField
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
qboolean ReadNumber(source_t *source, fielddef_t *fd, void *p)
|
qboolean ReadNumber(source_t *source, fielddef_t *fd, void *p)
|
||||||
{
|
{
|
||||||
token_t token;
|
token_t token;
|
||||||
int negative = qfalse;
|
int negative = qfalse;
|
||||||
long int intval, intmin = 0, intmax = 0;
|
long int intval, intmin = 0, intmax = 0;
|
||||||
double floatval;
|
double floatval;
|
||||||
|
|
||||||
if (!PC_ExpectAnyToken(source, &token)) return 0;
|
if (!PC_ExpectAnyToken(source, &token)) return 0;
|
||||||
|
|
||||||
//check for minus sign
|
//check for minus sign
|
||||||
if (token.type == TT_PUNCTUATION)
|
if (token.type == TT_PUNCTUATION)
|
||||||
{
|
{
|
||||||
if (fd->type & FT_UNSIGNED)
|
if (fd->type & FT_UNSIGNED)
|
||||||
{
|
{
|
||||||
SourceError(source, "expected unsigned value, found %s", token.string);
|
SourceError(source, "expected unsigned value, found %s", token.string);
|
||||||
return 0;
|
return 0;
|
||||||
} //end if
|
} //end if
|
||||||
//if not a minus sign
|
//if not a minus sign
|
||||||
if (strcmp(token.string, "-"))
|
if (strcmp(token.string, "-"))
|
||||||
{
|
{
|
||||||
SourceError(source, "unexpected punctuation %s", token.string);
|
SourceError(source, "unexpected punctuation %s", token.string);
|
||||||
return 0;
|
return 0;
|
||||||
} //end if
|
} //end if
|
||||||
negative = qtrue;
|
negative = qtrue;
|
||||||
//read the number
|
//read the number
|
||||||
if (!PC_ExpectAnyToken(source, &token)) return 0;
|
if (!PC_ExpectAnyToken(source, &token)) return 0;
|
||||||
} //end if
|
} //end if
|
||||||
//check if it is a number
|
//check if it is a number
|
||||||
if (token.type != TT_NUMBER)
|
if (token.type != TT_NUMBER)
|
||||||
{
|
{
|
||||||
SourceError(source, "expected number, found %s", token.string);
|
SourceError(source, "expected number, found %s", token.string);
|
||||||
return 0;
|
return 0;
|
||||||
} //end if
|
} //end if
|
||||||
//check for a float value
|
//check for a float value
|
||||||
if (token.subtype & TT_FLOAT)
|
if (token.subtype & TT_FLOAT)
|
||||||
{
|
{
|
||||||
if ((fd->type & FT_TYPE) != FT_FLOAT)
|
if ((fd->type & FT_TYPE) != FT_FLOAT)
|
||||||
{
|
{
|
||||||
SourceError(source, "unexpected float");
|
SourceError(source, "unexpected float");
|
||||||
return 0;
|
return 0;
|
||||||
} //end if
|
} //end if
|
||||||
floatval = token.floatvalue;
|
floatval = token.floatvalue;
|
||||||
if (negative) floatval = -floatval;
|
if (negative) floatval = -floatval;
|
||||||
if (fd->type & FT_BOUNDED)
|
if (fd->type & FT_BOUNDED)
|
||||||
{
|
{
|
||||||
if (floatval < fd->floatmin || floatval > fd->floatmax)
|
if (floatval < fd->floatmin || floatval > fd->floatmax)
|
||||||
{
|
{
|
||||||
SourceError(source, "float out of range [%f, %f]", fd->floatmin, fd->floatmax);
|
SourceError(source, "float out of range [%f, %f]", fd->floatmin, fd->floatmax);
|
||||||
return 0;
|
return 0;
|
||||||
} //end if
|
} //end if
|
||||||
} //end if
|
} //end if
|
||||||
*(float *) p = (float) floatval;
|
*(float *) p = (float) floatval;
|
||||||
return 1;
|
return 1;
|
||||||
} //end if
|
} //end if
|
||||||
//
|
//
|
||||||
intval = token.intvalue;
|
intval = token.intvalue;
|
||||||
if (negative) intval = -intval;
|
if (negative) intval = -intval;
|
||||||
//check bounds
|
//check bounds
|
||||||
if ((fd->type & FT_TYPE) == FT_CHAR)
|
if ((fd->type & FT_TYPE) == FT_CHAR)
|
||||||
{
|
{
|
||||||
if (fd->type & FT_UNSIGNED) {intmin = 0; intmax = 255;}
|
if (fd->type & FT_UNSIGNED) {intmin = 0; intmax = 255;}
|
||||||
else {intmin = -128; intmax = 127;}
|
else {intmin = -128; intmax = 127;}
|
||||||
} //end if
|
} //end if
|
||||||
if ((fd->type & FT_TYPE) == FT_INT)
|
if ((fd->type & FT_TYPE) == FT_INT)
|
||||||
{
|
{
|
||||||
if (fd->type & FT_UNSIGNED) {intmin = 0; intmax = 65535;}
|
if (fd->type & FT_UNSIGNED) {intmin = 0; intmax = 65535;}
|
||||||
else {intmin = -32768; intmax = 32767;}
|
else {intmin = -32768; intmax = 32767;}
|
||||||
} //end else if
|
} //end else if
|
||||||
if ((fd->type & FT_TYPE) == FT_CHAR || (fd->type & FT_TYPE) == FT_INT)
|
if ((fd->type & FT_TYPE) == FT_CHAR || (fd->type & FT_TYPE) == FT_INT)
|
||||||
{
|
{
|
||||||
if (fd->type & FT_BOUNDED)
|
if (fd->type & FT_BOUNDED)
|
||||||
{
|
{
|
||||||
intmin = Maximum(intmin, fd->floatmin);
|
intmin = Maximum(intmin, fd->floatmin);
|
||||||
intmax = Minimum(intmax, fd->floatmax);
|
intmax = Minimum(intmax, fd->floatmax);
|
||||||
} //end if
|
} //end if
|
||||||
if (intval < intmin || intval > intmax)
|
if (intval < intmin || intval > intmax)
|
||||||
{
|
{
|
||||||
SourceError(source, "value %d out of range [%d, %d]", intval, intmin, intmax);
|
SourceError(source, "value %d out of range [%d, %d]", intval, intmin, intmax);
|
||||||
return 0;
|
return 0;
|
||||||
} //end if
|
} //end if
|
||||||
} //end if
|
} //end if
|
||||||
else if ((fd->type & FT_TYPE) == FT_FLOAT)
|
else if ((fd->type & FT_TYPE) == FT_FLOAT)
|
||||||
{
|
{
|
||||||
if (fd->type & FT_BOUNDED)
|
if (fd->type & FT_BOUNDED)
|
||||||
{
|
{
|
||||||
if (intval < fd->floatmin || intval > fd->floatmax)
|
if (intval < fd->floatmin || intval > fd->floatmax)
|
||||||
{
|
{
|
||||||
SourceError(source, "value %d out of range [%f, %f]", intval, fd->floatmin, fd->floatmax);
|
SourceError(source, "value %d out of range [%f, %f]", intval, fd->floatmin, fd->floatmax);
|
||||||
return 0;
|
return 0;
|
||||||
} //end if
|
} //end if
|
||||||
} //end if
|
} //end if
|
||||||
} //end else if
|
} //end else if
|
||||||
//store the value
|
//store the value
|
||||||
if ((fd->type & FT_TYPE) == FT_CHAR)
|
if ((fd->type & FT_TYPE) == FT_CHAR)
|
||||||
{
|
{
|
||||||
if (fd->type & FT_UNSIGNED) *(unsigned char *) p = (unsigned char) intval;
|
if (fd->type & FT_UNSIGNED) *(unsigned char *) p = (unsigned char) intval;
|
||||||
else *(char *) p = (char) intval;
|
else *(char *) p = (char) intval;
|
||||||
} //end if
|
} //end if
|
||||||
else if ((fd->type & FT_TYPE) == FT_INT)
|
else if ((fd->type & FT_TYPE) == FT_INT)
|
||||||
{
|
{
|
||||||
if (fd->type & FT_UNSIGNED) *(unsigned int *) p = (unsigned int) intval;
|
if (fd->type & FT_UNSIGNED) *(unsigned int *) p = (unsigned int) intval;
|
||||||
else *(int *) p = (int) intval;
|
else *(int *) p = (int) intval;
|
||||||
} //end else
|
} //end else
|
||||||
else if ((fd->type & FT_TYPE) == FT_FLOAT)
|
else if ((fd->type & FT_TYPE) == FT_FLOAT)
|
||||||
{
|
{
|
||||||
*(float *) p = (float) intval;
|
*(float *) p = (float) intval;
|
||||||
} //end else
|
} //end else
|
||||||
return 1;
|
return 1;
|
||||||
} //end of the function ReadNumber
|
} //end of the function ReadNumber
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
qboolean ReadChar(source_t *source, fielddef_t *fd, void *p)
|
qboolean ReadChar(source_t *source, fielddef_t *fd, void *p)
|
||||||
{
|
{
|
||||||
token_t token;
|
token_t token;
|
||||||
|
|
||||||
if (!PC_ExpectAnyToken(source, &token)) return 0;
|
if (!PC_ExpectAnyToken(source, &token)) return 0;
|
||||||
|
|
||||||
//take literals into account
|
//take literals into account
|
||||||
if (token.type == TT_LITERAL)
|
if (token.type == TT_LITERAL)
|
||||||
{
|
{
|
||||||
StripSingleQuotes(token.string);
|
StripSingleQuotes(token.string);
|
||||||
*(char *) p = token.string[0];
|
*(char *) p = token.string[0];
|
||||||
} //end if
|
} //end if
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PC_UnreadLastToken(source);
|
PC_UnreadLastToken(source);
|
||||||
if (!ReadNumber(source, fd, p)) return 0;
|
if (!ReadNumber(source, fd, p)) return 0;
|
||||||
} //end if
|
} //end if
|
||||||
return 1;
|
return 1;
|
||||||
} //end of the function ReadChar
|
} //end of the function ReadChar
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int ReadString(source_t *source, fielddef_t *fd, void *p)
|
int ReadString(source_t *source, fielddef_t *fd, void *p)
|
||||||
{
|
{
|
||||||
token_t token;
|
token_t token;
|
||||||
|
|
||||||
if (!PC_ExpectTokenType(source, TT_STRING, 0, &token)) return 0;
|
if (!PC_ExpectTokenType(source, TT_STRING, 0, &token)) return 0;
|
||||||
//remove the double quotes
|
//remove the double quotes
|
||||||
StripDoubleQuotes(token.string);
|
StripDoubleQuotes(token.string);
|
||||||
//copy the string
|
//copy the string
|
||||||
strncpy((char *) p, token.string, MAX_STRINGFIELD);
|
strncpy((char *) p, token.string, MAX_STRINGFIELD);
|
||||||
//make sure the string is closed with a zero
|
//make sure the string is closed with a zero
|
||||||
((char *)p)[MAX_STRINGFIELD-1] = '\0';
|
((char *)p)[MAX_STRINGFIELD-1] = '\0';
|
||||||
//
|
//
|
||||||
return 1;
|
return 1;
|
||||||
} //end of the function ReadString
|
} //end of the function ReadString
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int ReadStructure(source_t *source, structdef_t *def, char *structure)
|
int ReadStructure(source_t *source, structdef_t *def, char *structure)
|
||||||
{
|
{
|
||||||
token_t token;
|
token_t token;
|
||||||
fielddef_t *fd;
|
fielddef_t *fd;
|
||||||
void *p;
|
void *p;
|
||||||
int num;
|
int num;
|
||||||
|
|
||||||
if (!PC_ExpectTokenString(source, "{")) return 0;
|
if (!PC_ExpectTokenString(source, "{")) return 0;
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
if (!PC_ExpectAnyToken(source, &token)) return qfalse;
|
if (!PC_ExpectAnyToken(source, &token)) return qfalse;
|
||||||
//if end of structure
|
//if end of structure
|
||||||
if (!strcmp(token.string, "}")) break;
|
if (!strcmp(token.string, "}")) break;
|
||||||
//find the field with the name
|
//find the field with the name
|
||||||
fd = FindField(def->fields, token.string);
|
fd = FindField(def->fields, token.string);
|
||||||
if (!fd)
|
if (!fd)
|
||||||
{
|
{
|
||||||
SourceError(source, "unknown structure field %s", token.string);
|
SourceError(source, "unknown structure field %s", token.string);
|
||||||
return qfalse;
|
return qfalse;
|
||||||
} //end if
|
} //end if
|
||||||
if (fd->type & FT_ARRAY)
|
if (fd->type & FT_ARRAY)
|
||||||
{
|
{
|
||||||
num = fd->maxarray;
|
num = fd->maxarray;
|
||||||
if (!PC_ExpectTokenString(source, "{")) return qfalse;
|
if (!PC_ExpectTokenString(source, "{")) return qfalse;
|
||||||
} //end if
|
} //end if
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
num = 1;
|
num = 1;
|
||||||
} //end else
|
} //end else
|
||||||
p = (void *)(structure + fd->offset);
|
p = (void *)(structure + fd->offset);
|
||||||
while (num-- > 0)
|
while (num-- > 0)
|
||||||
{
|
{
|
||||||
if (fd->type & FT_ARRAY)
|
if (fd->type & FT_ARRAY)
|
||||||
{
|
{
|
||||||
if (PC_CheckTokenString(source, "}")) break;
|
if (PC_CheckTokenString(source, "}")) break;
|
||||||
} //end if
|
} //end if
|
||||||
switch(fd->type & FT_TYPE)
|
switch(fd->type & FT_TYPE)
|
||||||
{
|
{
|
||||||
case FT_CHAR:
|
case FT_CHAR:
|
||||||
{
|
{
|
||||||
if (!ReadChar(source, fd, p)) return qfalse;
|
if (!ReadChar(source, fd, p)) return qfalse;
|
||||||
p = (char *) p + sizeof(char);
|
p = (char *) p + sizeof(char);
|
||||||
break;
|
break;
|
||||||
} //end case
|
} //end case
|
||||||
case FT_INT:
|
case FT_INT:
|
||||||
{
|
{
|
||||||
if (!ReadNumber(source, fd, p)) return qfalse;
|
if (!ReadNumber(source, fd, p)) return qfalse;
|
||||||
p = (char *) p + sizeof(int);
|
p = (char *) p + sizeof(int);
|
||||||
break;
|
break;
|
||||||
} //end case
|
} //end case
|
||||||
case FT_FLOAT:
|
case FT_FLOAT:
|
||||||
{
|
{
|
||||||
if (!ReadNumber(source, fd, p)) return qfalse;
|
if (!ReadNumber(source, fd, p)) return qfalse;
|
||||||
p = (char *) p + sizeof(float);
|
p = (char *) p + sizeof(float);
|
||||||
break;
|
break;
|
||||||
} //end case
|
} //end case
|
||||||
case FT_STRING:
|
case FT_STRING:
|
||||||
{
|
{
|
||||||
if (!ReadString(source, fd, p)) return qfalse;
|
if (!ReadString(source, fd, p)) return qfalse;
|
||||||
p = (char *) p + MAX_STRINGFIELD;
|
p = (char *) p + MAX_STRINGFIELD;
|
||||||
break;
|
break;
|
||||||
} //end case
|
} //end case
|
||||||
case FT_STRUCT:
|
case FT_STRUCT:
|
||||||
{
|
{
|
||||||
if (!fd->substruct)
|
if (!fd->substruct)
|
||||||
{
|
{
|
||||||
SourceError(source, "BUG: no sub structure defined");
|
SourceError(source, "BUG: no sub structure defined");
|
||||||
return qfalse;
|
return qfalse;
|
||||||
} //end if
|
} //end if
|
||||||
ReadStructure(source, fd->substruct, (char *) p);
|
ReadStructure(source, fd->substruct, (char *) p);
|
||||||
p = (char *) p + fd->substruct->size;
|
p = (char *) p + fd->substruct->size;
|
||||||
break;
|
break;
|
||||||
} //end case
|
} //end case
|
||||||
} //end switch
|
} //end switch
|
||||||
if (fd->type & FT_ARRAY)
|
if (fd->type & FT_ARRAY)
|
||||||
{
|
{
|
||||||
if (!PC_ExpectAnyToken(source, &token)) return qfalse;
|
if (!PC_ExpectAnyToken(source, &token)) return qfalse;
|
||||||
if (!strcmp(token.string, "}")) break;
|
if (!strcmp(token.string, "}")) break;
|
||||||
if (strcmp(token.string, ","))
|
if (strcmp(token.string, ","))
|
||||||
{
|
{
|
||||||
SourceError(source, "expected a comma, found %s", token.string);
|
SourceError(source, "expected a comma, found %s", token.string);
|
||||||
return qfalse;
|
return qfalse;
|
||||||
} //end if
|
} //end if
|
||||||
} //end if
|
} //end if
|
||||||
} //end while
|
} //end while
|
||||||
} //end while
|
} //end while
|
||||||
return qtrue;
|
return qtrue;
|
||||||
} //end of the function ReadStructure
|
} //end of the function ReadStructure
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int WriteIndent(FILE *fp, int indent)
|
int WriteIndent(FILE *fp, int indent)
|
||||||
{
|
{
|
||||||
while(indent-- > 0)
|
while(indent-- > 0)
|
||||||
{
|
{
|
||||||
if (fprintf(fp, "\t") < 0) return qfalse;
|
if (fprintf(fp, "\t") < 0) return qfalse;
|
||||||
} //end while
|
} //end while
|
||||||
return qtrue;
|
return qtrue;
|
||||||
} //end of the function WriteIndent
|
} //end of the function WriteIndent
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int WriteFloat(FILE *fp, float value)
|
int WriteFloat(FILE *fp, float value)
|
||||||
{
|
{
|
||||||
char buf[128];
|
char buf[128];
|
||||||
int l;
|
int l;
|
||||||
|
|
||||||
sprintf(buf, "%f", value);
|
sprintf(buf, "%f", value);
|
||||||
l = strlen(buf);
|
l = strlen(buf);
|
||||||
//strip any trailing zeros
|
//strip any trailing zeros
|
||||||
while(l-- > 1)
|
while(l-- > 1)
|
||||||
{
|
{
|
||||||
if (buf[l] != '0' && buf[l] != '.') break;
|
if (buf[l] != '0' && buf[l] != '.') break;
|
||||||
if (buf[l] == '.')
|
if (buf[l] == '.')
|
||||||
{
|
{
|
||||||
buf[l] = 0;
|
buf[l] = 0;
|
||||||
break;
|
break;
|
||||||
} //end if
|
} //end if
|
||||||
buf[l] = 0;
|
buf[l] = 0;
|
||||||
} //end while
|
} //end while
|
||||||
//write the float to file
|
//write the float to file
|
||||||
if (fprintf(fp, "%s", buf) < 0) return 0;
|
if (fprintf(fp, "%s", buf) < 0) return 0;
|
||||||
return 1;
|
return 1;
|
||||||
} //end of the function WriteFloat
|
} //end of the function WriteFloat
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int WriteStructWithIndent(FILE *fp, structdef_t *def, char *structure, int indent)
|
int WriteStructWithIndent(FILE *fp, structdef_t *def, char *structure, int indent)
|
||||||
{
|
{
|
||||||
int i, num;
|
int i, num;
|
||||||
void *p;
|
void *p;
|
||||||
fielddef_t *fd;
|
fielddef_t *fd;
|
||||||
|
|
||||||
if (!WriteIndent(fp, indent)) return qfalse;
|
if (!WriteIndent(fp, indent)) return qfalse;
|
||||||
if (fprintf(fp, "{\r\n") < 0) return qfalse;
|
if (fprintf(fp, "{\r\n") < 0) return qfalse;
|
||||||
|
|
||||||
indent++;
|
indent++;
|
||||||
for (i = 0; def->fields[i].name; i++)
|
for (i = 0; def->fields[i].name; i++)
|
||||||
{
|
{
|
||||||
fd = &def->fields[i];
|
fd = &def->fields[i];
|
||||||
if (!WriteIndent(fp, indent)) return qfalse;
|
if (!WriteIndent(fp, indent)) return qfalse;
|
||||||
if (fprintf(fp, "%s\t", fd->name) < 0) return qfalse;
|
if (fprintf(fp, "%s\t", fd->name) < 0) return qfalse;
|
||||||
p = (void *)(structure + fd->offset);
|
p = (void *)(structure + fd->offset);
|
||||||
if (fd->type & FT_ARRAY)
|
if (fd->type & FT_ARRAY)
|
||||||
{
|
{
|
||||||
num = fd->maxarray;
|
num = fd->maxarray;
|
||||||
if (fprintf(fp, "{") < 0) return qfalse;
|
if (fprintf(fp, "{") < 0) return qfalse;
|
||||||
} //end if
|
} //end if
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
num = 1;
|
num = 1;
|
||||||
} //end else
|
} //end else
|
||||||
while(num-- > 0)
|
while(num-- > 0)
|
||||||
{
|
{
|
||||||
switch(fd->type & FT_TYPE)
|
switch(fd->type & FT_TYPE)
|
||||||
{
|
{
|
||||||
case FT_CHAR:
|
case FT_CHAR:
|
||||||
{
|
{
|
||||||
if (fprintf(fp, "%d", *(char *) p) < 0) return qfalse;
|
if (fprintf(fp, "%d", *(char *) p) < 0) return qfalse;
|
||||||
p = (char *) p + sizeof(char);
|
p = (char *) p + sizeof(char);
|
||||||
break;
|
break;
|
||||||
} //end case
|
} //end case
|
||||||
case FT_INT:
|
case FT_INT:
|
||||||
{
|
{
|
||||||
if (fprintf(fp, "%d", *(int *) p) < 0) return qfalse;
|
if (fprintf(fp, "%d", *(int *) p) < 0) return qfalse;
|
||||||
p = (char *) p + sizeof(int);
|
p = (char *) p + sizeof(int);
|
||||||
break;
|
break;
|
||||||
} //end case
|
} //end case
|
||||||
case FT_FLOAT:
|
case FT_FLOAT:
|
||||||
{
|
{
|
||||||
if (!WriteFloat(fp, *(float *)p)) return qfalse;
|
if (!WriteFloat(fp, *(float *)p)) return qfalse;
|
||||||
p = (char *) p + sizeof(float);
|
p = (char *) p + sizeof(float);
|
||||||
break;
|
break;
|
||||||
} //end case
|
} //end case
|
||||||
case FT_STRING:
|
case FT_STRING:
|
||||||
{
|
{
|
||||||
if (fprintf(fp, "\"%s\"", (char *) p) < 0) return qfalse;
|
if (fprintf(fp, "\"%s\"", (char *) p) < 0) return qfalse;
|
||||||
p = (char *) p + MAX_STRINGFIELD;
|
p = (char *) p + MAX_STRINGFIELD;
|
||||||
break;
|
break;
|
||||||
} //end case
|
} //end case
|
||||||
case FT_STRUCT:
|
case FT_STRUCT:
|
||||||
{
|
{
|
||||||
if (!WriteStructWithIndent(fp, fd->substruct, structure, indent)) return qfalse;
|
if (!WriteStructWithIndent(fp, fd->substruct, structure, indent)) return qfalse;
|
||||||
p = (char *) p + fd->substruct->size;
|
p = (char *) p + fd->substruct->size;
|
||||||
break;
|
break;
|
||||||
} //end case
|
} //end case
|
||||||
} //end switch
|
} //end switch
|
||||||
if (fd->type & FT_ARRAY)
|
if (fd->type & FT_ARRAY)
|
||||||
{
|
{
|
||||||
if (num > 0)
|
if (num > 0)
|
||||||
{
|
{
|
||||||
if (fprintf(fp, ",") < 0) return qfalse;
|
if (fprintf(fp, ",") < 0) return qfalse;
|
||||||
} //end if
|
} //end if
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (fprintf(fp, "}") < 0) return qfalse;
|
if (fprintf(fp, "}") < 0) return qfalse;
|
||||||
} //end else
|
} //end else
|
||||||
} //end if
|
} //end if
|
||||||
} //end while
|
} //end while
|
||||||
if (fprintf(fp, "\r\n") < 0) return qfalse;
|
if (fprintf(fp, "\r\n") < 0) return qfalse;
|
||||||
} //end for
|
} //end for
|
||||||
indent--;
|
indent--;
|
||||||
|
|
||||||
if (!WriteIndent(fp, indent)) return qfalse;
|
if (!WriteIndent(fp, indent)) return qfalse;
|
||||||
if (fprintf(fp, "}\r\n") < 0) return qfalse;
|
if (fprintf(fp, "}\r\n") < 0) return qfalse;
|
||||||
return qtrue;
|
return qtrue;
|
||||||
} //end of the function WriteStructWithIndent
|
} //end of the function WriteStructWithIndent
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int WriteStructure(FILE *fp, structdef_t *def, char *structure)
|
int WriteStructure(FILE *fp, structdef_t *def, char *structure)
|
||||||
{
|
{
|
||||||
return WriteStructWithIndent(fp, def, structure, 0);
|
return WriteStructWithIndent(fp, def, structure, 0);
|
||||||
} //end of the function WriteStructure
|
} //end of the function WriteStructure
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,75 +1,75 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: l_struct.h
|
* name: l_struct.h
|
||||||
*
|
*
|
||||||
* desc: structure reading/writing
|
* desc: structure reading/writing
|
||||||
*
|
*
|
||||||
* $Archive: /source/code/botlib/l_struct.h $
|
* $Archive: /source/code/botlib/l_struct.h $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#define MAX_STRINGFIELD 80
|
#define MAX_STRINGFIELD 80
|
||||||
//field types
|
//field types
|
||||||
#define FT_CHAR 1 // char
|
#define FT_CHAR 1 // char
|
||||||
#define FT_INT 2 // int
|
#define FT_INT 2 // int
|
||||||
#define FT_FLOAT 3 // float
|
#define FT_FLOAT 3 // float
|
||||||
#define FT_STRING 4 // char [MAX_STRINGFIELD]
|
#define FT_STRING 4 // char [MAX_STRINGFIELD]
|
||||||
#define FT_STRUCT 6 // struct (sub structure)
|
#define FT_STRUCT 6 // struct (sub structure)
|
||||||
//type only mask
|
//type only mask
|
||||||
#define FT_TYPE 0x00FF // only type, clear subtype
|
#define FT_TYPE 0x00FF // only type, clear subtype
|
||||||
//sub types
|
//sub types
|
||||||
#define FT_ARRAY 0x0100 // array of type
|
#define FT_ARRAY 0x0100 // array of type
|
||||||
#define FT_BOUNDED 0x0200 // bounded value
|
#define FT_BOUNDED 0x0200 // bounded value
|
||||||
#define FT_UNSIGNED 0x0400
|
#define FT_UNSIGNED 0x0400
|
||||||
|
|
||||||
//structure field definition
|
//structure field definition
|
||||||
typedef struct fielddef_s
|
typedef struct fielddef_s
|
||||||
{
|
{
|
||||||
char *name; //name of the field
|
char *name; //name of the field
|
||||||
int offset; //offset in the structure
|
int offset; //offset in the structure
|
||||||
int type; //type of the field
|
int type; //type of the field
|
||||||
//type specific fields
|
//type specific fields
|
||||||
int maxarray; //maximum array size
|
int maxarray; //maximum array size
|
||||||
float floatmin, floatmax; //float min and max
|
float floatmin, floatmax; //float min and max
|
||||||
struct structdef_s *substruct; //sub structure
|
struct structdef_s *substruct; //sub structure
|
||||||
} fielddef_t;
|
} fielddef_t;
|
||||||
|
|
||||||
//structure definition
|
//structure definition
|
||||||
typedef struct structdef_s
|
typedef struct structdef_s
|
||||||
{
|
{
|
||||||
int size;
|
int size;
|
||||||
fielddef_t *fields;
|
fielddef_t *fields;
|
||||||
} structdef_t;
|
} structdef_t;
|
||||||
|
|
||||||
//read a structure from a script
|
//read a structure from a script
|
||||||
int ReadStructure(source_t *source, structdef_t *def, char *structure);
|
int ReadStructure(source_t *source, structdef_t *def, char *structure);
|
||||||
//write a structure to a file
|
//write a structure to a file
|
||||||
int WriteStructure(FILE *fp, structdef_t *def, char *structure);
|
int WriteStructure(FILE *fp, structdef_t *def, char *structure);
|
||||||
//writes indents
|
//writes indents
|
||||||
int WriteIndent(FILE *fp, int indent);
|
int WriteIndent(FILE *fp, int indent);
|
||||||
//writes a float without traling zeros
|
//writes a float without traling zeros
|
||||||
int WriteFloat(FILE *fp, float value);
|
int WriteFloat(FILE *fp, float value);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,35 +1,35 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* name: l_util.h
|
* name: l_util.h
|
||||||
*
|
*
|
||||||
* desc: utils
|
* desc: utils
|
||||||
*
|
*
|
||||||
* $Archive: /source/code/botlib/l_util.h $
|
* $Archive: /source/code/botlib/l_util.h $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#define Vector2Angles(v,a) vectoangles(v,a)
|
#define Vector2Angles(v,a) vectoangles(v,a)
|
||||||
#define MAX_PATH MAX_QPATH
|
#define MAX_PATH MAX_QPATH
|
||||||
#define Maximum(x,y) (x > y ? x : y)
|
#define Maximum(x,y) (x > y ? x : y)
|
||||||
#define Minimum(x,y) (x < y ? x : y)
|
#define Minimum(x,y) (x < y ? x : y)
|
||||||
|
|
|
||||||
|
|
@ -1,55 +1,55 @@
|
||||||
#
|
#
|
||||||
# Makefile for Gladiator Bot library: gladiator.dll
|
# Makefile for Gladiator Bot library: gladiator.dll
|
||||||
# Intended for LCC-Win32
|
# Intended for LCC-Win32
|
||||||
#
|
#
|
||||||
|
|
||||||
CC=lcc
|
CC=lcc
|
||||||
CFLAGS=-DC_ONLY -o
|
CFLAGS=-DC_ONLY -o
|
||||||
OBJS= be_aas_bspq2.obj \
|
OBJS= be_aas_bspq2.obj \
|
||||||
be_aas_bsphl.obj \
|
be_aas_bsphl.obj \
|
||||||
be_aas_cluster.obj \
|
be_aas_cluster.obj \
|
||||||
be_aas_debug.obj \
|
be_aas_debug.obj \
|
||||||
be_aas_entity.obj \
|
be_aas_entity.obj \
|
||||||
be_aas_file.obj \
|
be_aas_file.obj \
|
||||||
be_aas_light.obj \
|
be_aas_light.obj \
|
||||||
be_aas_main.obj \
|
be_aas_main.obj \
|
||||||
be_aas_move.obj \
|
be_aas_move.obj \
|
||||||
be_aas_optimize.obj \
|
be_aas_optimize.obj \
|
||||||
be_aas_reach.obj \
|
be_aas_reach.obj \
|
||||||
be_aas_route.obj \
|
be_aas_route.obj \
|
||||||
be_aas_routealt.obj \
|
be_aas_routealt.obj \
|
||||||
be_aas_sample.obj \
|
be_aas_sample.obj \
|
||||||
be_aas_sound.obj \
|
be_aas_sound.obj \
|
||||||
be_ai2_dm.obj \
|
be_ai2_dm.obj \
|
||||||
be_ai2_dmnet.obj \
|
be_ai2_dmnet.obj \
|
||||||
be_ai2_main.obj \
|
be_ai2_main.obj \
|
||||||
be_ai_char.obj \
|
be_ai_char.obj \
|
||||||
be_ai_chat.obj \
|
be_ai_chat.obj \
|
||||||
be_ai_goal.obj \
|
be_ai_goal.obj \
|
||||||
be_ai_load.obj \
|
be_ai_load.obj \
|
||||||
be_ai_move.obj \
|
be_ai_move.obj \
|
||||||
be_ai_weap.obj \
|
be_ai_weap.obj \
|
||||||
be_ai_weight.obj \
|
be_ai_weight.obj \
|
||||||
be_ea.obj \
|
be_ea.obj \
|
||||||
be_interface.obj \
|
be_interface.obj \
|
||||||
l_crc.obj \
|
l_crc.obj \
|
||||||
l_libvar.obj \
|
l_libvar.obj \
|
||||||
l_log.obj \
|
l_log.obj \
|
||||||
l_memory.obj \
|
l_memory.obj \
|
||||||
l_precomp.obj \
|
l_precomp.obj \
|
||||||
l_script.obj \
|
l_script.obj \
|
||||||
l_struct.obj \
|
l_struct.obj \
|
||||||
l_utils.obj \
|
l_utils.obj \
|
||||||
q_shared.obj
|
q_shared.obj
|
||||||
|
|
||||||
all: gladiator.dll
|
all: gladiator.dll
|
||||||
|
|
||||||
gladiator.dll: $(OBJS)
|
gladiator.dll: $(OBJS)
|
||||||
lcclnk -dll -entry GetBotAPI *.obj botlib.def -o gladiator.dll
|
lcclnk -dll -entry GetBotAPI *.obj botlib.def -o gladiator.dll
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
del *.obj gladiator.dll
|
del *.obj gladiator.dll
|
||||||
|
|
||||||
%.obj: %.c
|
%.obj: %.c
|
||||||
$(CC) $(CFLAGS) $<
|
$(CC) $(CFLAGS) $<
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,92 +1,92 @@
|
||||||
#
|
#
|
||||||
# Makefile for Gladiator Bot library: gladiator.so
|
# Makefile for Gladiator Bot library: gladiator.so
|
||||||
# Intended for gcc/Linux
|
# Intended for gcc/Linux
|
||||||
#
|
#
|
||||||
|
|
||||||
ARCH=i386
|
ARCH=i386
|
||||||
CC=gcc
|
CC=gcc
|
||||||
BASE_CFLAGS=-Dstricmp=strcasecmp
|
BASE_CFLAGS=-Dstricmp=strcasecmp
|
||||||
|
|
||||||
#use these cflags to optimize it
|
#use these cflags to optimize it
|
||||||
CFLAGS=$(BASE_CFLAGS) -m486 -O6 -ffast-math -funroll-loops \
|
CFLAGS=$(BASE_CFLAGS) -m486 -O6 -ffast-math -funroll-loops \
|
||||||
-fomit-frame-pointer -fexpensive-optimizations -malign-loops=2 \
|
-fomit-frame-pointer -fexpensive-optimizations -malign-loops=2 \
|
||||||
-malign-jumps=2 -malign-functions=2
|
-malign-jumps=2 -malign-functions=2
|
||||||
#use these when debugging
|
#use these when debugging
|
||||||
#CFLAGS=$(BASE_CFLAGS) -g
|
#CFLAGS=$(BASE_CFLAGS) -g
|
||||||
|
|
||||||
LDFLAGS=-ldl -lm
|
LDFLAGS=-ldl -lm
|
||||||
SHLIBEXT=so
|
SHLIBEXT=so
|
||||||
SHLIBCFLAGS=-fPIC
|
SHLIBCFLAGS=-fPIC
|
||||||
SHLIBLDFLAGS=-shared
|
SHLIBLDFLAGS=-shared
|
||||||
|
|
||||||
DO_CC=$(CC) $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $<
|
DO_CC=$(CC) $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $<
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
# SETUP AND BUILD
|
# SETUP AND BUILD
|
||||||
# GLADIATOR BOT
|
# GLADIATOR BOT
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
.c.o:
|
.c.o:
|
||||||
$(DO_CC)
|
$(DO_CC)
|
||||||
|
|
||||||
GAME_OBJS = \
|
GAME_OBJS = \
|
||||||
be_aas_bsphl.o\
|
be_aas_bsphl.o\
|
||||||
be_aas_bspq2.o\
|
be_aas_bspq2.o\
|
||||||
be_aas_cluster.o\
|
be_aas_cluster.o\
|
||||||
be_aas_debug.o\
|
be_aas_debug.o\
|
||||||
be_aas_entity.o\
|
be_aas_entity.o\
|
||||||
be_aas_file.o\
|
be_aas_file.o\
|
||||||
be_aas_light.o\
|
be_aas_light.o\
|
||||||
be_aas_main.o\
|
be_aas_main.o\
|
||||||
be_aas_move.o\
|
be_aas_move.o\
|
||||||
be_aas_optimize.o\
|
be_aas_optimize.o\
|
||||||
be_aas_reach.o\
|
be_aas_reach.o\
|
||||||
be_aas_route.o\
|
be_aas_route.o\
|
||||||
be_aas_routealt.o\
|
be_aas_routealt.o\
|
||||||
be_aas_sample.o\
|
be_aas_sample.o\
|
||||||
be_aas_sound.o\
|
be_aas_sound.o\
|
||||||
be_ai2_dmq2.o\
|
be_ai2_dmq2.o\
|
||||||
be_ai2_dmhl.o\
|
be_ai2_dmhl.o\
|
||||||
be_ai2_dmnet.o\
|
be_ai2_dmnet.o\
|
||||||
be_ai2_main.o\
|
be_ai2_main.o\
|
||||||
be_ai_char.o\
|
be_ai_char.o\
|
||||||
be_ai_chat.o\
|
be_ai_chat.o\
|
||||||
be_ai_goal.o\
|
be_ai_goal.o\
|
||||||
be_ai_load.o\
|
be_ai_load.o\
|
||||||
be_ai_move.o\
|
be_ai_move.o\
|
||||||
be_ai_weap.o\
|
be_ai_weap.o\
|
||||||
be_ai_weight.o\
|
be_ai_weight.o\
|
||||||
be_ea.o\
|
be_ea.o\
|
||||||
be_interface.o\
|
be_interface.o\
|
||||||
l_crc.o\
|
l_crc.o\
|
||||||
l_libvar.o\
|
l_libvar.o\
|
||||||
l_log.o\
|
l_log.o\
|
||||||
l_memory.o\
|
l_memory.o\
|
||||||
l_precomp.o\
|
l_precomp.o\
|
||||||
l_script.o\
|
l_script.o\
|
||||||
l_struct.o\
|
l_struct.o\
|
||||||
l_utils.o\
|
l_utils.o\
|
||||||
q_shared.o
|
q_shared.o
|
||||||
|
|
||||||
glad$(ARCH).$(SHLIBEXT) : $(GAME_OBJS)
|
glad$(ARCH).$(SHLIBEXT) : $(GAME_OBJS)
|
||||||
$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(GAME_OBJS)
|
$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(GAME_OBJS)
|
||||||
|
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
# MISC
|
# MISC
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-rm -f $(GAME_OBJS)
|
-rm -f $(GAME_OBJS)
|
||||||
|
|
||||||
depend:
|
depend:
|
||||||
gcc -MM $(GAME_OBJS:.o=.c)
|
gcc -MM $(GAME_OBJS:.o=.c)
|
||||||
|
|
||||||
|
|
||||||
install:
|
install:
|
||||||
cp gladiator.so ..
|
cp gladiator.so ..
|
||||||
|
|
||||||
#
|
#
|
||||||
# From "make depend"
|
# From "make depend"
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,75 +1,75 @@
|
||||||
# bspc compile
|
# bspc compile
|
||||||
|
|
||||||
Import qw( BSPC_BASE_CFLAGS BUILD_DIR INSTALL_DIR CC CXX LINK );
|
Import qw( BSPC_BASE_CFLAGS BUILD_DIR INSTALL_DIR CC CXX LINK );
|
||||||
|
|
||||||
@BSPC_FILES = qw(
|
@BSPC_FILES = qw(
|
||||||
aas_areamerging.c
|
aas_areamerging.c
|
||||||
aas_cfg.c
|
aas_cfg.c
|
||||||
aas_create.c
|
aas_create.c
|
||||||
aas_edgemelting.c
|
aas_edgemelting.c
|
||||||
aas_facemerging.c
|
aas_facemerging.c
|
||||||
aas_file.c
|
aas_file.c
|
||||||
aas_gsubdiv.c
|
aas_gsubdiv.c
|
||||||
aas_map.c
|
aas_map.c
|
||||||
aas_prunenodes.c
|
aas_prunenodes.c
|
||||||
aas_store.c
|
aas_store.c
|
||||||
be_aas_bspc.c
|
be_aas_bspc.c
|
||||||
../botlib/be_aas_bspq3.c
|
../botlib/be_aas_bspq3.c
|
||||||
../botlib/be_aas_cluster.c
|
../botlib/be_aas_cluster.c
|
||||||
../botlib/be_aas_move.c
|
../botlib/be_aas_move.c
|
||||||
../botlib/be_aas_optimize.c
|
../botlib/be_aas_optimize.c
|
||||||
../botlib/be_aas_reach.c
|
../botlib/be_aas_reach.c
|
||||||
../botlib/be_aas_sample.c
|
../botlib/be_aas_sample.c
|
||||||
brushbsp.c
|
brushbsp.c
|
||||||
bspc.c
|
bspc.c
|
||||||
../qcommon/cm_load.c
|
../qcommon/cm_load.c
|
||||||
../qcommon/cm_patch.c
|
../qcommon/cm_patch.c
|
||||||
../qcommon/cm_test.c
|
../qcommon/cm_test.c
|
||||||
../qcommon/cm_trace.c
|
../qcommon/cm_trace.c
|
||||||
csg.c
|
csg.c
|
||||||
glfile.c
|
glfile.c
|
||||||
l_bsp_ent.c
|
l_bsp_ent.c
|
||||||
l_bsp_hl.c
|
l_bsp_hl.c
|
||||||
l_bsp_q1.c
|
l_bsp_q1.c
|
||||||
l_bsp_q2.c
|
l_bsp_q2.c
|
||||||
l_bsp_q3.c
|
l_bsp_q3.c
|
||||||
l_bsp_sin.c
|
l_bsp_sin.c
|
||||||
l_cmd.c
|
l_cmd.c
|
||||||
../botlib/l_libvar.c
|
../botlib/l_libvar.c
|
||||||
l_log.c
|
l_log.c
|
||||||
l_math.c
|
l_math.c
|
||||||
l_mem.c
|
l_mem.c
|
||||||
l_poly.c
|
l_poly.c
|
||||||
../botlib/l_precomp.c
|
../botlib/l_precomp.c
|
||||||
l_qfiles.c
|
l_qfiles.c
|
||||||
../botlib/l_script.c
|
../botlib/l_script.c
|
||||||
../botlib/l_struct.c
|
../botlib/l_struct.c
|
||||||
l_threads.c
|
l_threads.c
|
||||||
l_utils.c
|
l_utils.c
|
||||||
leakfile.c
|
leakfile.c
|
||||||
map.c
|
map.c
|
||||||
map_hl.c
|
map_hl.c
|
||||||
map_q1.c
|
map_q1.c
|
||||||
map_q2.c
|
map_q2.c
|
||||||
map_q3.c
|
map_q3.c
|
||||||
map_sin.c
|
map_sin.c
|
||||||
../qcommon/md4.c
|
../qcommon/md4.c
|
||||||
nodraw.c
|
nodraw.c
|
||||||
portals.c
|
portals.c
|
||||||
textures.c
|
textures.c
|
||||||
tree.c
|
tree.c
|
||||||
../qcommon/unzip.c
|
../qcommon/unzip.c
|
||||||
);
|
);
|
||||||
$BSPC_REF = \@BSPC_FILES;
|
$BSPC_REF = \@BSPC_FILES;
|
||||||
|
|
||||||
$env = new cons(
|
$env = new cons(
|
||||||
CC => $CC,
|
CC => $CC,
|
||||||
CXX => $CXX,
|
CXX => $CXX,
|
||||||
LINK => $LINK,
|
LINK => $LINK,
|
||||||
CFLAGS => $BSPC_BASE_CFLAGS,
|
CFLAGS => $BSPC_BASE_CFLAGS,
|
||||||
LIBS => '-ldl -lm -lpthread'
|
LIBS => '-ldl -lm -lpthread'
|
||||||
);
|
);
|
||||||
|
|
||||||
Program $env 'bspc', @$BSPC_REF;
|
Program $env 'bspc', @$BSPC_REF;
|
||||||
# this should install to Q3 or something?
|
# this should install to Q3 or something?
|
||||||
Install $env $INSTALL_DIR, 'bspc';
|
Install $env $INSTALL_DIR, 'bspc';
|
||||||
|
|
|
||||||
|
|
@ -1,114 +1,114 @@
|
||||||
#
|
#
|
||||||
# Makefile for the BSPC tool for the Gladiator Bot
|
# Makefile for the BSPC tool for the Gladiator Bot
|
||||||
# Intended for gcc/Linux
|
# Intended for gcc/Linux
|
||||||
#
|
#
|
||||||
# TTimo 5/15/2001
|
# TTimo 5/15/2001
|
||||||
# some cleanup .. only used on i386 for GtkRadiant setups AFAIK .. removing the i386 tag
|
# some cleanup .. only used on i386 for GtkRadiant setups AFAIK .. removing the i386 tag
|
||||||
# TODO: the intermediate object files should go into their own directory
|
# TODO: the intermediate object files should go into their own directory
|
||||||
# specially for ../botlib and ../qcommon, the compilation flags on those might not be what you expect
|
# specially for ../botlib and ../qcommon, the compilation flags on those might not be what you expect
|
||||||
|
|
||||||
#ARCH=i386
|
#ARCH=i386
|
||||||
CC=gcc
|
CC=gcc
|
||||||
BASE_CFLAGS=-Dstricmp=strcasecmp
|
BASE_CFLAGS=-Dstricmp=strcasecmp
|
||||||
|
|
||||||
#use these cflags to optimize it
|
#use these cflags to optimize it
|
||||||
CFLAGS=$(BASE_CFLAGS) -m486 -O6 -ffast-math -funroll-loops \
|
CFLAGS=$(BASE_CFLAGS) -m486 -O6 -ffast-math -funroll-loops \
|
||||||
-fomit-frame-pointer -fexpensive-optimizations -malign-loops=2 \
|
-fomit-frame-pointer -fexpensive-optimizations -malign-loops=2 \
|
||||||
-malign-jumps=2 -malign-functions=2 -DLINUX -DBSPC
|
-malign-jumps=2 -malign-functions=2 -DLINUX -DBSPC
|
||||||
#use these when debugging
|
#use these when debugging
|
||||||
#CFLAGS=$(BASE_CFLAGS) -g
|
#CFLAGS=$(BASE_CFLAGS) -g
|
||||||
|
|
||||||
LDFLAGS=-ldl -lm -lpthread
|
LDFLAGS=-ldl -lm -lpthread
|
||||||
|
|
||||||
DO_CC=$(CC) $(CFLAGS) -o $@ -c $<
|
DO_CC=$(CC) $(CFLAGS) -o $@ -c $<
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
# SETUP AND BUILD BSPC
|
# SETUP AND BUILD BSPC
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
.c.o:
|
.c.o:
|
||||||
$(DO_CC)
|
$(DO_CC)
|
||||||
|
|
||||||
GAME_OBJS = \
|
GAME_OBJS = \
|
||||||
_files.o\
|
_files.o\
|
||||||
aas_areamerging.o\
|
aas_areamerging.o\
|
||||||
aas_cfg.o\
|
aas_cfg.o\
|
||||||
aas_create.o\
|
aas_create.o\
|
||||||
aas_edgemelting.o\
|
aas_edgemelting.o\
|
||||||
aas_facemerging.o\
|
aas_facemerging.o\
|
||||||
aas_file.o\
|
aas_file.o\
|
||||||
aas_gsubdiv.o\
|
aas_gsubdiv.o\
|
||||||
aas_map.o\
|
aas_map.o\
|
||||||
aas_prunenodes.o\
|
aas_prunenodes.o\
|
||||||
aas_store.o\
|
aas_store.o\
|
||||||
be_aas_bspc.o\
|
be_aas_bspc.o\
|
||||||
../botlib/be_aas_bspq3.o\
|
../botlib/be_aas_bspq3.o\
|
||||||
../botlib/be_aas_cluster.o\
|
../botlib/be_aas_cluster.o\
|
||||||
../botlib/be_aas_move.o\
|
../botlib/be_aas_move.o\
|
||||||
../botlib/be_aas_optimize.o\
|
../botlib/be_aas_optimize.o\
|
||||||
../botlib/be_aas_reach.o\
|
../botlib/be_aas_reach.o\
|
||||||
../botlib/be_aas_sample.o\
|
../botlib/be_aas_sample.o\
|
||||||
brushbsp.o\
|
brushbsp.o\
|
||||||
bspc.o\
|
bspc.o\
|
||||||
../qcommon/cm_load.o\
|
../qcommon/cm_load.o\
|
||||||
../qcommon/cm_patch.o\
|
../qcommon/cm_patch.o\
|
||||||
../qcommon/cm_test.o\
|
../qcommon/cm_test.o\
|
||||||
../qcommon/cm_trace.o\
|
../qcommon/cm_trace.o\
|
||||||
csg.o\
|
csg.o\
|
||||||
glfile.o\
|
glfile.o\
|
||||||
l_bsp_ent.o\
|
l_bsp_ent.o\
|
||||||
l_bsp_hl.o\
|
l_bsp_hl.o\
|
||||||
l_bsp_q1.o\
|
l_bsp_q1.o\
|
||||||
l_bsp_q2.o\
|
l_bsp_q2.o\
|
||||||
l_bsp_q3.o\
|
l_bsp_q3.o\
|
||||||
l_bsp_sin.o\
|
l_bsp_sin.o\
|
||||||
l_cmd.o\
|
l_cmd.o\
|
||||||
../botlib/l_libvar.o\
|
../botlib/l_libvar.o\
|
||||||
l_log.o\
|
l_log.o\
|
||||||
l_math.o\
|
l_math.o\
|
||||||
l_mem.o\
|
l_mem.o\
|
||||||
l_poly.o\
|
l_poly.o\
|
||||||
../botlib/l_precomp.o\
|
../botlib/l_precomp.o\
|
||||||
l_qfiles.o\
|
l_qfiles.o\
|
||||||
../botlib/l_script.o\
|
../botlib/l_script.o\
|
||||||
../botlib/l_struct.o\
|
../botlib/l_struct.o\
|
||||||
l_threads.o\
|
l_threads.o\
|
||||||
l_utils.o\
|
l_utils.o\
|
||||||
leakfile.o\
|
leakfile.o\
|
||||||
map.o\
|
map.o\
|
||||||
map_hl.o\
|
map_hl.o\
|
||||||
map_q1.o\
|
map_q1.o\
|
||||||
map_q2.o\
|
map_q2.o\
|
||||||
map_q3.o\
|
map_q3.o\
|
||||||
map_sin.o\
|
map_sin.o\
|
||||||
../qcommon/md4.o\
|
../qcommon/md4.o\
|
||||||
nodraw.o\
|
nodraw.o\
|
||||||
portals.o\
|
portals.o\
|
||||||
textures.o\
|
textures.o\
|
||||||
tree.o\
|
tree.o\
|
||||||
../qcommon/unzip.o
|
../qcommon/unzip.o
|
||||||
|
|
||||||
#tetrahedron.o
|
#tetrahedron.o
|
||||||
|
|
||||||
bspc : $(GAME_OBJS)
|
bspc : $(GAME_OBJS)
|
||||||
$(CC) $(CFLAGS) -o $@ $(GAME_OBJS) $(LDFLAGS)
|
$(CC) $(CFLAGS) -o $@ $(GAME_OBJS) $(LDFLAGS)
|
||||||
strip $@
|
strip $@
|
||||||
|
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
# MISC
|
# MISC
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-rm -f $(GAME_OBJS)
|
-rm -f $(GAME_OBJS)
|
||||||
|
|
||||||
depend:
|
depend:
|
||||||
gcc -MM $(GAME_OBJS:.o=.c)
|
gcc -MM $(GAME_OBJS:.o=.c)
|
||||||
|
|
||||||
#install:
|
#install:
|
||||||
# cp bspci386 ..
|
# cp bspci386 ..
|
||||||
|
|
||||||
#
|
#
|
||||||
# From "make depend"
|
# From "make depend"
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,390 +1,390 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "qbsp.h"
|
#include "qbsp.h"
|
||||||
#include "../botlib/aasfile.h"
|
#include "../botlib/aasfile.h"
|
||||||
#include "aas_create.h"
|
#include "aas_create.h"
|
||||||
#include "aas_store.h"
|
#include "aas_store.h"
|
||||||
|
|
||||||
#define CONVEX_EPSILON 0.3
|
#define CONVEX_EPSILON 0.3
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
tmp_node_t *AAS_RefreshMergedTree_r(tmp_node_t *tmpnode)
|
tmp_node_t *AAS_RefreshMergedTree_r(tmp_node_t *tmpnode)
|
||||||
{
|
{
|
||||||
tmp_area_t *tmparea;
|
tmp_area_t *tmparea;
|
||||||
|
|
||||||
//if this is a solid leaf
|
//if this is a solid leaf
|
||||||
if (!tmpnode) return NULL;
|
if (!tmpnode) return NULL;
|
||||||
//if this is an area leaf
|
//if this is an area leaf
|
||||||
if (tmpnode->tmparea)
|
if (tmpnode->tmparea)
|
||||||
{
|
{
|
||||||
tmparea = tmpnode->tmparea;
|
tmparea = tmpnode->tmparea;
|
||||||
while(tmparea->mergedarea) tmparea = tmparea->mergedarea;
|
while(tmparea->mergedarea) tmparea = tmparea->mergedarea;
|
||||||
tmpnode->tmparea = tmparea;
|
tmpnode->tmparea = tmparea;
|
||||||
return tmpnode;
|
return tmpnode;
|
||||||
} //end if
|
} //end if
|
||||||
//do the children recursively
|
//do the children recursively
|
||||||
tmpnode->children[0] = AAS_RefreshMergedTree_r(tmpnode->children[0]);
|
tmpnode->children[0] = AAS_RefreshMergedTree_r(tmpnode->children[0]);
|
||||||
tmpnode->children[1] = AAS_RefreshMergedTree_r(tmpnode->children[1]);
|
tmpnode->children[1] = AAS_RefreshMergedTree_r(tmpnode->children[1]);
|
||||||
return tmpnode;
|
return tmpnode;
|
||||||
} //end of the function AAS_RefreshMergedTree_r
|
} //end of the function AAS_RefreshMergedTree_r
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
// returns true if the two given faces would create a non-convex area at
|
// returns true if the two given faces would create a non-convex area at
|
||||||
// the given sides, otherwise false is returned
|
// the given sides, otherwise false is returned
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int NonConvex(tmp_face_t *face1, tmp_face_t *face2, int side1, int side2)
|
int NonConvex(tmp_face_t *face1, tmp_face_t *face2, int side1, int side2)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
winding_t *w1, *w2;
|
winding_t *w1, *w2;
|
||||||
plane_t *plane1, *plane2;
|
plane_t *plane1, *plane2;
|
||||||
|
|
||||||
w1 = face1->winding;
|
w1 = face1->winding;
|
||||||
w2 = face2->winding;
|
w2 = face2->winding;
|
||||||
|
|
||||||
plane1 = &mapplanes[face1->planenum ^ side1];
|
plane1 = &mapplanes[face1->planenum ^ side1];
|
||||||
plane2 = &mapplanes[face2->planenum ^ side2];
|
plane2 = &mapplanes[face2->planenum ^ side2];
|
||||||
|
|
||||||
//check if one of the points of face1 is at the back of the plane of face2
|
//check if one of the points of face1 is at the back of the plane of face2
|
||||||
for (i = 0; i < w1->numpoints; i++)
|
for (i = 0; i < w1->numpoints; i++)
|
||||||
{
|
{
|
||||||
if (DotProduct(plane2->normal, w1->p[i]) - plane2->dist < -CONVEX_EPSILON) return true;
|
if (DotProduct(plane2->normal, w1->p[i]) - plane2->dist < -CONVEX_EPSILON) return true;
|
||||||
} //end for
|
} //end for
|
||||||
//check if one of the points of face2 is at the back of the plane of face1
|
//check if one of the points of face2 is at the back of the plane of face1
|
||||||
for (i = 0; i < w2->numpoints; i++)
|
for (i = 0; i < w2->numpoints; i++)
|
||||||
{
|
{
|
||||||
if (DotProduct(plane1->normal, w2->p[i]) - plane1->dist < -CONVEX_EPSILON) return true;
|
if (DotProduct(plane1->normal, w2->p[i]) - plane1->dist < -CONVEX_EPSILON) return true;
|
||||||
} //end for
|
} //end for
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} //end of the function NonConvex
|
} //end of the function NonConvex
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
// try to merge the areas at both sides of the given face
|
// try to merge the areas at both sides of the given face
|
||||||
//
|
//
|
||||||
// Parameter: seperatingface : face that seperates two areas
|
// Parameter: seperatingface : face that seperates two areas
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_TryMergeFaceAreas(tmp_face_t *seperatingface)
|
int AAS_TryMergeFaceAreas(tmp_face_t *seperatingface)
|
||||||
{
|
{
|
||||||
int side1, side2, area1faceflags, area2faceflags;
|
int side1, side2, area1faceflags, area2faceflags;
|
||||||
tmp_area_t *tmparea1, *tmparea2, *newarea;
|
tmp_area_t *tmparea1, *tmparea2, *newarea;
|
||||||
tmp_face_t *face1, *face2, *nextface1, *nextface2;
|
tmp_face_t *face1, *face2, *nextface1, *nextface2;
|
||||||
|
|
||||||
tmparea1 = seperatingface->frontarea;
|
tmparea1 = seperatingface->frontarea;
|
||||||
tmparea2 = seperatingface->backarea;
|
tmparea2 = seperatingface->backarea;
|
||||||
|
|
||||||
//areas must have the same presence type
|
//areas must have the same presence type
|
||||||
if (tmparea1->presencetype != tmparea2->presencetype) return false;
|
if (tmparea1->presencetype != tmparea2->presencetype) return false;
|
||||||
//areas must have the same area contents
|
//areas must have the same area contents
|
||||||
if (tmparea1->contents != tmparea2->contents) return false;
|
if (tmparea1->contents != tmparea2->contents) return false;
|
||||||
//areas must have the same bsp model inside (or both none)
|
//areas must have the same bsp model inside (or both none)
|
||||||
if (tmparea1->modelnum != tmparea2->modelnum) return false;
|
if (tmparea1->modelnum != tmparea2->modelnum) return false;
|
||||||
|
|
||||||
area1faceflags = 0;
|
area1faceflags = 0;
|
||||||
area2faceflags = 0;
|
area2faceflags = 0;
|
||||||
for (face1 = tmparea1->tmpfaces; face1; face1 = face1->next[side1])
|
for (face1 = tmparea1->tmpfaces; face1; face1 = face1->next[side1])
|
||||||
{
|
{
|
||||||
side1 = (face1->frontarea != tmparea1);
|
side1 = (face1->frontarea != tmparea1);
|
||||||
//debug: check if the area belongs to the area
|
//debug: check if the area belongs to the area
|
||||||
if (face1->frontarea != tmparea1 &&
|
if (face1->frontarea != tmparea1 &&
|
||||||
face1->backarea != tmparea1) Error("face does not belong to area1");
|
face1->backarea != tmparea1) Error("face does not belong to area1");
|
||||||
//just continue if the face is seperating the two areas
|
//just continue if the face is seperating the two areas
|
||||||
//NOTE: a result of this is that ground and gap areas can
|
//NOTE: a result of this is that ground and gap areas can
|
||||||
// be merged if the seperating face is the gap
|
// be merged if the seperating face is the gap
|
||||||
if ((face1->frontarea == tmparea1 &&
|
if ((face1->frontarea == tmparea1 &&
|
||||||
face1->backarea == tmparea2) ||
|
face1->backarea == tmparea2) ||
|
||||||
(face1->frontarea == tmparea2 &&
|
(face1->frontarea == tmparea2 &&
|
||||||
face1->backarea == tmparea1)) continue;
|
face1->backarea == tmparea1)) continue;
|
||||||
//get area1 face flags
|
//get area1 face flags
|
||||||
area1faceflags |= face1->faceflags;
|
area1faceflags |= face1->faceflags;
|
||||||
if (AAS_GapFace(face1, side1)) area1faceflags |= FACE_GAP;
|
if (AAS_GapFace(face1, side1)) area1faceflags |= FACE_GAP;
|
||||||
//
|
//
|
||||||
for (face2 = tmparea2->tmpfaces; face2; face2 = face2->next[side2])
|
for (face2 = tmparea2->tmpfaces; face2; face2 = face2->next[side2])
|
||||||
{
|
{
|
||||||
side2 = (face2->frontarea != tmparea2);
|
side2 = (face2->frontarea != tmparea2);
|
||||||
//debug: check if the area belongs to the area
|
//debug: check if the area belongs to the area
|
||||||
if (face2->frontarea != tmparea2 &&
|
if (face2->frontarea != tmparea2 &&
|
||||||
face2->backarea != tmparea2) Error("face does not belong to area2");
|
face2->backarea != tmparea2) Error("face does not belong to area2");
|
||||||
//just continue if the face is seperating the two areas
|
//just continue if the face is seperating the two areas
|
||||||
//NOTE: a result of this is that ground and gap areas can
|
//NOTE: a result of this is that ground and gap areas can
|
||||||
// be merged if the seperating face is the gap
|
// be merged if the seperating face is the gap
|
||||||
if ((face2->frontarea == tmparea1 &&
|
if ((face2->frontarea == tmparea1 &&
|
||||||
face2->backarea == tmparea2) ||
|
face2->backarea == tmparea2) ||
|
||||||
(face2->frontarea == tmparea2 &&
|
(face2->frontarea == tmparea2 &&
|
||||||
face2->backarea == tmparea1)) continue;
|
face2->backarea == tmparea1)) continue;
|
||||||
//get area2 face flags
|
//get area2 face flags
|
||||||
area2faceflags |= face2->faceflags;
|
area2faceflags |= face2->faceflags;
|
||||||
if (AAS_GapFace(face2, side2)) area2faceflags |= FACE_GAP;
|
if (AAS_GapFace(face2, side2)) area2faceflags |= FACE_GAP;
|
||||||
//if the two faces would create a non-convex area
|
//if the two faces would create a non-convex area
|
||||||
if (NonConvex(face1, face2, side1, side2)) return false;
|
if (NonConvex(face1, face2, side1, side2)) return false;
|
||||||
} //end for
|
} //end for
|
||||||
} //end for
|
} //end for
|
||||||
//if one area has gap faces (that aren't seperating the two areas)
|
//if one area has gap faces (that aren't seperating the two areas)
|
||||||
//and the other has ground faces (that aren't seperating the two areas),
|
//and the other has ground faces (that aren't seperating the two areas),
|
||||||
//the areas can't be merged
|
//the areas can't be merged
|
||||||
if (((area1faceflags & FACE_GROUND) && (area2faceflags & FACE_GAP)) ||
|
if (((area1faceflags & FACE_GROUND) && (area2faceflags & FACE_GAP)) ||
|
||||||
((area2faceflags & FACE_GROUND) && (area1faceflags & FACE_GAP)))
|
((area2faceflags & FACE_GROUND) && (area1faceflags & FACE_GAP)))
|
||||||
{
|
{
|
||||||
// Log_Print(" can't merge: ground/gap\n");
|
// Log_Print(" can't merge: ground/gap\n");
|
||||||
return false;
|
return false;
|
||||||
} //end if
|
} //end if
|
||||||
|
|
||||||
// Log_Print("merged area %d & %d to %d with %d faces\n", tmparea1->areanum, tmparea2->areanum, newarea->areanum, numfaces);
|
// Log_Print("merged area %d & %d to %d with %d faces\n", tmparea1->areanum, tmparea2->areanum, newarea->areanum, numfaces);
|
||||||
// return false;
|
// return false;
|
||||||
//
|
//
|
||||||
//AAS_CheckArea(tmparea1);
|
//AAS_CheckArea(tmparea1);
|
||||||
//AAS_CheckArea(tmparea2);
|
//AAS_CheckArea(tmparea2);
|
||||||
//create the new area
|
//create the new area
|
||||||
newarea = AAS_AllocTmpArea();
|
newarea = AAS_AllocTmpArea();
|
||||||
newarea->presencetype = tmparea1->presencetype;
|
newarea->presencetype = tmparea1->presencetype;
|
||||||
newarea->contents = tmparea1->contents;
|
newarea->contents = tmparea1->contents;
|
||||||
newarea->modelnum = tmparea1->modelnum;
|
newarea->modelnum = tmparea1->modelnum;
|
||||||
newarea->tmpfaces = NULL;
|
newarea->tmpfaces = NULL;
|
||||||
|
|
||||||
//add all the faces (except the seperating ones) from the first area
|
//add all the faces (except the seperating ones) from the first area
|
||||||
//to the new area
|
//to the new area
|
||||||
for (face1 = tmparea1->tmpfaces; face1; face1 = nextface1)
|
for (face1 = tmparea1->tmpfaces; face1; face1 = nextface1)
|
||||||
{
|
{
|
||||||
side1 = (face1->frontarea != tmparea1);
|
side1 = (face1->frontarea != tmparea1);
|
||||||
nextface1 = face1->next[side1];
|
nextface1 = face1->next[side1];
|
||||||
//don't add seperating faces
|
//don't add seperating faces
|
||||||
if ((face1->frontarea == tmparea1 &&
|
if ((face1->frontarea == tmparea1 &&
|
||||||
face1->backarea == tmparea2) ||
|
face1->backarea == tmparea2) ||
|
||||||
(face1->frontarea == tmparea2 &&
|
(face1->frontarea == tmparea2 &&
|
||||||
face1->backarea == tmparea1))
|
face1->backarea == tmparea1))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
} //end if
|
} //end if
|
||||||
//
|
//
|
||||||
AAS_RemoveFaceFromArea(face1, tmparea1);
|
AAS_RemoveFaceFromArea(face1, tmparea1);
|
||||||
AAS_AddFaceSideToArea(face1, side1, newarea);
|
AAS_AddFaceSideToArea(face1, side1, newarea);
|
||||||
} //end for
|
} //end for
|
||||||
//add all the faces (except the seperating ones) from the second area
|
//add all the faces (except the seperating ones) from the second area
|
||||||
//to the new area
|
//to the new area
|
||||||
for (face2 = tmparea2->tmpfaces; face2; face2 = nextface2)
|
for (face2 = tmparea2->tmpfaces; face2; face2 = nextface2)
|
||||||
{
|
{
|
||||||
side2 = (face2->frontarea != tmparea2);
|
side2 = (face2->frontarea != tmparea2);
|
||||||
nextface2 = face2->next[side2];
|
nextface2 = face2->next[side2];
|
||||||
//don't add seperating faces
|
//don't add seperating faces
|
||||||
if ((face2->frontarea == tmparea1 &&
|
if ((face2->frontarea == tmparea1 &&
|
||||||
face2->backarea == tmparea2) ||
|
face2->backarea == tmparea2) ||
|
||||||
(face2->frontarea == tmparea2 &&
|
(face2->frontarea == tmparea2 &&
|
||||||
face2->backarea == tmparea1))
|
face2->backarea == tmparea1))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
} //end if
|
} //end if
|
||||||
//
|
//
|
||||||
AAS_RemoveFaceFromArea(face2, tmparea2);
|
AAS_RemoveFaceFromArea(face2, tmparea2);
|
||||||
AAS_AddFaceSideToArea(face2, side2, newarea);
|
AAS_AddFaceSideToArea(face2, side2, newarea);
|
||||||
} //end for
|
} //end for
|
||||||
//free all shared faces
|
//free all shared faces
|
||||||
for (face1 = tmparea1->tmpfaces; face1; face1 = nextface1)
|
for (face1 = tmparea1->tmpfaces; face1; face1 = nextface1)
|
||||||
{
|
{
|
||||||
side1 = (face1->frontarea != tmparea1);
|
side1 = (face1->frontarea != tmparea1);
|
||||||
nextface1 = face1->next[side1];
|
nextface1 = face1->next[side1];
|
||||||
//
|
//
|
||||||
AAS_RemoveFaceFromArea(face1, face1->frontarea);
|
AAS_RemoveFaceFromArea(face1, face1->frontarea);
|
||||||
AAS_RemoveFaceFromArea(face1, face1->backarea);
|
AAS_RemoveFaceFromArea(face1, face1->backarea);
|
||||||
AAS_FreeTmpFace(face1);
|
AAS_FreeTmpFace(face1);
|
||||||
} //end for
|
} //end for
|
||||||
//
|
//
|
||||||
tmparea1->mergedarea = newarea;
|
tmparea1->mergedarea = newarea;
|
||||||
tmparea1->invalid = true;
|
tmparea1->invalid = true;
|
||||||
tmparea2->mergedarea = newarea;
|
tmparea2->mergedarea = newarea;
|
||||||
tmparea2->invalid = true;
|
tmparea2->invalid = true;
|
||||||
//
|
//
|
||||||
AAS_CheckArea(newarea);
|
AAS_CheckArea(newarea);
|
||||||
AAS_FlipAreaFaces(newarea);
|
AAS_FlipAreaFaces(newarea);
|
||||||
// Log_Print("merged area %d & %d to %d with %d faces\n", tmparea1->areanum, tmparea2->areanum, newarea->areanum);
|
// Log_Print("merged area %d & %d to %d with %d faces\n", tmparea1->areanum, tmparea2->areanum, newarea->areanum);
|
||||||
return true;
|
return true;
|
||||||
} //end of the function AAS_TryMergeFaceAreas
|
} //end of the function AAS_TryMergeFaceAreas
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
// try to merge areas
|
// try to merge areas
|
||||||
// merged areas are added to the end of the convex area list so merging
|
// merged areas are added to the end of the convex area list so merging
|
||||||
// will be tried for those areas as well
|
// will be tried for those areas as well
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: tmpaasworld
|
// Changes Globals: tmpaasworld
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
/*
|
/*
|
||||||
void AAS_MergeAreas(void)
|
void AAS_MergeAreas(void)
|
||||||
{
|
{
|
||||||
int side, nummerges;
|
int side, nummerges;
|
||||||
tmp_area_t *tmparea, *othertmparea;
|
tmp_area_t *tmparea, *othertmparea;
|
||||||
tmp_face_t *face;
|
tmp_face_t *face;
|
||||||
|
|
||||||
nummerges = 0;
|
nummerges = 0;
|
||||||
Log_Write("AAS_MergeAreas\r\n");
|
Log_Write("AAS_MergeAreas\r\n");
|
||||||
qprintf("%6d areas merged", 1);
|
qprintf("%6d areas merged", 1);
|
||||||
//first merge grounded areas only
|
//first merge grounded areas only
|
||||||
//NOTE: this is useless because the area settings aren't available yet
|
//NOTE: this is useless because the area settings aren't available yet
|
||||||
for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next)
|
for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next)
|
||||||
{
|
{
|
||||||
// Log_Print("checking area %d\n", i);
|
// Log_Print("checking area %d\n", i);
|
||||||
//if the area is invalid
|
//if the area is invalid
|
||||||
if (tmparea->invalid)
|
if (tmparea->invalid)
|
||||||
{
|
{
|
||||||
// Log_Print(" area invalid\n");
|
// Log_Print(" area invalid\n");
|
||||||
continue;
|
continue;
|
||||||
} //end if
|
} //end if
|
||||||
//
|
//
|
||||||
// if (!(tmparea->settings->areaflags & AREA_GROUNDED)) continue;
|
// if (!(tmparea->settings->areaflags & AREA_GROUNDED)) continue;
|
||||||
//
|
//
|
||||||
for (face = tmparea->tmpfaces; face; face = face->next[side])
|
for (face = tmparea->tmpfaces; face; face = face->next[side])
|
||||||
{
|
{
|
||||||
side = (face->frontarea != tmparea);
|
side = (face->frontarea != tmparea);
|
||||||
//if the face has both a front and back area
|
//if the face has both a front and back area
|
||||||
if (face->frontarea && face->backarea)
|
if (face->frontarea && face->backarea)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
if (face->frontarea == tmparea) othertmparea = face->backarea;
|
if (face->frontarea == tmparea) othertmparea = face->backarea;
|
||||||
else othertmparea = face->frontarea;
|
else othertmparea = face->frontarea;
|
||||||
// if (!(othertmparea->settings->areaflags & AREA_GROUNDED)) continue;
|
// if (!(othertmparea->settings->areaflags & AREA_GROUNDED)) continue;
|
||||||
// Log_Print(" checking area %d with %d\n", face->frontarea, face->backarea);
|
// Log_Print(" checking area %d with %d\n", face->frontarea, face->backarea);
|
||||||
if (AAS_TryMergeFaceAreas(face))
|
if (AAS_TryMergeFaceAreas(face))
|
||||||
{
|
{
|
||||||
qprintf("\r%6d", ++nummerges);
|
qprintf("\r%6d", ++nummerges);
|
||||||
break;
|
break;
|
||||||
} //end if
|
} //end if
|
||||||
} //end if
|
} //end if
|
||||||
} //end for
|
} //end for
|
||||||
} //end for
|
} //end for
|
||||||
//merge all areas
|
//merge all areas
|
||||||
for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next)
|
for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next)
|
||||||
{
|
{
|
||||||
// Log_Print("checking area %d\n", i);
|
// Log_Print("checking area %d\n", i);
|
||||||
//if the area is invalid
|
//if the area is invalid
|
||||||
if (tmparea->invalid)
|
if (tmparea->invalid)
|
||||||
{
|
{
|
||||||
// Log_Print(" area invalid\n");
|
// Log_Print(" area invalid\n");
|
||||||
continue;
|
continue;
|
||||||
} //end if
|
} //end if
|
||||||
//
|
//
|
||||||
for (face = tmparea->tmpfaces; face; face = face->next[side])
|
for (face = tmparea->tmpfaces; face; face = face->next[side])
|
||||||
{
|
{
|
||||||
side = (face->frontarea != tmparea);
|
side = (face->frontarea != tmparea);
|
||||||
//if the face has both a front and back area
|
//if the face has both a front and back area
|
||||||
if (face->frontarea && face->backarea)
|
if (face->frontarea && face->backarea)
|
||||||
{
|
{
|
||||||
// Log_Print(" checking area %d with %d\n", face->frontarea, face->backarea);
|
// Log_Print(" checking area %d with %d\n", face->frontarea, face->backarea);
|
||||||
if (AAS_TryMergeFaceAreas(face))
|
if (AAS_TryMergeFaceAreas(face))
|
||||||
{
|
{
|
||||||
qprintf("\r%6d", ++nummerges);
|
qprintf("\r%6d", ++nummerges);
|
||||||
break;
|
break;
|
||||||
} //end if
|
} //end if
|
||||||
} //end if
|
} //end if
|
||||||
} //end for
|
} //end for
|
||||||
} //end for
|
} //end for
|
||||||
Log_Print("\r%6d areas merged\n", nummerges);
|
Log_Print("\r%6d areas merged\n", nummerges);
|
||||||
//refresh the merged tree
|
//refresh the merged tree
|
||||||
AAS_RefreshMergedTree_r(tmpaasworld.nodes);
|
AAS_RefreshMergedTree_r(tmpaasworld.nodes);
|
||||||
} //end of the function AAS_MergeAreas*/
|
} //end of the function AAS_MergeAreas*/
|
||||||
|
|
||||||
int AAS_GroundArea(tmp_area_t *tmparea)
|
int AAS_GroundArea(tmp_area_t *tmparea)
|
||||||
{
|
{
|
||||||
tmp_face_t *face;
|
tmp_face_t *face;
|
||||||
int side;
|
int side;
|
||||||
|
|
||||||
for (face = tmparea->tmpfaces; face; face = face->next[side])
|
for (face = tmparea->tmpfaces; face; face = face->next[side])
|
||||||
{
|
{
|
||||||
side = (face->frontarea != tmparea);
|
side = (face->frontarea != tmparea);
|
||||||
if (face->faceflags & FACE_GROUND) return true;
|
if (face->faceflags & FACE_GROUND) return true;
|
||||||
} //end for
|
} //end for
|
||||||
return false;
|
return false;
|
||||||
} //end of the function AAS_GroundArea
|
} //end of the function AAS_GroundArea
|
||||||
|
|
||||||
void AAS_MergeAreas(void)
|
void AAS_MergeAreas(void)
|
||||||
{
|
{
|
||||||
int side, nummerges, merges, groundfirst;
|
int side, nummerges, merges, groundfirst;
|
||||||
tmp_area_t *tmparea, *othertmparea;
|
tmp_area_t *tmparea, *othertmparea;
|
||||||
tmp_face_t *face;
|
tmp_face_t *face;
|
||||||
|
|
||||||
nummerges = 0;
|
nummerges = 0;
|
||||||
Log_Write("AAS_MergeAreas\r\n");
|
Log_Write("AAS_MergeAreas\r\n");
|
||||||
qprintf("%6d areas merged", 1);
|
qprintf("%6d areas merged", 1);
|
||||||
//
|
//
|
||||||
groundfirst = true;
|
groundfirst = true;
|
||||||
//for (i = 0; i < 4 || merges; i++)
|
//for (i = 0; i < 4 || merges; i++)
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
//if (i < 2) groundfirst = true;
|
//if (i < 2) groundfirst = true;
|
||||||
//else groundfirst = false;
|
//else groundfirst = false;
|
||||||
//
|
//
|
||||||
merges = 0;
|
merges = 0;
|
||||||
//first merge grounded areas only
|
//first merge grounded areas only
|
||||||
for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next)
|
for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next)
|
||||||
{
|
{
|
||||||
//if the area is invalid
|
//if the area is invalid
|
||||||
if (tmparea->invalid)
|
if (tmparea->invalid)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
} //end if
|
} //end if
|
||||||
//
|
//
|
||||||
if (groundfirst)
|
if (groundfirst)
|
||||||
{
|
{
|
||||||
if (!AAS_GroundArea(tmparea)) continue;
|
if (!AAS_GroundArea(tmparea)) continue;
|
||||||
} //end if
|
} //end if
|
||||||
//
|
//
|
||||||
for (face = tmparea->tmpfaces; face; face = face->next[side])
|
for (face = tmparea->tmpfaces; face; face = face->next[side])
|
||||||
{
|
{
|
||||||
side = (face->frontarea != tmparea);
|
side = (face->frontarea != tmparea);
|
||||||
//if the face has both a front and back area
|
//if the face has both a front and back area
|
||||||
if (face->frontarea && face->backarea)
|
if (face->frontarea && face->backarea)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
if (face->frontarea == tmparea) othertmparea = face->backarea;
|
if (face->frontarea == tmparea) othertmparea = face->backarea;
|
||||||
else othertmparea = face->frontarea;
|
else othertmparea = face->frontarea;
|
||||||
//
|
//
|
||||||
if (groundfirst)
|
if (groundfirst)
|
||||||
{
|
{
|
||||||
if (!AAS_GroundArea(othertmparea)) continue;
|
if (!AAS_GroundArea(othertmparea)) continue;
|
||||||
} //end if
|
} //end if
|
||||||
if (AAS_TryMergeFaceAreas(face))
|
if (AAS_TryMergeFaceAreas(face))
|
||||||
{
|
{
|
||||||
qprintf("\r%6d", ++nummerges);
|
qprintf("\r%6d", ++nummerges);
|
||||||
merges++;
|
merges++;
|
||||||
break;
|
break;
|
||||||
} //end if
|
} //end if
|
||||||
} //end if
|
} //end if
|
||||||
} //end for
|
} //end for
|
||||||
} //end for
|
} //end for
|
||||||
if (!merges)
|
if (!merges)
|
||||||
{
|
{
|
||||||
if (groundfirst) groundfirst = false;
|
if (groundfirst) groundfirst = false;
|
||||||
else break;
|
else break;
|
||||||
} //end if
|
} //end if
|
||||||
} //end for
|
} //end for
|
||||||
qprintf("\n");
|
qprintf("\n");
|
||||||
Log_Write("%6d areas merged\r\n", nummerges);
|
Log_Write("%6d areas merged\r\n", nummerges);
|
||||||
//refresh the merged tree
|
//refresh the merged tree
|
||||||
AAS_RefreshMergedTree_r(tmpaasworld.nodes);
|
AAS_RefreshMergedTree_r(tmpaasworld.nodes);
|
||||||
} //end of the function AAS_MergeAreas
|
} //end of the function AAS_MergeAreas
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,24 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void AAS_MergeAreas(void);
|
void AAS_MergeAreas(void);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,252 +1,252 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "qbsp.h"
|
#include "qbsp.h"
|
||||||
#include "float.h"
|
#include "float.h"
|
||||||
#include "../botlib/aasfile.h"
|
#include "../botlib/aasfile.h"
|
||||||
#include "aas_store.h"
|
#include "aas_store.h"
|
||||||
#include "aas_cfg.h"
|
#include "aas_cfg.h"
|
||||||
#include "../botlib/l_precomp.h"
|
#include "../botlib/l_precomp.h"
|
||||||
#include "../botlib/l_struct.h"
|
#include "../botlib/l_struct.h"
|
||||||
#include "../botlib/l_libvar.h"
|
#include "../botlib/l_libvar.h"
|
||||||
|
|
||||||
//structure field offsets
|
//structure field offsets
|
||||||
#define BBOX_OFS(x) (int)&(((aas_bbox_t *)0)->x)
|
#define BBOX_OFS(x) (int)&(((aas_bbox_t *)0)->x)
|
||||||
#define CFG_OFS(x) (int)&(((cfg_t *)0)->x)
|
#define CFG_OFS(x) (int)&(((cfg_t *)0)->x)
|
||||||
|
|
||||||
//bounding box definition
|
//bounding box definition
|
||||||
fielddef_t bbox_fields[] =
|
fielddef_t bbox_fields[] =
|
||||||
{
|
{
|
||||||
{"presencetype", BBOX_OFS(presencetype), FT_INT},
|
{"presencetype", BBOX_OFS(presencetype), FT_INT},
|
||||||
{"flags", BBOX_OFS(flags), FT_INT},
|
{"flags", BBOX_OFS(flags), FT_INT},
|
||||||
{"mins", BBOX_OFS(mins), FT_FLOAT|FT_ARRAY, 3},
|
{"mins", BBOX_OFS(mins), FT_FLOAT|FT_ARRAY, 3},
|
||||||
{"maxs", BBOX_OFS(maxs), FT_FLOAT|FT_ARRAY, 3},
|
{"maxs", BBOX_OFS(maxs), FT_FLOAT|FT_ARRAY, 3},
|
||||||
{NULL, 0, 0, 0}
|
{NULL, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
fielddef_t cfg_fields[] =
|
fielddef_t cfg_fields[] =
|
||||||
{
|
{
|
||||||
{"phys_gravitydirection", CFG_OFS(phys_gravitydirection), FT_FLOAT|FT_ARRAY, 3},
|
{"phys_gravitydirection", CFG_OFS(phys_gravitydirection), FT_FLOAT|FT_ARRAY, 3},
|
||||||
{"phys_friction", CFG_OFS(phys_friction), FT_FLOAT},
|
{"phys_friction", CFG_OFS(phys_friction), FT_FLOAT},
|
||||||
{"phys_stopspeed", CFG_OFS(phys_stopspeed), FT_FLOAT},
|
{"phys_stopspeed", CFG_OFS(phys_stopspeed), FT_FLOAT},
|
||||||
{"phys_gravity", CFG_OFS(phys_gravity), FT_FLOAT},
|
{"phys_gravity", CFG_OFS(phys_gravity), FT_FLOAT},
|
||||||
{"phys_waterfriction", CFG_OFS(phys_waterfriction), FT_FLOAT},
|
{"phys_waterfriction", CFG_OFS(phys_waterfriction), FT_FLOAT},
|
||||||
{"phys_watergravity", CFG_OFS(phys_watergravity), FT_FLOAT},
|
{"phys_watergravity", CFG_OFS(phys_watergravity), FT_FLOAT},
|
||||||
{"phys_maxvelocity", CFG_OFS(phys_maxvelocity), FT_FLOAT},
|
{"phys_maxvelocity", CFG_OFS(phys_maxvelocity), FT_FLOAT},
|
||||||
{"phys_maxwalkvelocity", CFG_OFS(phys_maxwalkvelocity), FT_FLOAT},
|
{"phys_maxwalkvelocity", CFG_OFS(phys_maxwalkvelocity), FT_FLOAT},
|
||||||
{"phys_maxcrouchvelocity", CFG_OFS(phys_maxcrouchvelocity), FT_FLOAT},
|
{"phys_maxcrouchvelocity", CFG_OFS(phys_maxcrouchvelocity), FT_FLOAT},
|
||||||
{"phys_maxswimvelocity", CFG_OFS(phys_maxswimvelocity), FT_FLOAT},
|
{"phys_maxswimvelocity", CFG_OFS(phys_maxswimvelocity), FT_FLOAT},
|
||||||
{"phys_walkaccelerate", CFG_OFS(phys_walkaccelerate), FT_FLOAT},
|
{"phys_walkaccelerate", CFG_OFS(phys_walkaccelerate), FT_FLOAT},
|
||||||
{"phys_airaccelerate", CFG_OFS(phys_airaccelerate), FT_FLOAT},
|
{"phys_airaccelerate", CFG_OFS(phys_airaccelerate), FT_FLOAT},
|
||||||
{"phys_swimaccelerate", CFG_OFS(phys_swimaccelerate), FT_FLOAT},
|
{"phys_swimaccelerate", CFG_OFS(phys_swimaccelerate), FT_FLOAT},
|
||||||
{"phys_maxstep", CFG_OFS(phys_maxstep), FT_FLOAT},
|
{"phys_maxstep", CFG_OFS(phys_maxstep), FT_FLOAT},
|
||||||
{"phys_maxsteepness", CFG_OFS(phys_maxsteepness), FT_FLOAT},
|
{"phys_maxsteepness", CFG_OFS(phys_maxsteepness), FT_FLOAT},
|
||||||
{"phys_maxwaterjump", CFG_OFS(phys_maxwaterjump), FT_FLOAT},
|
{"phys_maxwaterjump", CFG_OFS(phys_maxwaterjump), FT_FLOAT},
|
||||||
{"phys_maxbarrier", CFG_OFS(phys_maxbarrier), FT_FLOAT},
|
{"phys_maxbarrier", CFG_OFS(phys_maxbarrier), FT_FLOAT},
|
||||||
{"phys_jumpvel", CFG_OFS(phys_jumpvel), FT_FLOAT},
|
{"phys_jumpvel", CFG_OFS(phys_jumpvel), FT_FLOAT},
|
||||||
{"phys_falldelta5", CFG_OFS(phys_falldelta5), FT_FLOAT},
|
{"phys_falldelta5", CFG_OFS(phys_falldelta5), FT_FLOAT},
|
||||||
{"phys_falldelta10", CFG_OFS(phys_falldelta10), FT_FLOAT},
|
{"phys_falldelta10", CFG_OFS(phys_falldelta10), FT_FLOAT},
|
||||||
{"rs_waterjump", CFG_OFS(rs_waterjump), FT_FLOAT},
|
{"rs_waterjump", CFG_OFS(rs_waterjump), FT_FLOAT},
|
||||||
{"rs_teleport", CFG_OFS(rs_teleport), FT_FLOAT},
|
{"rs_teleport", CFG_OFS(rs_teleport), FT_FLOAT},
|
||||||
{"rs_barrierjump", CFG_OFS(rs_barrierjump), FT_FLOAT},
|
{"rs_barrierjump", CFG_OFS(rs_barrierjump), FT_FLOAT},
|
||||||
{"rs_startcrouch", CFG_OFS(rs_startcrouch), FT_FLOAT},
|
{"rs_startcrouch", CFG_OFS(rs_startcrouch), FT_FLOAT},
|
||||||
{"rs_startgrapple", CFG_OFS(rs_startgrapple), FT_FLOAT},
|
{"rs_startgrapple", CFG_OFS(rs_startgrapple), FT_FLOAT},
|
||||||
{"rs_startwalkoffledge", CFG_OFS(rs_startwalkoffledge), FT_FLOAT},
|
{"rs_startwalkoffledge", CFG_OFS(rs_startwalkoffledge), FT_FLOAT},
|
||||||
{"rs_startjump", CFG_OFS(rs_startjump), FT_FLOAT},
|
{"rs_startjump", CFG_OFS(rs_startjump), FT_FLOAT},
|
||||||
{"rs_rocketjump", CFG_OFS(rs_rocketjump), FT_FLOAT},
|
{"rs_rocketjump", CFG_OFS(rs_rocketjump), FT_FLOAT},
|
||||||
{"rs_bfgjump", CFG_OFS(rs_bfgjump), FT_FLOAT},
|
{"rs_bfgjump", CFG_OFS(rs_bfgjump), FT_FLOAT},
|
||||||
{"rs_jumppad", CFG_OFS(rs_jumppad), FT_FLOAT},
|
{"rs_jumppad", CFG_OFS(rs_jumppad), FT_FLOAT},
|
||||||
{"rs_aircontrolledjumppad", CFG_OFS(rs_aircontrolledjumppad), FT_FLOAT},
|
{"rs_aircontrolledjumppad", CFG_OFS(rs_aircontrolledjumppad), FT_FLOAT},
|
||||||
{"rs_funcbob", CFG_OFS(rs_funcbob), FT_FLOAT},
|
{"rs_funcbob", CFG_OFS(rs_funcbob), FT_FLOAT},
|
||||||
{"rs_startelevator", CFG_OFS(rs_startelevator), FT_FLOAT},
|
{"rs_startelevator", CFG_OFS(rs_startelevator), FT_FLOAT},
|
||||||
{"rs_falldamage5", CFG_OFS(rs_falldamage5), FT_FLOAT},
|
{"rs_falldamage5", CFG_OFS(rs_falldamage5), FT_FLOAT},
|
||||||
{"rs_falldamage10", CFG_OFS(rs_falldamage10), FT_FLOAT},
|
{"rs_falldamage10", CFG_OFS(rs_falldamage10), FT_FLOAT},
|
||||||
{"rs_maxjumpfallheight", CFG_OFS(rs_maxjumpfallheight), FT_FLOAT},
|
{"rs_maxjumpfallheight", CFG_OFS(rs_maxjumpfallheight), FT_FLOAT},
|
||||||
{NULL, 0, 0, 0}
|
{NULL, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
structdef_t bbox_struct =
|
structdef_t bbox_struct =
|
||||||
{
|
{
|
||||||
sizeof(aas_bbox_t), bbox_fields
|
sizeof(aas_bbox_t), bbox_fields
|
||||||
};
|
};
|
||||||
structdef_t cfg_struct =
|
structdef_t cfg_struct =
|
||||||
{
|
{
|
||||||
sizeof(cfg_t), cfg_fields
|
sizeof(cfg_t), cfg_fields
|
||||||
};
|
};
|
||||||
|
|
||||||
//global cfg
|
//global cfg
|
||||||
cfg_t cfg;
|
cfg_t cfg;
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
// the default Q3A configuration
|
// the default Q3A configuration
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void DefaultCfg(void)
|
void DefaultCfg(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
// default all float values to infinite
|
// default all float values to infinite
|
||||||
for (i = 0; cfg_fields[i].name; i++)
|
for (i = 0; cfg_fields[i].name; i++)
|
||||||
{
|
{
|
||||||
if ((cfg_fields[i].type & FT_TYPE) == FT_FLOAT)
|
if ((cfg_fields[i].type & FT_TYPE) == FT_FLOAT)
|
||||||
*(float *)( ((char*)&cfg) + cfg_fields[i].offset ) = FLT_MAX;
|
*(float *)( ((char*)&cfg) + cfg_fields[i].offset ) = FLT_MAX;
|
||||||
} //end for
|
} //end for
|
||||||
//
|
//
|
||||||
cfg.numbboxes = 2;
|
cfg.numbboxes = 2;
|
||||||
//bbox 0
|
//bbox 0
|
||||||
cfg.bboxes[0].presencetype = PRESENCE_NORMAL;
|
cfg.bboxes[0].presencetype = PRESENCE_NORMAL;
|
||||||
cfg.bboxes[0].flags = 0;
|
cfg.bboxes[0].flags = 0;
|
||||||
cfg.bboxes[0].mins[0] = -15;
|
cfg.bboxes[0].mins[0] = -15;
|
||||||
cfg.bboxes[0].mins[1] = -15;
|
cfg.bboxes[0].mins[1] = -15;
|
||||||
cfg.bboxes[0].mins[2] = -24;
|
cfg.bboxes[0].mins[2] = -24;
|
||||||
cfg.bboxes[0].maxs[0] = 15;
|
cfg.bboxes[0].maxs[0] = 15;
|
||||||
cfg.bboxes[0].maxs[1] = 15;
|
cfg.bboxes[0].maxs[1] = 15;
|
||||||
cfg.bboxes[0].maxs[2] = 32;
|
cfg.bboxes[0].maxs[2] = 32;
|
||||||
//bbox 1
|
//bbox 1
|
||||||
cfg.bboxes[1].presencetype = PRESENCE_CROUCH;
|
cfg.bboxes[1].presencetype = PRESENCE_CROUCH;
|
||||||
cfg.bboxes[1].flags = 1;
|
cfg.bboxes[1].flags = 1;
|
||||||
cfg.bboxes[1].mins[0] = -15;
|
cfg.bboxes[1].mins[0] = -15;
|
||||||
cfg.bboxes[1].mins[1] = -15;
|
cfg.bboxes[1].mins[1] = -15;
|
||||||
cfg.bboxes[1].mins[2] = -24;
|
cfg.bboxes[1].mins[2] = -24;
|
||||||
cfg.bboxes[1].maxs[0] = 15;
|
cfg.bboxes[1].maxs[0] = 15;
|
||||||
cfg.bboxes[1].maxs[1] = 15;
|
cfg.bboxes[1].maxs[1] = 15;
|
||||||
cfg.bboxes[1].maxs[2] = 16;
|
cfg.bboxes[1].maxs[2] = 16;
|
||||||
//
|
//
|
||||||
cfg.allpresencetypes = PRESENCE_NORMAL|PRESENCE_CROUCH;
|
cfg.allpresencetypes = PRESENCE_NORMAL|PRESENCE_CROUCH;
|
||||||
cfg.phys_gravitydirection[0] = 0;
|
cfg.phys_gravitydirection[0] = 0;
|
||||||
cfg.phys_gravitydirection[1] = 0;
|
cfg.phys_gravitydirection[1] = 0;
|
||||||
cfg.phys_gravitydirection[2] = -1;
|
cfg.phys_gravitydirection[2] = -1;
|
||||||
cfg.phys_maxsteepness = 0.7;
|
cfg.phys_maxsteepness = 0.7;
|
||||||
} //end of the function DefaultCfg
|
} //end of the function DefaultCfg
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
char * QDECL va( char *format, ... )
|
char * QDECL va( char *format, ... )
|
||||||
{
|
{
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
static char string[2][32000]; // in case va is called by nested functions
|
static char string[2][32000]; // in case va is called by nested functions
|
||||||
static int index = 0;
|
static int index = 0;
|
||||||
char *buf;
|
char *buf;
|
||||||
|
|
||||||
buf = string[index & 1];
|
buf = string[index & 1];
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
va_start (argptr, format);
|
va_start (argptr, format);
|
||||||
vsprintf (buf, format,argptr);
|
vsprintf (buf, format,argptr);
|
||||||
va_end (argptr);
|
va_end (argptr);
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
} //end of the function va
|
} //end of the function va
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void SetCfgLibVars(void)
|
void SetCfgLibVars(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
float value;
|
float value;
|
||||||
|
|
||||||
for (i = 0; cfg_fields[i].name; i++)
|
for (i = 0; cfg_fields[i].name; i++)
|
||||||
{
|
{
|
||||||
if ((cfg_fields[i].type & FT_TYPE) == FT_FLOAT)
|
if ((cfg_fields[i].type & FT_TYPE) == FT_FLOAT)
|
||||||
{
|
{
|
||||||
value = *(float *)(((char*)&cfg) + cfg_fields[i].offset);
|
value = *(float *)(((char*)&cfg) + cfg_fields[i].offset);
|
||||||
if (value != FLT_MAX)
|
if (value != FLT_MAX)
|
||||||
{
|
{
|
||||||
LibVarSet(cfg_fields[i].name, va("%f", value));
|
LibVarSet(cfg_fields[i].name, va("%f", value));
|
||||||
} //end if
|
} //end if
|
||||||
} //end if
|
} //end if
|
||||||
} //end for
|
} //end for
|
||||||
} //end of the function SetCfgLibVars
|
} //end of the function SetCfgLibVars
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int LoadCfgFile(char *filename)
|
int LoadCfgFile(char *filename)
|
||||||
{
|
{
|
||||||
source_t *source;
|
source_t *source;
|
||||||
token_t token;
|
token_t token;
|
||||||
int settingsdefined;
|
int settingsdefined;
|
||||||
|
|
||||||
source = LoadSourceFile(filename);
|
source = LoadSourceFile(filename);
|
||||||
if (!source)
|
if (!source)
|
||||||
{
|
{
|
||||||
Log_Print("couldn't open cfg file %s\n", filename);
|
Log_Print("couldn't open cfg file %s\n", filename);
|
||||||
return false;
|
return false;
|
||||||
} //end if
|
} //end if
|
||||||
|
|
||||||
settingsdefined = false;
|
settingsdefined = false;
|
||||||
memset(&cfg, 0, sizeof(cfg_t));
|
memset(&cfg, 0, sizeof(cfg_t));
|
||||||
|
|
||||||
while(PC_ReadToken(source, &token))
|
while(PC_ReadToken(source, &token))
|
||||||
{
|
{
|
||||||
if (!stricmp(token.string, "bbox"))
|
if (!stricmp(token.string, "bbox"))
|
||||||
{
|
{
|
||||||
if (cfg.numbboxes >= AAS_MAX_BBOXES)
|
if (cfg.numbboxes >= AAS_MAX_BBOXES)
|
||||||
{
|
{
|
||||||
SourceError(source, "too many bounding box volumes defined");
|
SourceError(source, "too many bounding box volumes defined");
|
||||||
} //end if
|
} //end if
|
||||||
if (!ReadStructure(source, &bbox_struct, (char *) &cfg.bboxes[cfg.numbboxes]))
|
if (!ReadStructure(source, &bbox_struct, (char *) &cfg.bboxes[cfg.numbboxes]))
|
||||||
{
|
{
|
||||||
FreeSource(source);
|
FreeSource(source);
|
||||||
return false;
|
return false;
|
||||||
} //end if
|
} //end if
|
||||||
cfg.allpresencetypes |= cfg.bboxes[cfg.numbboxes].presencetype;
|
cfg.allpresencetypes |= cfg.bboxes[cfg.numbboxes].presencetype;
|
||||||
cfg.numbboxes++;
|
cfg.numbboxes++;
|
||||||
} //end if
|
} //end if
|
||||||
else if (!stricmp(token.string, "settings"))
|
else if (!stricmp(token.string, "settings"))
|
||||||
{
|
{
|
||||||
if (settingsdefined)
|
if (settingsdefined)
|
||||||
{
|
{
|
||||||
SourceWarning(source, "settings already defined\n");
|
SourceWarning(source, "settings already defined\n");
|
||||||
} //end if
|
} //end if
|
||||||
settingsdefined = true;
|
settingsdefined = true;
|
||||||
if (!ReadStructure(source, &cfg_struct, (char *) &cfg))
|
if (!ReadStructure(source, &cfg_struct, (char *) &cfg))
|
||||||
{
|
{
|
||||||
FreeSource(source);
|
FreeSource(source);
|
||||||
return false;
|
return false;
|
||||||
} //end if
|
} //end if
|
||||||
} //end else if
|
} //end else if
|
||||||
} //end while
|
} //end while
|
||||||
if (VectorLength(cfg.phys_gravitydirection) < 0.9 || VectorLength(cfg.phys_gravitydirection) > 1.1)
|
if (VectorLength(cfg.phys_gravitydirection) < 0.9 || VectorLength(cfg.phys_gravitydirection) > 1.1)
|
||||||
{
|
{
|
||||||
SourceError(source, "invalid gravity direction specified");
|
SourceError(source, "invalid gravity direction specified");
|
||||||
} //end if
|
} //end if
|
||||||
if (cfg.numbboxes <= 0)
|
if (cfg.numbboxes <= 0)
|
||||||
{
|
{
|
||||||
SourceError(source, "no bounding volumes specified");
|
SourceError(source, "no bounding volumes specified");
|
||||||
} //end if
|
} //end if
|
||||||
FreeSource(source);
|
FreeSource(source);
|
||||||
SetCfgLibVars();
|
SetCfgLibVars();
|
||||||
Log_Print("using cfg file %s\n", filename);
|
Log_Print("using cfg file %s\n", filename);
|
||||||
return true;
|
return true;
|
||||||
} //end of the function LoadCfgFile
|
} //end of the function LoadCfgFile
|
||||||
|
|
|
||||||
|
|
@ -1,73 +1,73 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define BBOXFL_GROUNDED 1 //bounding box only valid when on ground
|
#define BBOXFL_GROUNDED 1 //bounding box only valid when on ground
|
||||||
#define BBOXFL_NOTGROUNDED 2 //bounding box only valid when NOT on ground
|
#define BBOXFL_NOTGROUNDED 2 //bounding box only valid when NOT on ground
|
||||||
|
|
||||||
typedef struct cfg_s
|
typedef struct cfg_s
|
||||||
{
|
{
|
||||||
int numbboxes; //number of bounding boxes
|
int numbboxes; //number of bounding boxes
|
||||||
aas_bbox_t bboxes[AAS_MAX_BBOXES]; //all the bounding boxes
|
aas_bbox_t bboxes[AAS_MAX_BBOXES]; //all the bounding boxes
|
||||||
int allpresencetypes; //or of all presence types
|
int allpresencetypes; //or of all presence types
|
||||||
// aas settings
|
// aas settings
|
||||||
vec3_t phys_gravitydirection;
|
vec3_t phys_gravitydirection;
|
||||||
float phys_friction;
|
float phys_friction;
|
||||||
float phys_stopspeed;
|
float phys_stopspeed;
|
||||||
float phys_gravity;
|
float phys_gravity;
|
||||||
float phys_waterfriction;
|
float phys_waterfriction;
|
||||||
float phys_watergravity;
|
float phys_watergravity;
|
||||||
float phys_maxvelocity;
|
float phys_maxvelocity;
|
||||||
float phys_maxwalkvelocity;
|
float phys_maxwalkvelocity;
|
||||||
float phys_maxcrouchvelocity;
|
float phys_maxcrouchvelocity;
|
||||||
float phys_maxswimvelocity;
|
float phys_maxswimvelocity;
|
||||||
float phys_walkaccelerate;
|
float phys_walkaccelerate;
|
||||||
float phys_airaccelerate;
|
float phys_airaccelerate;
|
||||||
float phys_swimaccelerate;
|
float phys_swimaccelerate;
|
||||||
float phys_maxstep;
|
float phys_maxstep;
|
||||||
float phys_maxsteepness;
|
float phys_maxsteepness;
|
||||||
float phys_maxwaterjump;
|
float phys_maxwaterjump;
|
||||||
float phys_maxbarrier;
|
float phys_maxbarrier;
|
||||||
float phys_jumpvel;
|
float phys_jumpvel;
|
||||||
float phys_falldelta5;
|
float phys_falldelta5;
|
||||||
float phys_falldelta10;
|
float phys_falldelta10;
|
||||||
float rs_waterjump;
|
float rs_waterjump;
|
||||||
float rs_teleport;
|
float rs_teleport;
|
||||||
float rs_barrierjump;
|
float rs_barrierjump;
|
||||||
float rs_startcrouch;
|
float rs_startcrouch;
|
||||||
float rs_startgrapple;
|
float rs_startgrapple;
|
||||||
float rs_startwalkoffledge;
|
float rs_startwalkoffledge;
|
||||||
float rs_startjump;
|
float rs_startjump;
|
||||||
float rs_rocketjump;
|
float rs_rocketjump;
|
||||||
float rs_bfgjump;
|
float rs_bfgjump;
|
||||||
float rs_jumppad;
|
float rs_jumppad;
|
||||||
float rs_aircontrolledjumppad;
|
float rs_aircontrolledjumppad;
|
||||||
float rs_funcbob;
|
float rs_funcbob;
|
||||||
float rs_startelevator;
|
float rs_startelevator;
|
||||||
float rs_falldamage5;
|
float rs_falldamage5;
|
||||||
float rs_falldamage10;
|
float rs_falldamage10;
|
||||||
float rs_maxjumpfallheight;
|
float rs_maxjumpfallheight;
|
||||||
} cfg_t;
|
} cfg_t;
|
||||||
|
|
||||||
extern cfg_t cfg;
|
extern cfg_t cfg;
|
||||||
|
|
||||||
void DefaultCfg(void);
|
void DefaultCfg(void);
|
||||||
int LoadCfgFile(char *filename);
|
int LoadCfgFile(char *filename);
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,136 +1,136 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define AREA_PORTAL 1
|
#define AREA_PORTAL 1
|
||||||
|
|
||||||
//temporary AAS face
|
//temporary AAS face
|
||||||
typedef struct tmp_face_s
|
typedef struct tmp_face_s
|
||||||
{
|
{
|
||||||
int num; //face number
|
int num; //face number
|
||||||
int planenum; //number of the plane the face is in
|
int planenum; //number of the plane the face is in
|
||||||
winding_t *winding; //winding of the face
|
winding_t *winding; //winding of the face
|
||||||
struct tmp_area_s *frontarea; //area at the front of the face
|
struct tmp_area_s *frontarea; //area at the front of the face
|
||||||
struct tmp_area_s *backarea; //area at the back of the face
|
struct tmp_area_s *backarea; //area at the back of the face
|
||||||
int faceflags; //flags of this face
|
int faceflags; //flags of this face
|
||||||
int aasfacenum; //the number of the aas face used for this face
|
int aasfacenum; //the number of the aas face used for this face
|
||||||
//double link list pointers for front and back area
|
//double link list pointers for front and back area
|
||||||
struct tmp_face_s *prev[2], *next[2];
|
struct tmp_face_s *prev[2], *next[2];
|
||||||
//links in the list with faces
|
//links in the list with faces
|
||||||
struct tmp_face_s *l_prev, *l_next;
|
struct tmp_face_s *l_prev, *l_next;
|
||||||
} tmp_face_t;
|
} tmp_face_t;
|
||||||
|
|
||||||
//temporary AAS area settings
|
//temporary AAS area settings
|
||||||
typedef struct tmp_areasettings_s
|
typedef struct tmp_areasettings_s
|
||||||
{
|
{
|
||||||
//could also add all kind of statistic fields
|
//could also add all kind of statistic fields
|
||||||
int contents; //contents of the area
|
int contents; //contents of the area
|
||||||
int modelnum; //bsp model inside this area
|
int modelnum; //bsp model inside this area
|
||||||
int areaflags; //area flags
|
int areaflags; //area flags
|
||||||
int presencetype; //how a bot can be present in this area
|
int presencetype; //how a bot can be present in this area
|
||||||
int numreachableareas; //number of reachable areas from this one
|
int numreachableareas; //number of reachable areas from this one
|
||||||
int firstreachablearea; //first reachable area in the reachable area index
|
int firstreachablearea; //first reachable area in the reachable area index
|
||||||
} tmp_areasettings_t;
|
} tmp_areasettings_t;
|
||||||
|
|
||||||
//temporary AAS area
|
//temporary AAS area
|
||||||
typedef struct tmp_area_s
|
typedef struct tmp_area_s
|
||||||
{
|
{
|
||||||
int areanum; //number of the area
|
int areanum; //number of the area
|
||||||
struct tmp_face_s *tmpfaces; //the faces of the area
|
struct tmp_face_s *tmpfaces; //the faces of the area
|
||||||
int presencetype; //presence type of the area
|
int presencetype; //presence type of the area
|
||||||
int contents; //area contents
|
int contents; //area contents
|
||||||
int modelnum; //bsp model inside this area
|
int modelnum; //bsp model inside this area
|
||||||
int invalid; //true if the area is invalid
|
int invalid; //true if the area is invalid
|
||||||
tmp_areasettings_t *settings; //area settings
|
tmp_areasettings_t *settings; //area settings
|
||||||
struct tmp_area_s *mergedarea; //points to the new area after merging
|
struct tmp_area_s *mergedarea; //points to the new area after merging
|
||||||
//when mergedarea != 0 the area has only the
|
//when mergedarea != 0 the area has only the
|
||||||
//seperating face of the merged areas
|
//seperating face of the merged areas
|
||||||
int aasareanum; //number of the aas area created for this tmp area
|
int aasareanum; //number of the aas area created for this tmp area
|
||||||
//links in the list with areas
|
//links in the list with areas
|
||||||
struct tmp_area_s *l_prev, *l_next;
|
struct tmp_area_s *l_prev, *l_next;
|
||||||
} tmp_area_t;
|
} tmp_area_t;
|
||||||
|
|
||||||
//temporary AAS node
|
//temporary AAS node
|
||||||
typedef struct tmp_node_s
|
typedef struct tmp_node_s
|
||||||
{
|
{
|
||||||
int planenum; //node plane number
|
int planenum; //node plane number
|
||||||
struct tmp_area_s *tmparea; //points to an area if this node is an area
|
struct tmp_area_s *tmparea; //points to an area if this node is an area
|
||||||
struct tmp_node_s *children[2]; //child nodes of this node
|
struct tmp_node_s *children[2]; //child nodes of this node
|
||||||
} tmp_node_t;
|
} tmp_node_t;
|
||||||
|
|
||||||
#define NODEBUF_SIZE 128
|
#define NODEBUF_SIZE 128
|
||||||
//node buffer
|
//node buffer
|
||||||
typedef struct tmp_nodebuf_s
|
typedef struct tmp_nodebuf_s
|
||||||
{
|
{
|
||||||
int numnodes;
|
int numnodes;
|
||||||
struct tmp_nodebuf_s *next;
|
struct tmp_nodebuf_s *next;
|
||||||
tmp_node_t nodes[NODEBUF_SIZE];
|
tmp_node_t nodes[NODEBUF_SIZE];
|
||||||
} tmp_nodebuf_t;
|
} tmp_nodebuf_t;
|
||||||
|
|
||||||
//the whole temorary AAS
|
//the whole temorary AAS
|
||||||
typedef struct tmp_aas_s
|
typedef struct tmp_aas_s
|
||||||
{
|
{
|
||||||
//faces
|
//faces
|
||||||
int numfaces;
|
int numfaces;
|
||||||
int facenum;
|
int facenum;
|
||||||
tmp_face_t *faces;
|
tmp_face_t *faces;
|
||||||
//areas
|
//areas
|
||||||
int numareas;
|
int numareas;
|
||||||
int areanum;
|
int areanum;
|
||||||
tmp_area_t *areas;
|
tmp_area_t *areas;
|
||||||
//area settings
|
//area settings
|
||||||
int numareasettings;
|
int numareasettings;
|
||||||
tmp_areasettings_t *areasettings;
|
tmp_areasettings_t *areasettings;
|
||||||
//nodes
|
//nodes
|
||||||
int numnodes;
|
int numnodes;
|
||||||
tmp_node_t *nodes;
|
tmp_node_t *nodes;
|
||||||
//node buffer
|
//node buffer
|
||||||
tmp_nodebuf_t *nodebuffer;
|
tmp_nodebuf_t *nodebuffer;
|
||||||
} tmp_aas_t;
|
} tmp_aas_t;
|
||||||
|
|
||||||
extern tmp_aas_t tmpaasworld;
|
extern tmp_aas_t tmpaasworld;
|
||||||
|
|
||||||
//creates a .AAS file with the given name from an already loaded map
|
//creates a .AAS file with the given name from an already loaded map
|
||||||
void AAS_Create(char *aasfile);
|
void AAS_Create(char *aasfile);
|
||||||
//adds a face side to an area
|
//adds a face side to an area
|
||||||
void AAS_AddFaceSideToArea(tmp_face_t *tmpface, int side, tmp_area_t *tmparea);
|
void AAS_AddFaceSideToArea(tmp_face_t *tmpface, int side, tmp_area_t *tmparea);
|
||||||
//remvoes a face from an area
|
//remvoes a face from an area
|
||||||
void AAS_RemoveFaceFromArea(tmp_face_t *tmpface, tmp_area_t *tmparea);
|
void AAS_RemoveFaceFromArea(tmp_face_t *tmpface, tmp_area_t *tmparea);
|
||||||
//allocate a tmp face
|
//allocate a tmp face
|
||||||
tmp_face_t *AAS_AllocTmpFace(void);
|
tmp_face_t *AAS_AllocTmpFace(void);
|
||||||
//free the tmp face
|
//free the tmp face
|
||||||
void AAS_FreeTmpFace(tmp_face_t *tmpface);
|
void AAS_FreeTmpFace(tmp_face_t *tmpface);
|
||||||
//allocate a tmp area
|
//allocate a tmp area
|
||||||
tmp_area_t *AAS_AllocTmpArea(void);
|
tmp_area_t *AAS_AllocTmpArea(void);
|
||||||
//free a tmp area
|
//free a tmp area
|
||||||
void AAS_FreeTmpArea(tmp_area_t *tmparea);
|
void AAS_FreeTmpArea(tmp_area_t *tmparea);
|
||||||
//allocate a tmp node
|
//allocate a tmp node
|
||||||
tmp_node_t *AAS_AllocTmpNode(void);
|
tmp_node_t *AAS_AllocTmpNode(void);
|
||||||
//free a tmp node
|
//free a tmp node
|
||||||
void AAS_FreeTmpNode(tmp_node_t *node);
|
void AAS_FreeTmpNode(tmp_node_t *node);
|
||||||
//checks if an area is ok
|
//checks if an area is ok
|
||||||
void AAS_CheckArea(tmp_area_t *tmparea);
|
void AAS_CheckArea(tmp_area_t *tmparea);
|
||||||
//flips the area faces where needed
|
//flips the area faces where needed
|
||||||
void AAS_FlipAreaFaces(tmp_area_t *tmparea);
|
void AAS_FlipAreaFaces(tmp_area_t *tmparea);
|
||||||
//returns true if the face is a gap seen from the given side
|
//returns true if the face is a gap seen from the given side
|
||||||
int AAS_GapFace(tmp_face_t *tmpface, int side);
|
int AAS_GapFace(tmp_face_t *tmpface, int side);
|
||||||
//returns true if the face is a ground face
|
//returns true if the face is a ground face
|
||||||
int AAS_GroundFace(tmp_face_t *tmpface);
|
int AAS_GroundFace(tmp_face_t *tmpface);
|
||||||
|
|
|
||||||
|
|
@ -1,108 +1,108 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "qbsp.h"
|
#include "qbsp.h"
|
||||||
#include "../botlib/aasfile.h"
|
#include "../botlib/aasfile.h"
|
||||||
#include "aas_create.h"
|
#include "aas_create.h"
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
// try to melt the windings of the two faces
|
// try to melt the windings of the two faces
|
||||||
// FIXME: this is buggy
|
// FIXME: this is buggy
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_MeltFaceWinding(tmp_face_t *face1, tmp_face_t *face2)
|
int AAS_MeltFaceWinding(tmp_face_t *face1, tmp_face_t *face2)
|
||||||
{
|
{
|
||||||
int i, n;
|
int i, n;
|
||||||
int splits = 0;
|
int splits = 0;
|
||||||
winding_t *w2, *neww;
|
winding_t *w2, *neww;
|
||||||
plane_t *plane1;
|
plane_t *plane1;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (!face1->winding) Error("face1 %d without winding", face1->num);
|
if (!face1->winding) Error("face1 %d without winding", face1->num);
|
||||||
if (!face2->winding) Error("face2 %d without winding", face2->num);
|
if (!face2->winding) Error("face2 %d without winding", face2->num);
|
||||||
#endif //DEBUG
|
#endif //DEBUG
|
||||||
w2 = face2->winding;
|
w2 = face2->winding;
|
||||||
plane1 = &mapplanes[face1->planenum];
|
plane1 = &mapplanes[face1->planenum];
|
||||||
for (i = 0; i < w2->numpoints; i++)
|
for (i = 0; i < w2->numpoints; i++)
|
||||||
{
|
{
|
||||||
if (PointOnWinding(face1->winding, plane1->normal, plane1->dist, w2->p[i], &n))
|
if (PointOnWinding(face1->winding, plane1->normal, plane1->dist, w2->p[i], &n))
|
||||||
{
|
{
|
||||||
neww = AddWindingPoint(face1->winding, w2->p[i], n);
|
neww = AddWindingPoint(face1->winding, w2->p[i], n);
|
||||||
FreeWinding(face1->winding);
|
FreeWinding(face1->winding);
|
||||||
face1->winding = neww;
|
face1->winding = neww;
|
||||||
|
|
||||||
splits++;
|
splits++;
|
||||||
} //end if
|
} //end if
|
||||||
} //end for
|
} //end for
|
||||||
return splits;
|
return splits;
|
||||||
} //end of the function AAS_MeltFaceWinding
|
} //end of the function AAS_MeltFaceWinding
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
// melt the windings of the area faces
|
// melt the windings of the area faces
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_MeltFaceWindingsOfArea(tmp_area_t *tmparea)
|
int AAS_MeltFaceWindingsOfArea(tmp_area_t *tmparea)
|
||||||
{
|
{
|
||||||
int side1, side2, num_windingsplits = 0;
|
int side1, side2, num_windingsplits = 0;
|
||||||
tmp_face_t *face1, *face2;
|
tmp_face_t *face1, *face2;
|
||||||
|
|
||||||
for (face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1])
|
for (face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1])
|
||||||
{
|
{
|
||||||
side1 = face1->frontarea != tmparea;
|
side1 = face1->frontarea != tmparea;
|
||||||
for (face2 = tmparea->tmpfaces; face2; face2 = face2->next[side2])
|
for (face2 = tmparea->tmpfaces; face2; face2 = face2->next[side2])
|
||||||
{
|
{
|
||||||
side2 = face2->frontarea != tmparea;
|
side2 = face2->frontarea != tmparea;
|
||||||
if (face1 == face2) continue;
|
if (face1 == face2) continue;
|
||||||
num_windingsplits += AAS_MeltFaceWinding(face1, face2);
|
num_windingsplits += AAS_MeltFaceWinding(face1, face2);
|
||||||
} //end for
|
} //end for
|
||||||
} //end for
|
} //end for
|
||||||
return num_windingsplits;
|
return num_windingsplits;
|
||||||
} //end of the function AAS_MeltFaceWindingsOfArea
|
} //end of the function AAS_MeltFaceWindingsOfArea
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
// melt the windings of the faces of all areas
|
// melt the windings of the faces of all areas
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_MeltAreaFaceWindings(void)
|
void AAS_MeltAreaFaceWindings(void)
|
||||||
{
|
{
|
||||||
tmp_area_t *tmparea;
|
tmp_area_t *tmparea;
|
||||||
int num_windingsplits = 0;
|
int num_windingsplits = 0;
|
||||||
|
|
||||||
Log_Write("AAS_MeltAreaFaceWindings\r\n");
|
Log_Write("AAS_MeltAreaFaceWindings\r\n");
|
||||||
qprintf("%6d edges melted", num_windingsplits);
|
qprintf("%6d edges melted", num_windingsplits);
|
||||||
//NOTE: first convex area (zero) is a dummy
|
//NOTE: first convex area (zero) is a dummy
|
||||||
for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next)
|
for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next)
|
||||||
{
|
{
|
||||||
num_windingsplits += AAS_MeltFaceWindingsOfArea(tmparea);
|
num_windingsplits += AAS_MeltFaceWindingsOfArea(tmparea);
|
||||||
qprintf("\r%6d", num_windingsplits);
|
qprintf("\r%6d", num_windingsplits);
|
||||||
} //end for
|
} //end for
|
||||||
qprintf("\n");
|
qprintf("\n");
|
||||||
Log_Write("%6d edges melted\r\n", num_windingsplits);
|
Log_Write("%6d edges melted\r\n", num_windingsplits);
|
||||||
} //end of the function AAS_MeltAreaFaceWindings
|
} //end of the function AAS_MeltAreaFaceWindings
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,24 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void AAS_MeltAreaFaceWindings(void);
|
void AAS_MeltAreaFaceWindings(void);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,282 +1,282 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "qbsp.h"
|
#include "qbsp.h"
|
||||||
#include "../botlib/aasfile.h"
|
#include "../botlib/aasfile.h"
|
||||||
#include "aas_create.h"
|
#include "aas_create.h"
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_TryMergeFaces(tmp_face_t *face1, tmp_face_t *face2)
|
int AAS_TryMergeFaces(tmp_face_t *face1, tmp_face_t *face2)
|
||||||
{
|
{
|
||||||
winding_t *neww;
|
winding_t *neww;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (!face1->winding) Error("face1 %d without winding", face1->num);
|
if (!face1->winding) Error("face1 %d without winding", face1->num);
|
||||||
if (!face2->winding) Error("face2 %d without winding", face2->num);
|
if (!face2->winding) Error("face2 %d without winding", face2->num);
|
||||||
#endif //DEBUG
|
#endif //DEBUG
|
||||||
//
|
//
|
||||||
if (face1->faceflags != face2->faceflags) return false;
|
if (face1->faceflags != face2->faceflags) return false;
|
||||||
//NOTE: if the front or back area is zero this doesn't mean there's
|
//NOTE: if the front or back area is zero this doesn't mean there's
|
||||||
//a real area. It means there's solid at that side of the face
|
//a real area. It means there's solid at that side of the face
|
||||||
//if both faces have the same front area
|
//if both faces have the same front area
|
||||||
if (face1->frontarea == face2->frontarea)
|
if (face1->frontarea == face2->frontarea)
|
||||||
{
|
{
|
||||||
//if both faces have the same back area
|
//if both faces have the same back area
|
||||||
if (face1->backarea == face2->backarea)
|
if (face1->backarea == face2->backarea)
|
||||||
{
|
{
|
||||||
//if the faces are in the same plane
|
//if the faces are in the same plane
|
||||||
if (face1->planenum == face2->planenum)
|
if (face1->planenum == face2->planenum)
|
||||||
{
|
{
|
||||||
//if they have both a front and a back area (no solid on either side)
|
//if they have both a front and a back area (no solid on either side)
|
||||||
if (face1->frontarea && face1->backarea)
|
if (face1->frontarea && face1->backarea)
|
||||||
{
|
{
|
||||||
neww = MergeWindings(face1->winding, face2->winding,
|
neww = MergeWindings(face1->winding, face2->winding,
|
||||||
mapplanes[face1->planenum].normal);
|
mapplanes[face1->planenum].normal);
|
||||||
} //end if
|
} //end if
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//this function is to be found in l_poly.c
|
//this function is to be found in l_poly.c
|
||||||
neww = TryMergeWinding(face1->winding, face2->winding,
|
neww = TryMergeWinding(face1->winding, face2->winding,
|
||||||
mapplanes[face1->planenum].normal);
|
mapplanes[face1->planenum].normal);
|
||||||
} //end else
|
} //end else
|
||||||
if (neww)
|
if (neww)
|
||||||
{
|
{
|
||||||
FreeWinding(face1->winding);
|
FreeWinding(face1->winding);
|
||||||
face1->winding = neww;
|
face1->winding = neww;
|
||||||
if (face2->frontarea) AAS_RemoveFaceFromArea(face2, face2->frontarea);
|
if (face2->frontarea) AAS_RemoveFaceFromArea(face2, face2->frontarea);
|
||||||
if (face2->backarea) AAS_RemoveFaceFromArea(face2, face2->backarea);
|
if (face2->backarea) AAS_RemoveFaceFromArea(face2, face2->backarea);
|
||||||
AAS_FreeTmpFace(face2);
|
AAS_FreeTmpFace(face2);
|
||||||
return true;
|
return true;
|
||||||
} //end if
|
} //end if
|
||||||
} //end if
|
} //end if
|
||||||
else if ((face1->planenum & ~1) == (face2->planenum & ~1))
|
else if ((face1->planenum & ~1) == (face2->planenum & ~1))
|
||||||
{
|
{
|
||||||
Log_Write("face %d and %d, same front and back area but flipped planes\r\n",
|
Log_Write("face %d and %d, same front and back area but flipped planes\r\n",
|
||||||
face1->num, face2->num);
|
face1->num, face2->num);
|
||||||
} //end if
|
} //end if
|
||||||
} //end if
|
} //end if
|
||||||
} //end if
|
} //end if
|
||||||
return false;
|
return false;
|
||||||
} //end of the function AAS_TryMergeFaces
|
} //end of the function AAS_TryMergeFaces
|
||||||
/*
|
/*
|
||||||
int AAS_TryMergeFaces(tmp_face_t *face1, tmp_face_t *face2)
|
int AAS_TryMergeFaces(tmp_face_t *face1, tmp_face_t *face2)
|
||||||
{
|
{
|
||||||
winding_t *neww;
|
winding_t *neww;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (!face1->winding) Error("face1 %d without winding", face1->num);
|
if (!face1->winding) Error("face1 %d without winding", face1->num);
|
||||||
if (!face2->winding) Error("face2 %d without winding", face2->num);
|
if (!face2->winding) Error("face2 %d without winding", face2->num);
|
||||||
#endif //DEBUG
|
#endif //DEBUG
|
||||||
//if the faces are in the same plane
|
//if the faces are in the same plane
|
||||||
if ((face1->planenum & ~1) != (face2->planenum & ~1)) return false;
|
if ((face1->planenum & ~1) != (face2->planenum & ~1)) return false;
|
||||||
// if (face1->planenum != face2->planenum) return false;
|
// if (face1->planenum != face2->planenum) return false;
|
||||||
//NOTE: if the front or back area is zero this doesn't mean there's
|
//NOTE: if the front or back area is zero this doesn't mean there's
|
||||||
//a real area. It means there's solid at that side of the face
|
//a real area. It means there's solid at that side of the face
|
||||||
//if both faces have the same front area
|
//if both faces have the same front area
|
||||||
if (face1->frontarea != face2->frontarea ||
|
if (face1->frontarea != face2->frontarea ||
|
||||||
face1->backarea != face2->backarea)
|
face1->backarea != face2->backarea)
|
||||||
{
|
{
|
||||||
if (!face1->frontarea || !face1->backarea ||
|
if (!face1->frontarea || !face1->backarea ||
|
||||||
!face2->frontarea || !face2->backarea) return false;
|
!face2->frontarea || !face2->backarea) return false;
|
||||||
else if (face1->frontarea != face2->backarea ||
|
else if (face1->frontarea != face2->backarea ||
|
||||||
face1->backarea != face2->frontarea) return false;
|
face1->backarea != face2->frontarea) return false;
|
||||||
// return false;
|
// return false;
|
||||||
} //end if
|
} //end if
|
||||||
//this function is to be found in l_poly.c
|
//this function is to be found in l_poly.c
|
||||||
neww = TryMergeWinding(face1->winding, face2->winding,
|
neww = TryMergeWinding(face1->winding, face2->winding,
|
||||||
mapplanes[face1->planenum].normal);
|
mapplanes[face1->planenum].normal);
|
||||||
if (!neww) return false;
|
if (!neww) return false;
|
||||||
//
|
//
|
||||||
FreeWinding(face1->winding);
|
FreeWinding(face1->winding);
|
||||||
face1->winding = neww;
|
face1->winding = neww;
|
||||||
//remove face2
|
//remove face2
|
||||||
if (face2->frontarea)
|
if (face2->frontarea)
|
||||||
AAS_RemoveFaceFromArea(face2, &tmpaasworld.areas[face2->frontarea]);
|
AAS_RemoveFaceFromArea(face2, &tmpaasworld.areas[face2->frontarea]);
|
||||||
if (face2->backarea)
|
if (face2->backarea)
|
||||||
AAS_RemoveFaceFromArea(face2, &tmpaasworld.areas[face2->backarea]);
|
AAS_RemoveFaceFromArea(face2, &tmpaasworld.areas[face2->backarea]);
|
||||||
return true;
|
return true;
|
||||||
} //end of the function AAS_TryMergeFaces*/
|
} //end of the function AAS_TryMergeFaces*/
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_MergeAreaFaces(void)
|
void AAS_MergeAreaFaces(void)
|
||||||
{
|
{
|
||||||
int num_facemerges = 0;
|
int num_facemerges = 0;
|
||||||
int side1, side2, restart;
|
int side1, side2, restart;
|
||||||
tmp_area_t *tmparea, *lasttmparea;
|
tmp_area_t *tmparea, *lasttmparea;
|
||||||
tmp_face_t *face1, *face2;
|
tmp_face_t *face1, *face2;
|
||||||
|
|
||||||
Log_Write("AAS_MergeAreaFaces\r\n");
|
Log_Write("AAS_MergeAreaFaces\r\n");
|
||||||
qprintf("%6d face merges", num_facemerges);
|
qprintf("%6d face merges", num_facemerges);
|
||||||
//NOTE: first convex area is a dummy
|
//NOTE: first convex area is a dummy
|
||||||
lasttmparea = tmpaasworld.areas;
|
lasttmparea = tmpaasworld.areas;
|
||||||
for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next)
|
for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next)
|
||||||
{
|
{
|
||||||
restart = false;
|
restart = false;
|
||||||
//
|
//
|
||||||
if (tmparea->invalid) continue;
|
if (tmparea->invalid) continue;
|
||||||
//
|
//
|
||||||
for (face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1])
|
for (face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1])
|
||||||
{
|
{
|
||||||
side1 = face1->frontarea != tmparea;
|
side1 = face1->frontarea != tmparea;
|
||||||
for (face2 = face1->next[side1]; face2; face2 = face2->next[side2])
|
for (face2 = face1->next[side1]; face2; face2 = face2->next[side2])
|
||||||
{
|
{
|
||||||
side2 = face2->frontarea != tmparea;
|
side2 = face2->frontarea != tmparea;
|
||||||
//if succesfully merged
|
//if succesfully merged
|
||||||
if (AAS_TryMergeFaces(face1, face2))
|
if (AAS_TryMergeFaces(face1, face2))
|
||||||
{
|
{
|
||||||
//start over again after merging two faces
|
//start over again after merging two faces
|
||||||
restart = true;
|
restart = true;
|
||||||
num_facemerges++;
|
num_facemerges++;
|
||||||
qprintf("\r%6d", num_facemerges);
|
qprintf("\r%6d", num_facemerges);
|
||||||
AAS_CheckArea(tmparea);
|
AAS_CheckArea(tmparea);
|
||||||
break;
|
break;
|
||||||
} //end if
|
} //end if
|
||||||
} //end for
|
} //end for
|
||||||
if (restart)
|
if (restart)
|
||||||
{
|
{
|
||||||
tmparea = lasttmparea;
|
tmparea = lasttmparea;
|
||||||
break;
|
break;
|
||||||
} //end if
|
} //end if
|
||||||
} //end for
|
} //end for
|
||||||
lasttmparea = tmparea;
|
lasttmparea = tmparea;
|
||||||
} //end for
|
} //end for
|
||||||
qprintf("\n");
|
qprintf("\n");
|
||||||
Log_Write("%6d face merges\r\n", num_facemerges);
|
Log_Write("%6d face merges\r\n", num_facemerges);
|
||||||
} //end of the function AAS_MergeAreaFaces
|
} //end of the function AAS_MergeAreaFaces
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_MergePlaneFaces(tmp_area_t *tmparea, int planenum)
|
void AAS_MergePlaneFaces(tmp_area_t *tmparea, int planenum)
|
||||||
{
|
{
|
||||||
tmp_face_t *face1, *face2, *nextface2;
|
tmp_face_t *face1, *face2, *nextface2;
|
||||||
winding_t *neww;
|
winding_t *neww;
|
||||||
int side1, side2;
|
int side1, side2;
|
||||||
|
|
||||||
for (face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1])
|
for (face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1])
|
||||||
{
|
{
|
||||||
side1 = face1->frontarea != tmparea;
|
side1 = face1->frontarea != tmparea;
|
||||||
if (face1->planenum != planenum) continue;
|
if (face1->planenum != planenum) continue;
|
||||||
//
|
//
|
||||||
for (face2 = face1->next[side1]; face2; face2 = nextface2)
|
for (face2 = face1->next[side1]; face2; face2 = nextface2)
|
||||||
{
|
{
|
||||||
side2 = face2->frontarea != tmparea;
|
side2 = face2->frontarea != tmparea;
|
||||||
nextface2 = face2->next[side2];
|
nextface2 = face2->next[side2];
|
||||||
//
|
//
|
||||||
if ((face2->planenum & ~1) != (planenum & ~1)) continue;
|
if ((face2->planenum & ~1) != (planenum & ~1)) continue;
|
||||||
//
|
//
|
||||||
neww = MergeWindings(face1->winding, face2->winding,
|
neww = MergeWindings(face1->winding, face2->winding,
|
||||||
mapplanes[face1->planenum].normal);
|
mapplanes[face1->planenum].normal);
|
||||||
FreeWinding(face1->winding);
|
FreeWinding(face1->winding);
|
||||||
face1->winding = neww;
|
face1->winding = neww;
|
||||||
if (face2->frontarea) AAS_RemoveFaceFromArea(face2, face2->frontarea);
|
if (face2->frontarea) AAS_RemoveFaceFromArea(face2, face2->frontarea);
|
||||||
if (face2->backarea) AAS_RemoveFaceFromArea(face2, face2->backarea);
|
if (face2->backarea) AAS_RemoveFaceFromArea(face2, face2->backarea);
|
||||||
AAS_FreeTmpFace(face2);
|
AAS_FreeTmpFace(face2);
|
||||||
//
|
//
|
||||||
nextface2 = face1->next[side1];
|
nextface2 = face1->next[side1];
|
||||||
} //end for
|
} //end for
|
||||||
} //end for
|
} //end for
|
||||||
} //end of the function AAS_MergePlaneFaces
|
} //end of the function AAS_MergePlaneFaces
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int AAS_CanMergePlaneFaces(tmp_area_t *tmparea, int planenum)
|
int AAS_CanMergePlaneFaces(tmp_area_t *tmparea, int planenum)
|
||||||
{
|
{
|
||||||
tmp_area_t *frontarea, *backarea;
|
tmp_area_t *frontarea, *backarea;
|
||||||
tmp_face_t *face1;
|
tmp_face_t *face1;
|
||||||
int side1, merge, faceflags;
|
int side1, merge, faceflags;
|
||||||
|
|
||||||
frontarea = backarea = NULL;
|
frontarea = backarea = NULL;
|
||||||
merge = false;
|
merge = false;
|
||||||
for (face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1])
|
for (face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1])
|
||||||
{
|
{
|
||||||
side1 = face1->frontarea != tmparea;
|
side1 = face1->frontarea != tmparea;
|
||||||
if ((face1->planenum & ~1) != (planenum & ~1)) continue;
|
if ((face1->planenum & ~1) != (planenum & ~1)) continue;
|
||||||
if (!frontarea && !backarea)
|
if (!frontarea && !backarea)
|
||||||
{
|
{
|
||||||
frontarea = face1->frontarea;
|
frontarea = face1->frontarea;
|
||||||
backarea = face1->backarea;
|
backarea = face1->backarea;
|
||||||
faceflags = face1->faceflags;
|
faceflags = face1->faceflags;
|
||||||
} //end if
|
} //end if
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (frontarea != face1->frontarea) return false;
|
if (frontarea != face1->frontarea) return false;
|
||||||
if (backarea != face1->backarea) return false;
|
if (backarea != face1->backarea) return false;
|
||||||
if (faceflags != face1->faceflags) return false;
|
if (faceflags != face1->faceflags) return false;
|
||||||
merge = true;
|
merge = true;
|
||||||
} //end else
|
} //end else
|
||||||
} //end for
|
} //end for
|
||||||
return merge;
|
return merge;
|
||||||
} //end of the function AAS_CanMergePlaneFaces
|
} //end of the function AAS_CanMergePlaneFaces
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_MergeAreaPlaneFaces(void)
|
void AAS_MergeAreaPlaneFaces(void)
|
||||||
{
|
{
|
||||||
int num_facemerges = 0;
|
int num_facemerges = 0;
|
||||||
int side1;
|
int side1;
|
||||||
tmp_area_t *tmparea, *nexttmparea;
|
tmp_area_t *tmparea, *nexttmparea;
|
||||||
tmp_face_t *face1;
|
tmp_face_t *face1;
|
||||||
|
|
||||||
Log_Write("AAS_MergePlaneFaces\r\n");
|
Log_Write("AAS_MergePlaneFaces\r\n");
|
||||||
qprintf("%6d plane face merges", num_facemerges);
|
qprintf("%6d plane face merges", num_facemerges);
|
||||||
//NOTE: first convex area is a dummy
|
//NOTE: first convex area is a dummy
|
||||||
for (tmparea = tmpaasworld.areas; tmparea; tmparea = nexttmparea)
|
for (tmparea = tmpaasworld.areas; tmparea; tmparea = nexttmparea)
|
||||||
{
|
{
|
||||||
nexttmparea = tmparea->l_next;
|
nexttmparea = tmparea->l_next;
|
||||||
//
|
//
|
||||||
if (tmparea->invalid) continue;
|
if (tmparea->invalid) continue;
|
||||||
//
|
//
|
||||||
for (face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1])
|
for (face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1])
|
||||||
{
|
{
|
||||||
side1 = face1->frontarea != tmparea;
|
side1 = face1->frontarea != tmparea;
|
||||||
//
|
//
|
||||||
if (AAS_CanMergePlaneFaces(tmparea, face1->planenum))
|
if (AAS_CanMergePlaneFaces(tmparea, face1->planenum))
|
||||||
{
|
{
|
||||||
AAS_MergePlaneFaces(tmparea, face1->planenum);
|
AAS_MergePlaneFaces(tmparea, face1->planenum);
|
||||||
nexttmparea = tmparea;
|
nexttmparea = tmparea;
|
||||||
num_facemerges++;
|
num_facemerges++;
|
||||||
qprintf("\r%6d", num_facemerges);
|
qprintf("\r%6d", num_facemerges);
|
||||||
break;
|
break;
|
||||||
} //end if
|
} //end if
|
||||||
} //end for
|
} //end for
|
||||||
} //end for
|
} //end for
|
||||||
qprintf("\n");
|
qprintf("\n");
|
||||||
Log_Write("%6d plane face merges\r\n", num_facemerges);
|
Log_Write("%6d plane face merges\r\n", num_facemerges);
|
||||||
} //end of the function AAS_MergeAreaPlaneFaces
|
} //end of the function AAS_MergeAreaPlaneFaces
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,24 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void AAS_MergeAreaFaces(void);
|
void AAS_MergeAreaFaces(void);
|
||||||
void AAS_MergeAreaPlaneFaces(void);
|
void AAS_MergeAreaPlaneFaces(void);
|
||||||
|
|
|
||||||
1098
code/bspc/aas_file.c
1098
code/bspc/aas_file.c
File diff suppressed because it is too large
Load diff
|
|
@ -1,25 +1,25 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
qboolean AAS_WriteAASFile(char *filename);
|
qboolean AAS_WriteAASFile(char *filename);
|
||||||
qboolean AAS_LoadAASFile(char *filename, int fpoffset, int fplength);
|
qboolean AAS_LoadAASFile(char *filename, int fpoffset, int fplength);
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,25 +1,25 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//works with the global tmpaasworld
|
//works with the global tmpaasworld
|
||||||
void AAS_GravitationalSubdivision(void);
|
void AAS_GravitationalSubdivision(void);
|
||||||
void AAS_LadderSubdivision(void);
|
void AAS_LadderSubdivision(void);
|
||||||
|
|
|
||||||
1698
code/bspc/aas_map.c
1698
code/bspc/aas_map.c
File diff suppressed because it is too large
Load diff
|
|
@ -1,23 +1,23 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void AAS_CreateMapBrushes(mapbrush_t *brush, entity_t *mapent, int addbevels);
|
void AAS_CreateMapBrushes(mapbrush_t *brush, entity_t *mapent, int addbevels);
|
||||||
|
|
|
||||||
|
|
@ -1,89 +1,89 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "qbsp.h"
|
#include "qbsp.h"
|
||||||
#include "../botlib/aasfile.h"
|
#include "../botlib/aasfile.h"
|
||||||
#include "aas_create.h"
|
#include "aas_create.h"
|
||||||
|
|
||||||
int c_numprunes;
|
int c_numprunes;
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
tmp_node_t *AAS_PruneNodes_r(tmp_node_t *tmpnode)
|
tmp_node_t *AAS_PruneNodes_r(tmp_node_t *tmpnode)
|
||||||
{
|
{
|
||||||
tmp_area_t *tmparea1, *tmparea2;
|
tmp_area_t *tmparea1, *tmparea2;
|
||||||
|
|
||||||
//if it is a solid leaf
|
//if it is a solid leaf
|
||||||
if (!tmpnode) return NULL;
|
if (!tmpnode) return NULL;
|
||||||
//
|
//
|
||||||
if (tmpnode->tmparea) return tmpnode;
|
if (tmpnode->tmparea) return tmpnode;
|
||||||
//process the children first
|
//process the children first
|
||||||
tmpnode->children[0] = AAS_PruneNodes_r(tmpnode->children[0]);
|
tmpnode->children[0] = AAS_PruneNodes_r(tmpnode->children[0]);
|
||||||
tmpnode->children[1] = AAS_PruneNodes_r(tmpnode->children[1]);
|
tmpnode->children[1] = AAS_PruneNodes_r(tmpnode->children[1]);
|
||||||
//if both children are areas
|
//if both children are areas
|
||||||
if (tmpnode->children[0] && tmpnode->children[1] &&
|
if (tmpnode->children[0] && tmpnode->children[1] &&
|
||||||
tmpnode->children[0]->tmparea && tmpnode->children[1]->tmparea)
|
tmpnode->children[0]->tmparea && tmpnode->children[1]->tmparea)
|
||||||
{
|
{
|
||||||
tmparea1 = tmpnode->children[0]->tmparea;
|
tmparea1 = tmpnode->children[0]->tmparea;
|
||||||
while(tmparea1->mergedarea) tmparea1 = tmparea1->mergedarea;
|
while(tmparea1->mergedarea) tmparea1 = tmparea1->mergedarea;
|
||||||
|
|
||||||
tmparea2 = tmpnode->children[1]->tmparea;
|
tmparea2 = tmpnode->children[1]->tmparea;
|
||||||
while(tmparea2->mergedarea) tmparea2 = tmparea2->mergedarea;
|
while(tmparea2->mergedarea) tmparea2 = tmparea2->mergedarea;
|
||||||
|
|
||||||
if (tmparea1 == tmparea2)
|
if (tmparea1 == tmparea2)
|
||||||
{
|
{
|
||||||
c_numprunes++;
|
c_numprunes++;
|
||||||
tmpnode->tmparea = tmparea1;
|
tmpnode->tmparea = tmparea1;
|
||||||
tmpnode->planenum = 0;
|
tmpnode->planenum = 0;
|
||||||
AAS_FreeTmpNode(tmpnode->children[0]);
|
AAS_FreeTmpNode(tmpnode->children[0]);
|
||||||
AAS_FreeTmpNode(tmpnode->children[1]);
|
AAS_FreeTmpNode(tmpnode->children[1]);
|
||||||
tmpnode->children[0] = NULL;
|
tmpnode->children[0] = NULL;
|
||||||
tmpnode->children[1] = NULL;
|
tmpnode->children[1] = NULL;
|
||||||
return tmpnode;
|
return tmpnode;
|
||||||
} //end if
|
} //end if
|
||||||
} //end if
|
} //end if
|
||||||
//if both solid leafs
|
//if both solid leafs
|
||||||
if (!tmpnode->children[0] && !tmpnode->children[1])
|
if (!tmpnode->children[0] && !tmpnode->children[1])
|
||||||
{
|
{
|
||||||
c_numprunes++;
|
c_numprunes++;
|
||||||
AAS_FreeTmpNode(tmpnode);
|
AAS_FreeTmpNode(tmpnode);
|
||||||
return NULL;
|
return NULL;
|
||||||
} //end if
|
} //end if
|
||||||
//
|
//
|
||||||
return tmpnode;
|
return tmpnode;
|
||||||
} //end of the function AAS_PruneNodes_r
|
} //end of the function AAS_PruneNodes_r
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_PruneNodes(void)
|
void AAS_PruneNodes(void)
|
||||||
{
|
{
|
||||||
Log_Write("AAS_PruneNodes\r\n");
|
Log_Write("AAS_PruneNodes\r\n");
|
||||||
AAS_PruneNodes_r(tmpaasworld.nodes);
|
AAS_PruneNodes_r(tmpaasworld.nodes);
|
||||||
Log_Print("%6d nodes pruned\r\n", c_numprunes);
|
Log_Print("%6d nodes pruned\r\n", c_numprunes);
|
||||||
} //end of the function AAS_PruneNodes
|
} //end of the function AAS_PruneNodes
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,24 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void AAS_PruneNodes(void);
|
void AAS_PruneNodes(void);
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,107 +1,107 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define AAS_MAX_BBOXES 5
|
#define AAS_MAX_BBOXES 5
|
||||||
#define AAS_MAX_VERTEXES 512000
|
#define AAS_MAX_VERTEXES 512000
|
||||||
#define AAS_MAX_PLANES 65536
|
#define AAS_MAX_PLANES 65536
|
||||||
#define AAS_MAX_EDGES 512000
|
#define AAS_MAX_EDGES 512000
|
||||||
#define AAS_MAX_EDGEINDEXSIZE 512000
|
#define AAS_MAX_EDGEINDEXSIZE 512000
|
||||||
#define AAS_MAX_FACES 512000
|
#define AAS_MAX_FACES 512000
|
||||||
#define AAS_MAX_FACEINDEXSIZE 512000
|
#define AAS_MAX_FACEINDEXSIZE 512000
|
||||||
#define AAS_MAX_AREAS 65536
|
#define AAS_MAX_AREAS 65536
|
||||||
#define AAS_MAX_AREASETTINGS 65536
|
#define AAS_MAX_AREASETTINGS 65536
|
||||||
#define AAS_MAX_REACHABILITYSIZE 65536
|
#define AAS_MAX_REACHABILITYSIZE 65536
|
||||||
#define AAS_MAX_NODES 256000
|
#define AAS_MAX_NODES 256000
|
||||||
#define AAS_MAX_PORTALS 65536
|
#define AAS_MAX_PORTALS 65536
|
||||||
#define AAS_MAX_PORTALINDEXSIZE 65536
|
#define AAS_MAX_PORTALINDEXSIZE 65536
|
||||||
#define AAS_MAX_CLUSTERS 65536
|
#define AAS_MAX_CLUSTERS 65536
|
||||||
|
|
||||||
#define BSPCINCLUDE
|
#define BSPCINCLUDE
|
||||||
#include "../game/be_aas.h"
|
#include "../game/be_aas.h"
|
||||||
#include "../botlib/be_aas_def.h"
|
#include "../botlib/be_aas_def.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
typedef struct bspc_aas_s
|
typedef struct bspc_aas_s
|
||||||
{
|
{
|
||||||
int loaded;
|
int loaded;
|
||||||
int initialized; //true when AAS has been initialized
|
int initialized; //true when AAS has been initialized
|
||||||
int savefile; //set true when file should be saved
|
int savefile; //set true when file should be saved
|
||||||
//bounding boxes
|
//bounding boxes
|
||||||
int numbboxes;
|
int numbboxes;
|
||||||
aas_bbox_t *bboxes;
|
aas_bbox_t *bboxes;
|
||||||
//vertexes
|
//vertexes
|
||||||
int numvertexes;
|
int numvertexes;
|
||||||
aas_vertex_t *vertexes;
|
aas_vertex_t *vertexes;
|
||||||
//planes
|
//planes
|
||||||
int numplanes;
|
int numplanes;
|
||||||
aas_plane_t *planes;
|
aas_plane_t *planes;
|
||||||
//edges
|
//edges
|
||||||
int numedges;
|
int numedges;
|
||||||
aas_edge_t *edges;
|
aas_edge_t *edges;
|
||||||
//edge index
|
//edge index
|
||||||
int edgeindexsize;
|
int edgeindexsize;
|
||||||
aas_edgeindex_t *edgeindex;
|
aas_edgeindex_t *edgeindex;
|
||||||
//faces
|
//faces
|
||||||
int numfaces;
|
int numfaces;
|
||||||
aas_face_t *faces;
|
aas_face_t *faces;
|
||||||
//face index
|
//face index
|
||||||
int faceindexsize;
|
int faceindexsize;
|
||||||
aas_faceindex_t *faceindex;
|
aas_faceindex_t *faceindex;
|
||||||
//convex areas
|
//convex areas
|
||||||
int numareas;
|
int numareas;
|
||||||
aas_area_t *areas;
|
aas_area_t *areas;
|
||||||
//convex area settings
|
//convex area settings
|
||||||
int numareasettings;
|
int numareasettings;
|
||||||
aas_areasettings_t *areasettings;
|
aas_areasettings_t *areasettings;
|
||||||
//reachablity list
|
//reachablity list
|
||||||
int reachabilitysize;
|
int reachabilitysize;
|
||||||
aas_reachability_t *reachability;
|
aas_reachability_t *reachability;
|
||||||
//nodes of the bsp tree
|
//nodes of the bsp tree
|
||||||
int numnodes;
|
int numnodes;
|
||||||
aas_node_t *nodes;
|
aas_node_t *nodes;
|
||||||
//cluster portals
|
//cluster portals
|
||||||
int numportals;
|
int numportals;
|
||||||
aas_portal_t *portals;
|
aas_portal_t *portals;
|
||||||
//cluster portal index
|
//cluster portal index
|
||||||
int portalindexsize;
|
int portalindexsize;
|
||||||
aas_portalindex_t *portalindex;
|
aas_portalindex_t *portalindex;
|
||||||
//clusters
|
//clusters
|
||||||
int numclusters;
|
int numclusters;
|
||||||
aas_cluster_t *clusters;
|
aas_cluster_t *clusters;
|
||||||
//
|
//
|
||||||
int numreachabilityareas;
|
int numreachabilityareas;
|
||||||
float reachabilitytime;
|
float reachabilitytime;
|
||||||
} bspc_aas_t;
|
} bspc_aas_t;
|
||||||
|
|
||||||
extern bspc_aas_t aasworld;
|
extern bspc_aas_t aasworld;
|
||||||
//*/
|
//*/
|
||||||
|
|
||||||
extern aas_t aasworld;
|
extern aas_t aasworld;
|
||||||
|
|
||||||
//stores the AAS file from the temporary AAS
|
//stores the AAS file from the temporary AAS
|
||||||
void AAS_StoreFile(char *filename);
|
void AAS_StoreFile(char *filename);
|
||||||
//returns a number of the given plane
|
//returns a number of the given plane
|
||||||
qboolean AAS_FindPlane(vec3_t normal, float dist, int *planenum);
|
qboolean AAS_FindPlane(vec3_t normal, float dist, int *planenum);
|
||||||
//allocates the maximum AAS memory for storage
|
//allocates the maximum AAS memory for storage
|
||||||
void AAS_AllocMaxAAS(void);
|
void AAS_AllocMaxAAS(void);
|
||||||
//frees the maximum AAS memory for storage
|
//frees the maximum AAS memory for storage
|
||||||
void AAS_FreeMaxAAS(void);
|
void AAS_FreeMaxAAS(void);
|
||||||
|
|
|
||||||
|
|
@ -1,252 +1,252 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
//NOTE: int = default signed
|
//NOTE: int = default signed
|
||||||
// default long
|
// default long
|
||||||
|
|
||||||
#define AASID (('S'<<24)+('A'<<16)+('A'<<8)+'E')
|
#define AASID (('S'<<24)+('A'<<16)+('A'<<8)+'E')
|
||||||
#define AASVERSION_OLD 4
|
#define AASVERSION_OLD 4
|
||||||
#define AASVERSION 5
|
#define AASVERSION 5
|
||||||
|
|
||||||
//presence types
|
//presence types
|
||||||
#define PRESENCE_NONE 1
|
#define PRESENCE_NONE 1
|
||||||
#define PRESENCE_NORMAL 2
|
#define PRESENCE_NORMAL 2
|
||||||
#define PRESENCE_CROUCH 4
|
#define PRESENCE_CROUCH 4
|
||||||
|
|
||||||
//travel types
|
//travel types
|
||||||
#define MAX_TRAVELTYPES 32
|
#define MAX_TRAVELTYPES 32
|
||||||
#define TRAVEL_INVALID 1 //temporary not possible
|
#define TRAVEL_INVALID 1 //temporary not possible
|
||||||
#define TRAVEL_WALK 2 //walking
|
#define TRAVEL_WALK 2 //walking
|
||||||
#define TRAVEL_CROUCH 3 //crouching
|
#define TRAVEL_CROUCH 3 //crouching
|
||||||
#define TRAVEL_BARRIERJUMP 4 //jumping onto a barrier
|
#define TRAVEL_BARRIERJUMP 4 //jumping onto a barrier
|
||||||
#define TRAVEL_JUMP 5 //jumping
|
#define TRAVEL_JUMP 5 //jumping
|
||||||
#define TRAVEL_LADDER 6 //climbing a ladder
|
#define TRAVEL_LADDER 6 //climbing a ladder
|
||||||
#define TRAVEL_WALKOFFLEDGE 7 //walking of a ledge
|
#define TRAVEL_WALKOFFLEDGE 7 //walking of a ledge
|
||||||
#define TRAVEL_SWIM 8 //swimming
|
#define TRAVEL_SWIM 8 //swimming
|
||||||
#define TRAVEL_WATERJUMP 9 //jump out of the water
|
#define TRAVEL_WATERJUMP 9 //jump out of the water
|
||||||
#define TRAVEL_TELEPORT 10 //teleportation
|
#define TRAVEL_TELEPORT 10 //teleportation
|
||||||
#define TRAVEL_ELEVATOR 11 //travel by elevator
|
#define TRAVEL_ELEVATOR 11 //travel by elevator
|
||||||
#define TRAVEL_ROCKETJUMP 12 //rocket jumping required for travel
|
#define TRAVEL_ROCKETJUMP 12 //rocket jumping required for travel
|
||||||
#define TRAVEL_BFGJUMP 13 //bfg jumping required for travel
|
#define TRAVEL_BFGJUMP 13 //bfg jumping required for travel
|
||||||
#define TRAVEL_GRAPPLEHOOK 14 //grappling hook required for travel
|
#define TRAVEL_GRAPPLEHOOK 14 //grappling hook required for travel
|
||||||
#define TRAVEL_DOUBLEJUMP 15 //double jump
|
#define TRAVEL_DOUBLEJUMP 15 //double jump
|
||||||
#define TRAVEL_RAMPJUMP 16 //ramp jump
|
#define TRAVEL_RAMPJUMP 16 //ramp jump
|
||||||
#define TRAVEL_STRAFEJUMP 17 //strafe jump
|
#define TRAVEL_STRAFEJUMP 17 //strafe jump
|
||||||
#define TRAVEL_JUMPPAD 18 //jump pad
|
#define TRAVEL_JUMPPAD 18 //jump pad
|
||||||
#define TRAVEL_FUNCBOB 19 //func bob
|
#define TRAVEL_FUNCBOB 19 //func bob
|
||||||
|
|
||||||
//face flags
|
//face flags
|
||||||
#define FACE_SOLID 1 //just solid at the other side
|
#define FACE_SOLID 1 //just solid at the other side
|
||||||
#define FACE_LADDER 2 //ladder
|
#define FACE_LADDER 2 //ladder
|
||||||
#define FACE_GROUND 4 //standing on ground when in this face
|
#define FACE_GROUND 4 //standing on ground when in this face
|
||||||
#define FACE_GAP 8 //gap in the ground
|
#define FACE_GAP 8 //gap in the ground
|
||||||
#define FACE_LIQUID 16
|
#define FACE_LIQUID 16
|
||||||
#define FACE_LIQUIDSURFACE 32
|
#define FACE_LIQUIDSURFACE 32
|
||||||
|
|
||||||
//area contents
|
//area contents
|
||||||
#define AREACONTENTS_WATER 1
|
#define AREACONTENTS_WATER 1
|
||||||
#define AREACONTENTS_LAVA 2
|
#define AREACONTENTS_LAVA 2
|
||||||
#define AREACONTENTS_SLIME 4
|
#define AREACONTENTS_SLIME 4
|
||||||
#define AREACONTENTS_CLUSTERPORTAL 8
|
#define AREACONTENTS_CLUSTERPORTAL 8
|
||||||
#define AREACONTENTS_TELEPORTAL 16
|
#define AREACONTENTS_TELEPORTAL 16
|
||||||
#define AREACONTENTS_ROUTEPORTAL 32
|
#define AREACONTENTS_ROUTEPORTAL 32
|
||||||
#define AREACONTENTS_TELEPORTER 64
|
#define AREACONTENTS_TELEPORTER 64
|
||||||
#define AREACONTENTS_JUMPPAD 128
|
#define AREACONTENTS_JUMPPAD 128
|
||||||
#define AREACONTENTS_DONOTENTER 256
|
#define AREACONTENTS_DONOTENTER 256
|
||||||
#define AREACONTENTS_VIEWPORTAL 512
|
#define AREACONTENTS_VIEWPORTAL 512
|
||||||
|
|
||||||
//area flags
|
//area flags
|
||||||
#define AREA_GROUNDED 1 //bot can stand on the ground
|
#define AREA_GROUNDED 1 //bot can stand on the ground
|
||||||
#define AREA_LADDER 2 //area contains one or more ladder faces
|
#define AREA_LADDER 2 //area contains one or more ladder faces
|
||||||
#define AREA_LIQUID 4 //area contains a liquid
|
#define AREA_LIQUID 4 //area contains a liquid
|
||||||
|
|
||||||
//aas file header lumps
|
//aas file header lumps
|
||||||
#define AAS_LUMPS 14
|
#define AAS_LUMPS 14
|
||||||
#define AASLUMP_BBOXES 0
|
#define AASLUMP_BBOXES 0
|
||||||
#define AASLUMP_VERTEXES 1
|
#define AASLUMP_VERTEXES 1
|
||||||
#define AASLUMP_PLANES 2
|
#define AASLUMP_PLANES 2
|
||||||
#define AASLUMP_EDGES 3
|
#define AASLUMP_EDGES 3
|
||||||
#define AASLUMP_EDGEINDEX 4
|
#define AASLUMP_EDGEINDEX 4
|
||||||
#define AASLUMP_FACES 5
|
#define AASLUMP_FACES 5
|
||||||
#define AASLUMP_FACEINDEX 6
|
#define AASLUMP_FACEINDEX 6
|
||||||
#define AASLUMP_AREAS 7
|
#define AASLUMP_AREAS 7
|
||||||
#define AASLUMP_AREASETTINGS 8
|
#define AASLUMP_AREASETTINGS 8
|
||||||
#define AASLUMP_REACHABILITY 9
|
#define AASLUMP_REACHABILITY 9
|
||||||
#define AASLUMP_NODES 10
|
#define AASLUMP_NODES 10
|
||||||
#define AASLUMP_PORTALS 11
|
#define AASLUMP_PORTALS 11
|
||||||
#define AASLUMP_PORTALINDEX 12
|
#define AASLUMP_PORTALINDEX 12
|
||||||
#define AASLUMP_CLUSTERS 13
|
#define AASLUMP_CLUSTERS 13
|
||||||
|
|
||||||
//========== bounding box =========
|
//========== bounding box =========
|
||||||
|
|
||||||
//bounding box
|
//bounding box
|
||||||
typedef struct aas_bbox_s
|
typedef struct aas_bbox_s
|
||||||
{
|
{
|
||||||
int presencetype;
|
int presencetype;
|
||||||
int flags;
|
int flags;
|
||||||
vec3_t mins, maxs;
|
vec3_t mins, maxs;
|
||||||
} aas_bbox_t;
|
} aas_bbox_t;
|
||||||
|
|
||||||
//============ settings ===========
|
//============ settings ===========
|
||||||
|
|
||||||
//reachability to another area
|
//reachability to another area
|
||||||
typedef struct aas_reachability_s
|
typedef struct aas_reachability_s
|
||||||
{
|
{
|
||||||
int areanum; //number of the reachable area
|
int areanum; //number of the reachable area
|
||||||
int facenum; //number of the face towards the other area
|
int facenum; //number of the face towards the other area
|
||||||
int edgenum; //number of the edge towards the other area
|
int edgenum; //number of the edge towards the other area
|
||||||
vec3_t start; //start point of inter area movement
|
vec3_t start; //start point of inter area movement
|
||||||
vec3_t end; //end point of inter area movement
|
vec3_t end; //end point of inter area movement
|
||||||
int traveltype; //type of travel required to get to the area
|
int traveltype; //type of travel required to get to the area
|
||||||
unsigned short int traveltime;//travel time of the inter area movement
|
unsigned short int traveltime;//travel time of the inter area movement
|
||||||
} aas_reachability_t;
|
} aas_reachability_t;
|
||||||
|
|
||||||
//area settings
|
//area settings
|
||||||
typedef struct aas_areasettings_s
|
typedef struct aas_areasettings_s
|
||||||
{
|
{
|
||||||
//could also add all kind of statistic fields
|
//could also add all kind of statistic fields
|
||||||
int contents; //contents of the convex area
|
int contents; //contents of the convex area
|
||||||
int areaflags; //several area flags
|
int areaflags; //several area flags
|
||||||
int presencetype; //how a bot can be present in this convex area
|
int presencetype; //how a bot can be present in this convex area
|
||||||
int cluster; //cluster the area belongs to, if negative it's a portal
|
int cluster; //cluster the area belongs to, if negative it's a portal
|
||||||
int clusterareanum; //number of the area in the cluster
|
int clusterareanum; //number of the area in the cluster
|
||||||
int numreachableareas; //number of reachable areas from this one
|
int numreachableareas; //number of reachable areas from this one
|
||||||
int firstreachablearea; //first reachable area in the reachable area index
|
int firstreachablearea; //first reachable area in the reachable area index
|
||||||
} aas_areasettings_t;
|
} aas_areasettings_t;
|
||||||
|
|
||||||
//cluster portal
|
//cluster portal
|
||||||
typedef struct aas_portal_s
|
typedef struct aas_portal_s
|
||||||
{
|
{
|
||||||
int areanum; //area that is the actual portal
|
int areanum; //area that is the actual portal
|
||||||
int frontcluster; //cluster at front of portal
|
int frontcluster; //cluster at front of portal
|
||||||
int backcluster; //cluster at back of portal
|
int backcluster; //cluster at back of portal
|
||||||
int clusterareanum[2]; //number of the area in the front and back cluster
|
int clusterareanum[2]; //number of the area in the front and back cluster
|
||||||
} aas_portal_t;
|
} aas_portal_t;
|
||||||
|
|
||||||
//cluster portal index
|
//cluster portal index
|
||||||
typedef int aas_portalindex_t;
|
typedef int aas_portalindex_t;
|
||||||
|
|
||||||
//cluster
|
//cluster
|
||||||
typedef struct aas_cluster_s
|
typedef struct aas_cluster_s
|
||||||
{
|
{
|
||||||
int numareas; //number of areas in the cluster
|
int numareas; //number of areas in the cluster
|
||||||
int numreachabilityareas; //number of areas with reachabilities
|
int numreachabilityareas; //number of areas with reachabilities
|
||||||
int numportals; //number of cluster portals
|
int numportals; //number of cluster portals
|
||||||
int firstportal; //first cluster portal in the index
|
int firstportal; //first cluster portal in the index
|
||||||
} aas_cluster_t;
|
} aas_cluster_t;
|
||||||
|
|
||||||
//============ 3d definition ============
|
//============ 3d definition ============
|
||||||
|
|
||||||
typedef vec3_t aas_vertex_t;
|
typedef vec3_t aas_vertex_t;
|
||||||
|
|
||||||
//just a plane in the third dimension
|
//just a plane in the third dimension
|
||||||
typedef struct aas_plane_s
|
typedef struct aas_plane_s
|
||||||
{
|
{
|
||||||
vec3_t normal; //normal vector of the plane
|
vec3_t normal; //normal vector of the plane
|
||||||
float dist; //distance of the plane (normal vector * distance = point in plane)
|
float dist; //distance of the plane (normal vector * distance = point in plane)
|
||||||
int type;
|
int type;
|
||||||
} aas_plane_t;
|
} aas_plane_t;
|
||||||
|
|
||||||
//edge
|
//edge
|
||||||
typedef struct aas_edge_s
|
typedef struct aas_edge_s
|
||||||
{
|
{
|
||||||
int v[2]; //numbers of the vertexes of this edge
|
int v[2]; //numbers of the vertexes of this edge
|
||||||
} aas_edge_t;
|
} aas_edge_t;
|
||||||
|
|
||||||
//edge index, negative if vertexes are reversed
|
//edge index, negative if vertexes are reversed
|
||||||
typedef int aas_edgeindex_t;
|
typedef int aas_edgeindex_t;
|
||||||
|
|
||||||
//a face bounds a convex area, often it will also seperate two convex areas
|
//a face bounds a convex area, often it will also seperate two convex areas
|
||||||
typedef struct aas_face_s
|
typedef struct aas_face_s
|
||||||
{
|
{
|
||||||
int planenum; //number of the plane this face is in
|
int planenum; //number of the plane this face is in
|
||||||
int faceflags; //face flags (no use to create face settings for just this field)
|
int faceflags; //face flags (no use to create face settings for just this field)
|
||||||
int numedges; //number of edges in the boundary of the face
|
int numedges; //number of edges in the boundary of the face
|
||||||
int firstedge; //first edge in the edge index
|
int firstedge; //first edge in the edge index
|
||||||
int frontarea; //convex area at the front of this face
|
int frontarea; //convex area at the front of this face
|
||||||
int backarea; //convex area at the back of this face
|
int backarea; //convex area at the back of this face
|
||||||
} aas_face_t;
|
} aas_face_t;
|
||||||
|
|
||||||
//face index, stores a negative index if backside of face
|
//face index, stores a negative index if backside of face
|
||||||
typedef int aas_faceindex_t;
|
typedef int aas_faceindex_t;
|
||||||
|
|
||||||
//convex area with a boundary of faces
|
//convex area with a boundary of faces
|
||||||
typedef struct aas_area_s
|
typedef struct aas_area_s
|
||||||
{
|
{
|
||||||
int areanum; //number of this area
|
int areanum; //number of this area
|
||||||
//3d definition
|
//3d definition
|
||||||
int numfaces; //number of faces used for the boundary of the convex area
|
int numfaces; //number of faces used for the boundary of the convex area
|
||||||
int firstface; //first face in the face index used for the boundary of the convex area
|
int firstface; //first face in the face index used for the boundary of the convex area
|
||||||
vec3_t mins; //mins of the convex area
|
vec3_t mins; //mins of the convex area
|
||||||
vec3_t maxs; //maxs of the convex area
|
vec3_t maxs; //maxs of the convex area
|
||||||
vec3_t center; //'center' of the convex area
|
vec3_t center; //'center' of the convex area
|
||||||
} aas_area_t;
|
} aas_area_t;
|
||||||
|
|
||||||
//nodes of the bsp tree
|
//nodes of the bsp tree
|
||||||
typedef struct aas_node_s
|
typedef struct aas_node_s
|
||||||
{
|
{
|
||||||
int planenum;
|
int planenum;
|
||||||
int children[2]; //child nodes of this node, or convex areas as leaves when negative
|
int children[2]; //child nodes of this node, or convex areas as leaves when negative
|
||||||
//when a child is zero it's a solid leaf
|
//when a child is zero it's a solid leaf
|
||||||
} aas_node_t;
|
} aas_node_t;
|
||||||
|
|
||||||
//=========== aas file ===============
|
//=========== aas file ===============
|
||||||
|
|
||||||
//header lump
|
//header lump
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int fileofs;
|
int fileofs;
|
||||||
int filelen;
|
int filelen;
|
||||||
} aas_lump_t;
|
} aas_lump_t;
|
||||||
|
|
||||||
//aas file header
|
//aas file header
|
||||||
typedef struct aas_header_s
|
typedef struct aas_header_s
|
||||||
{
|
{
|
||||||
int ident;
|
int ident;
|
||||||
int version;
|
int version;
|
||||||
int bspchecksum;
|
int bspchecksum;
|
||||||
//data entries
|
//data entries
|
||||||
aas_lump_t lumps[AAS_LUMPS];
|
aas_lump_t lumps[AAS_LUMPS];
|
||||||
} aas_header_t;
|
} aas_header_t;
|
||||||
|
|
||||||
|
|
||||||
//====== additional information ======
|
//====== additional information ======
|
||||||
/*
|
/*
|
||||||
|
|
||||||
- when a node child is a solid leaf the node child number is zero
|
- when a node child is a solid leaf the node child number is zero
|
||||||
- two adjacent areas (sharing a plane at opposite sides) share a face
|
- two adjacent areas (sharing a plane at opposite sides) share a face
|
||||||
this face is a portal between the areas
|
this face is a portal between the areas
|
||||||
- when an area uses a face from the faceindex with a positive index
|
- when an area uses a face from the faceindex with a positive index
|
||||||
then the face plane normal points into the area
|
then the face plane normal points into the area
|
||||||
- the face edges are stored counter clockwise using the edgeindex
|
- the face edges are stored counter clockwise using the edgeindex
|
||||||
- two adjacent convex areas (sharing a face) only share One face
|
- two adjacent convex areas (sharing a face) only share One face
|
||||||
this is a simple result of the areas being convex
|
this is a simple result of the areas being convex
|
||||||
- the convex areas can't have a mixture of ground and gap faces
|
- the convex areas can't have a mixture of ground and gap faces
|
||||||
other mixtures of faces in one area are allowed
|
other mixtures of faces in one area are allowed
|
||||||
- areas with the AREACONTENTS_CLUSTERPORTAL in the settings have
|
- areas with the AREACONTENTS_CLUSTERPORTAL in the settings have
|
||||||
cluster number zero
|
cluster number zero
|
||||||
- edge zero is a dummy
|
- edge zero is a dummy
|
||||||
- face zero is a dummy
|
- face zero is a dummy
|
||||||
- area zero is a dummy
|
- area zero is a dummy
|
||||||
- node zero is a dummy
|
- node zero is a dummy
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1,292 +1,292 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../game/q_shared.h"
|
#include "../game/q_shared.h"
|
||||||
#include "../bspc/l_log.h"
|
#include "../bspc/l_log.h"
|
||||||
#include "../bspc/l_qfiles.h"
|
#include "../bspc/l_qfiles.h"
|
||||||
#include "../botlib/l_memory.h"
|
#include "../botlib/l_memory.h"
|
||||||
#include "../botlib/l_script.h"
|
#include "../botlib/l_script.h"
|
||||||
#include "../botlib/l_precomp.h"
|
#include "../botlib/l_precomp.h"
|
||||||
#include "../botlib/l_struct.h"
|
#include "../botlib/l_struct.h"
|
||||||
#include "../botlib/aasfile.h"
|
#include "../botlib/aasfile.h"
|
||||||
#include "../game/botlib.h"
|
#include "../game/botlib.h"
|
||||||
#include "../game/be_aas.h"
|
#include "../game/be_aas.h"
|
||||||
#include "../botlib/be_aas_def.h"
|
#include "../botlib/be_aas_def.h"
|
||||||
#include "../qcommon/cm_public.h"
|
#include "../qcommon/cm_public.h"
|
||||||
|
|
||||||
//#define BSPC
|
//#define BSPC
|
||||||
|
|
||||||
extern botlib_import_t botimport;
|
extern botlib_import_t botimport;
|
||||||
extern qboolean capsule_collision;
|
extern qboolean capsule_collision;
|
||||||
|
|
||||||
botlib_import_t botimport;
|
botlib_import_t botimport;
|
||||||
clipHandle_t worldmodel;
|
clipHandle_t worldmodel;
|
||||||
|
|
||||||
void Error (char *error, ...);
|
void Error (char *error, ...);
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_Error(char *fmt, ...)
|
void AAS_Error(char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
char text[1024];
|
char text[1024];
|
||||||
|
|
||||||
va_start(argptr, fmt);
|
va_start(argptr, fmt);
|
||||||
vsprintf(text, fmt, argptr);
|
vsprintf(text, fmt, argptr);
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
|
|
||||||
Error(text);
|
Error(text);
|
||||||
} //end of the function AAS_Error
|
} //end of the function AAS_Error
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int Sys_MilliSeconds(void)
|
int Sys_MilliSeconds(void)
|
||||||
{
|
{
|
||||||
return clock() * 1000 / CLOCKS_PER_SEC;
|
return clock() * 1000 / CLOCKS_PER_SEC;
|
||||||
} //end of the function Sys_MilliSeconds
|
} //end of the function Sys_MilliSeconds
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_DebugLine(vec3_t start, vec3_t end, int color)
|
void AAS_DebugLine(vec3_t start, vec3_t end, int color)
|
||||||
{
|
{
|
||||||
} //end of the function AAS_DebugLine
|
} //end of the function AAS_DebugLine
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_ClearShownDebugLines(void)
|
void AAS_ClearShownDebugLines(void)
|
||||||
{
|
{
|
||||||
} //end of the function AAS_ClearShownDebugLines
|
} //end of the function AAS_ClearShownDebugLines
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
char *BotImport_BSPEntityData(void)
|
char *BotImport_BSPEntityData(void)
|
||||||
{
|
{
|
||||||
return CM_EntityString();
|
return CM_EntityString();
|
||||||
} //end of the function AAS_GetEntityData
|
} //end of the function AAS_GetEntityData
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void BotImport_Trace(bsp_trace_t *bsptrace, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int passent, int contentmask)
|
void BotImport_Trace(bsp_trace_t *bsptrace, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int passent, int contentmask)
|
||||||
{
|
{
|
||||||
trace_t result;
|
trace_t result;
|
||||||
|
|
||||||
CM_BoxTrace(&result, start, end, mins, maxs, worldmodel, contentmask, capsule_collision);
|
CM_BoxTrace(&result, start, end, mins, maxs, worldmodel, contentmask, capsule_collision);
|
||||||
|
|
||||||
bsptrace->allsolid = result.allsolid;
|
bsptrace->allsolid = result.allsolid;
|
||||||
bsptrace->contents = result.contents;
|
bsptrace->contents = result.contents;
|
||||||
VectorCopy(result.endpos, bsptrace->endpos);
|
VectorCopy(result.endpos, bsptrace->endpos);
|
||||||
bsptrace->ent = result.entityNum;
|
bsptrace->ent = result.entityNum;
|
||||||
bsptrace->fraction = result.fraction;
|
bsptrace->fraction = result.fraction;
|
||||||
bsptrace->exp_dist = 0;
|
bsptrace->exp_dist = 0;
|
||||||
bsptrace->plane.dist = result.plane.dist;
|
bsptrace->plane.dist = result.plane.dist;
|
||||||
VectorCopy(result.plane.normal, bsptrace->plane.normal);
|
VectorCopy(result.plane.normal, bsptrace->plane.normal);
|
||||||
bsptrace->plane.signbits = result.plane.signbits;
|
bsptrace->plane.signbits = result.plane.signbits;
|
||||||
bsptrace->plane.type = result.plane.type;
|
bsptrace->plane.type = result.plane.type;
|
||||||
bsptrace->sidenum = 0;
|
bsptrace->sidenum = 0;
|
||||||
bsptrace->startsolid = result.startsolid;
|
bsptrace->startsolid = result.startsolid;
|
||||||
bsptrace->surface.flags = result.surfaceFlags;
|
bsptrace->surface.flags = result.surfaceFlags;
|
||||||
} //end of the function BotImport_Trace
|
} //end of the function BotImport_Trace
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int BotImport_PointContents(vec3_t p)
|
int BotImport_PointContents(vec3_t p)
|
||||||
{
|
{
|
||||||
return CM_PointContents(p, worldmodel);
|
return CM_PointContents(p, worldmodel);
|
||||||
} //end of the function BotImport_PointContents
|
} //end of the function BotImport_PointContents
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void *BotImport_GetMemory(int size)
|
void *BotImport_GetMemory(int size)
|
||||||
{
|
{
|
||||||
return GetMemory(size);
|
return GetMemory(size);
|
||||||
} //end of the function BotImport_GetMemory
|
} //end of the function BotImport_GetMemory
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void BotImport_Print(int type, char *fmt, ...)
|
void BotImport_Print(int type, char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
|
||||||
va_start(argptr, fmt);
|
va_start(argptr, fmt);
|
||||||
vsprintf(buf, fmt, argptr);
|
vsprintf(buf, fmt, argptr);
|
||||||
printf(buf);
|
printf(buf);
|
||||||
if (buf[0] != '\r') Log_Write(buf);
|
if (buf[0] != '\r') Log_Write(buf);
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
} //end of the function BotImport_Print
|
} //end of the function BotImport_Print
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void BotImport_BSPModelMinsMaxsOrigin(int modelnum, vec3_t angles, vec3_t outmins, vec3_t outmaxs, vec3_t origin)
|
void BotImport_BSPModelMinsMaxsOrigin(int modelnum, vec3_t angles, vec3_t outmins, vec3_t outmaxs, vec3_t origin)
|
||||||
{
|
{
|
||||||
clipHandle_t h;
|
clipHandle_t h;
|
||||||
vec3_t mins, maxs;
|
vec3_t mins, maxs;
|
||||||
float max;
|
float max;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
h = CM_InlineModel(modelnum);
|
h = CM_InlineModel(modelnum);
|
||||||
CM_ModelBounds(h, mins, maxs);
|
CM_ModelBounds(h, mins, maxs);
|
||||||
//if the model is rotated
|
//if the model is rotated
|
||||||
if ((angles[0] || angles[1] || angles[2]))
|
if ((angles[0] || angles[1] || angles[2]))
|
||||||
{ // expand for rotation
|
{ // expand for rotation
|
||||||
|
|
||||||
max = RadiusFromBounds(mins, maxs);
|
max = RadiusFromBounds(mins, maxs);
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
mins[i] = (mins[i] + maxs[i]) * 0.5 - max;
|
mins[i] = (mins[i] + maxs[i]) * 0.5 - max;
|
||||||
maxs[i] = (mins[i] + maxs[i]) * 0.5 + max;
|
maxs[i] = (mins[i] + maxs[i]) * 0.5 + max;
|
||||||
} //end for
|
} //end for
|
||||||
} //end if
|
} //end if
|
||||||
if (outmins) VectorCopy(mins, outmins);
|
if (outmins) VectorCopy(mins, outmins);
|
||||||
if (outmaxs) VectorCopy(maxs, outmaxs);
|
if (outmaxs) VectorCopy(maxs, outmaxs);
|
||||||
if (origin) VectorClear(origin);
|
if (origin) VectorClear(origin);
|
||||||
} //end of the function BotImport_BSPModelMinsMaxsOrigin
|
} //end of the function BotImport_BSPModelMinsMaxsOrigin
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void Com_DPrintf(char *fmt, ...)
|
void Com_DPrintf(char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
|
||||||
va_start(argptr, fmt);
|
va_start(argptr, fmt);
|
||||||
vsprintf(buf, fmt, argptr);
|
vsprintf(buf, fmt, argptr);
|
||||||
printf(buf);
|
printf(buf);
|
||||||
if (buf[0] != '\r') Log_Write(buf);
|
if (buf[0] != '\r') Log_Write(buf);
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
} //end of the function Com_DPrintf
|
} //end of the function Com_DPrintf
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
int COM_Compress( char *data_p ) {
|
int COM_Compress( char *data_p ) {
|
||||||
return strlen(data_p);
|
return strlen(data_p);
|
||||||
}
|
}
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void Com_Memset (void* dest, const int val, const size_t count) {
|
void Com_Memset (void* dest, const int val, const size_t count) {
|
||||||
memset(dest, val, count);
|
memset(dest, val, count);
|
||||||
}
|
}
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void Com_Memcpy (void* dest, const void* src, const size_t count) {
|
void Com_Memcpy (void* dest, const void* src, const size_t count) {
|
||||||
memcpy(dest, src, count);
|
memcpy(dest, src, count);
|
||||||
}
|
}
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_InitBotImport(void)
|
void AAS_InitBotImport(void)
|
||||||
{
|
{
|
||||||
botimport.BSPEntityData = BotImport_BSPEntityData;
|
botimport.BSPEntityData = BotImport_BSPEntityData;
|
||||||
botimport.GetMemory = BotImport_GetMemory;
|
botimport.GetMemory = BotImport_GetMemory;
|
||||||
botimport.FreeMemory = FreeMemory;
|
botimport.FreeMemory = FreeMemory;
|
||||||
botimport.Trace = BotImport_Trace;
|
botimport.Trace = BotImport_Trace;
|
||||||
botimport.PointContents = BotImport_PointContents;
|
botimport.PointContents = BotImport_PointContents;
|
||||||
botimport.Print = BotImport_Print;
|
botimport.Print = BotImport_Print;
|
||||||
botimport.BSPModelMinsMaxsOrigin = BotImport_BSPModelMinsMaxsOrigin;
|
botimport.BSPModelMinsMaxsOrigin = BotImport_BSPModelMinsMaxsOrigin;
|
||||||
} //end of the function AAS_InitBotImport
|
} //end of the function AAS_InitBotImport
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
// Returns: -
|
// Returns: -
|
||||||
// Changes Globals: -
|
// Changes Globals: -
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void AAS_CalcReachAndClusters(struct quakefile_s *qf)
|
void AAS_CalcReachAndClusters(struct quakefile_s *qf)
|
||||||
{
|
{
|
||||||
float time;
|
float time;
|
||||||
|
|
||||||
Log_Print("loading collision map...\n");
|
Log_Print("loading collision map...\n");
|
||||||
//
|
//
|
||||||
if (!qf->pakfile[0]) strcpy(qf->pakfile, qf->filename);
|
if (!qf->pakfile[0]) strcpy(qf->pakfile, qf->filename);
|
||||||
//load the map
|
//load the map
|
||||||
CM_LoadMap((char *) qf, qfalse, &aasworld.bspchecksum);
|
CM_LoadMap((char *) qf, qfalse, &aasworld.bspchecksum);
|
||||||
//get a handle to the world model
|
//get a handle to the world model
|
||||||
worldmodel = CM_InlineModel(0); // 0 = world, 1 + are bmodels
|
worldmodel = CM_InlineModel(0); // 0 = world, 1 + are bmodels
|
||||||
//initialize bot import structure
|
//initialize bot import structure
|
||||||
AAS_InitBotImport();
|
AAS_InitBotImport();
|
||||||
//load the BSP entity string
|
//load the BSP entity string
|
||||||
AAS_LoadBSPFile();
|
AAS_LoadBSPFile();
|
||||||
//init physics settings
|
//init physics settings
|
||||||
AAS_InitSettings();
|
AAS_InitSettings();
|
||||||
//initialize AAS link heap
|
//initialize AAS link heap
|
||||||
AAS_InitAASLinkHeap();
|
AAS_InitAASLinkHeap();
|
||||||
//initialize the AAS linked entities for the new map
|
//initialize the AAS linked entities for the new map
|
||||||
AAS_InitAASLinkedEntities();
|
AAS_InitAASLinkedEntities();
|
||||||
//reset all reachabilities and clusters
|
//reset all reachabilities and clusters
|
||||||
aasworld.reachabilitysize = 0;
|
aasworld.reachabilitysize = 0;
|
||||||
aasworld.numclusters = 0;
|
aasworld.numclusters = 0;
|
||||||
//set all view portals as cluster portals in case we re-calculate the reachabilities and clusters (with -reach)
|
//set all view portals as cluster portals in case we re-calculate the reachabilities and clusters (with -reach)
|
||||||
AAS_SetViewPortalsAsClusterPortals();
|
AAS_SetViewPortalsAsClusterPortals();
|
||||||
//calculate reachabilities
|
//calculate reachabilities
|
||||||
AAS_InitReachability();
|
AAS_InitReachability();
|
||||||
time = 0;
|
time = 0;
|
||||||
while(AAS_ContinueInitReachability(time)) time++;
|
while(AAS_ContinueInitReachability(time)) time++;
|
||||||
//calculate clusters
|
//calculate clusters
|
||||||
AAS_InitClustering();
|
AAS_InitClustering();
|
||||||
} //end of the function AAS_CalcReachAndClusters
|
} //end of the function AAS_CalcReachAndClusters
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,23 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void AAS_CalcReachAndClusters(struct quakefile_s *qf);
|
void AAS_CalcReachAndClusters(struct quakefile_s *qf);
|
||||||
|
|
|
||||||
3742
code/bspc/brushbsp.c
3742
code/bspc/brushbsp.c
File diff suppressed because it is too large
Load diff
1982
code/bspc/bspc.c
1982
code/bspc/bspc.c
File diff suppressed because it is too large
Load diff
|
|
@ -1,28 +1,28 @@
|
||||||
Microsoft Visual Studio Solution File, Format Version 8.00
|
Microsoft Visual Studio Solution File, Format Version 8.00
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bspc", "bspc.vcproj", "{4E4EBC16-F345-4667-84E1-86633BAFDAE6}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bspc", "bspc.vcproj", "{4E4EBC16-F345-4667-84E1-86633BAFDAE6}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SourceCodeControl) = preSolution
|
GlobalSection(SourceCodeControl) = preSolution
|
||||||
SccNumberOfProjects = 1
|
SccNumberOfProjects = 1
|
||||||
SccProjectUniqueName0 = bspc.vcproj
|
SccProjectUniqueName0 = bspc.vcproj
|
||||||
SccProjectName0 = \u0022$/source/code/bspc\u0022,\u0020IGAAAAAA
|
SccProjectName0 = \u0022$/source/code/bspc\u0022,\u0020IGAAAAAA
|
||||||
SccLocalPath0 = .
|
SccLocalPath0 = .
|
||||||
SccProvider0 = MSSCCI:Perforce\u0020SCM
|
SccProvider0 = MSSCCI:Perforce\u0020SCM
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionConfiguration) = preSolution
|
GlobalSection(SolutionConfiguration) = preSolution
|
||||||
Debug = Debug
|
Debug = Debug
|
||||||
Release = Release
|
Release = Release
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfiguration) = postSolution
|
GlobalSection(ProjectConfiguration) = postSolution
|
||||||
{4E4EBC16-F345-4667-84E1-86633BAFDAE6}.Debug.ActiveCfg = Debug|Win32
|
{4E4EBC16-F345-4667-84E1-86633BAFDAE6}.Debug.ActiveCfg = Debug|Win32
|
||||||
{4E4EBC16-F345-4667-84E1-86633BAFDAE6}.Debug.Build.0 = Debug|Win32
|
{4E4EBC16-F345-4667-84E1-86633BAFDAE6}.Debug.Build.0 = Debug|Win32
|
||||||
{4E4EBC16-F345-4667-84E1-86633BAFDAE6}.Release.ActiveCfg = Release|Win32
|
{4E4EBC16-F345-4667-84E1-86633BAFDAE6}.Release.ActiveCfg = Release|Win32
|
||||||
{4E4EBC16-F345-4667-84E1-86633BAFDAE6}.Release.Build.0 = Release|Win32
|
{4E4EBC16-F345-4667-84E1-86633BAFDAE6}.Release.Build.0 = Release|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,84 +1,84 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
// BSPC configuration file
|
// BSPC configuration file
|
||||||
// Quake3
|
// Quake3
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
#define PRESENCE_NONE 1
|
#define PRESENCE_NONE 1
|
||||||
#define PRESENCE_NORMAL 2
|
#define PRESENCE_NORMAL 2
|
||||||
#define PRESENCE_CROUCH 4
|
#define PRESENCE_CROUCH 4
|
||||||
|
|
||||||
bbox //30x30x56
|
bbox //30x30x56
|
||||||
{
|
{
|
||||||
presencetype PRESENCE_NORMAL
|
presencetype PRESENCE_NORMAL
|
||||||
flags 0x0000
|
flags 0x0000
|
||||||
mins {-15, -15, -24}
|
mins {-15, -15, -24}
|
||||||
maxs {15, 15, 32}
|
maxs {15, 15, 32}
|
||||||
} //end bbox
|
} //end bbox
|
||||||
|
|
||||||
bbox //30x30x40
|
bbox //30x30x40
|
||||||
{
|
{
|
||||||
presencetype PRESENCE_CROUCH
|
presencetype PRESENCE_CROUCH
|
||||||
flags 0x0001
|
flags 0x0001
|
||||||
mins {-15, -15, -24}
|
mins {-15, -15, -24}
|
||||||
maxs {15, 15, 16}
|
maxs {15, 15, 16}
|
||||||
} //end bbox
|
} //end bbox
|
||||||
|
|
||||||
settings
|
settings
|
||||||
{
|
{
|
||||||
phys_gravitydirection {0, 0, -1}
|
phys_gravitydirection {0, 0, -1}
|
||||||
phys_friction 6
|
phys_friction 6
|
||||||
phys_stopspeed 100
|
phys_stopspeed 100
|
||||||
phys_gravity 800
|
phys_gravity 800
|
||||||
phys_waterfriction 1
|
phys_waterfriction 1
|
||||||
phys_watergravity 400
|
phys_watergravity 400
|
||||||
phys_maxvelocity 320
|
phys_maxvelocity 320
|
||||||
phys_maxwalkvelocity 320
|
phys_maxwalkvelocity 320
|
||||||
phys_maxcrouchvelocity 100
|
phys_maxcrouchvelocity 100
|
||||||
phys_maxswimvelocity 150
|
phys_maxswimvelocity 150
|
||||||
phys_maxacceleration 2200
|
phys_maxacceleration 2200
|
||||||
phys_airaccelerate 0
|
phys_airaccelerate 0
|
||||||
phys_maxstep 18
|
phys_maxstep 18
|
||||||
phys_maxsteepness 0.7
|
phys_maxsteepness 0.7
|
||||||
phys_maxwaterjump 19
|
phys_maxwaterjump 19
|
||||||
phys_maxbarrier 33
|
phys_maxbarrier 33
|
||||||
phys_jumpvel 270
|
phys_jumpvel 270
|
||||||
phys_falldelta5 40
|
phys_falldelta5 40
|
||||||
phys_falldelta10 60
|
phys_falldelta10 60
|
||||||
rs_waterjump 400
|
rs_waterjump 400
|
||||||
rs_teleport 50
|
rs_teleport 50
|
||||||
rs_barrierjump 100
|
rs_barrierjump 100
|
||||||
rs_startcrouch 300
|
rs_startcrouch 300
|
||||||
rs_startgrapple 500
|
rs_startgrapple 500
|
||||||
rs_startwalkoffledge 70
|
rs_startwalkoffledge 70
|
||||||
rs_startjump 300
|
rs_startjump 300
|
||||||
rs_rocketjump 500
|
rs_rocketjump 500
|
||||||
rs_bfgjump 500
|
rs_bfgjump 500
|
||||||
rs_jumppad 250
|
rs_jumppad 250
|
||||||
rs_aircontrolledjumppad 300
|
rs_aircontrolledjumppad 300
|
||||||
rs_funcbob 300
|
rs_funcbob 300
|
||||||
rs_startelevator 50
|
rs_startelevator 50
|
||||||
rs_falldamage5 300
|
rs_falldamage5 300
|
||||||
rs_falldamage10 500
|
rs_falldamage10 500
|
||||||
rs_maxjumpfallheight 450
|
rs_maxjumpfallheight 450
|
||||||
} //end settings
|
} //end settings
|
||||||
|
|
|
||||||
2010
code/bspc/csg.c
2010
code/bspc/csg.c
File diff suppressed because it is too large
Load diff
1956
code/bspc/faces.c
1956
code/bspc/faces.c
File diff suppressed because it is too large
Load diff
|
|
@ -1,232 +1,232 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
#include <GL/glaux.h>
|
#include <GL/glaux.h>
|
||||||
|
|
||||||
#include "qbsp.h"
|
#include "qbsp.h"
|
||||||
|
|
||||||
// can't use the glvertex3fv functions, because the vec3_t fields
|
// can't use the glvertex3fv functions, because the vec3_t fields
|
||||||
// could be either floats or doubles, depending on DOUBLEVEC_T
|
// could be either floats or doubles, depending on DOUBLEVEC_T
|
||||||
|
|
||||||
qboolean drawflag;
|
qboolean drawflag;
|
||||||
vec3_t draw_mins, draw_maxs;
|
vec3_t draw_mins, draw_maxs;
|
||||||
|
|
||||||
|
|
||||||
#define WIN_SIZE 512
|
#define WIN_SIZE 512
|
||||||
|
|
||||||
void InitWindow (void)
|
void InitWindow (void)
|
||||||
{
|
{
|
||||||
auxInitDisplayMode (AUX_SINGLE | AUX_RGB);
|
auxInitDisplayMode (AUX_SINGLE | AUX_RGB);
|
||||||
auxInitPosition (0, 0, WIN_SIZE, WIN_SIZE);
|
auxInitPosition (0, 0, WIN_SIZE, WIN_SIZE);
|
||||||
auxInitWindow ("qcsg");
|
auxInitWindow ("qcsg");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Draw_ClearWindow (void)
|
void Draw_ClearWindow (void)
|
||||||
{
|
{
|
||||||
static int init;
|
static int init;
|
||||||
int w, h, g;
|
int w, h, g;
|
||||||
vec_t mx, my;
|
vec_t mx, my;
|
||||||
|
|
||||||
if (!drawflag)
|
if (!drawflag)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!init)
|
if (!init)
|
||||||
{
|
{
|
||||||
init = true;
|
init = true;
|
||||||
InitWindow ();
|
InitWindow ();
|
||||||
}
|
}
|
||||||
|
|
||||||
glClearColor (1,0.8,0.8,0);
|
glClearColor (1,0.8,0.8,0);
|
||||||
glClear (GL_COLOR_BUFFER_BIT);
|
glClear (GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
w = (draw_maxs[0] - draw_mins[0]);
|
w = (draw_maxs[0] - draw_mins[0]);
|
||||||
h = (draw_maxs[1] - draw_mins[1]);
|
h = (draw_maxs[1] - draw_mins[1]);
|
||||||
|
|
||||||
mx = draw_mins[0] + w/2;
|
mx = draw_mins[0] + w/2;
|
||||||
my = draw_mins[1] + h/2;
|
my = draw_mins[1] + h/2;
|
||||||
|
|
||||||
g = w > h ? w : h;
|
g = w > h ? w : h;
|
||||||
|
|
||||||
glLoadIdentity ();
|
glLoadIdentity ();
|
||||||
gluPerspective (90, 1, 2, 16384);
|
gluPerspective (90, 1, 2, 16384);
|
||||||
gluLookAt (mx, my, draw_maxs[2] + g/2, mx , my, draw_maxs[2], 0, 1, 0);
|
gluLookAt (mx, my, draw_maxs[2] + g/2, mx , my, draw_maxs[2], 0, 1, 0);
|
||||||
|
|
||||||
glColor3f (0,0,0);
|
glColor3f (0,0,0);
|
||||||
// glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
|
// glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
|
||||||
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
|
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
|
||||||
glDisable (GL_DEPTH_TEST);
|
glDisable (GL_DEPTH_TEST);
|
||||||
glEnable (GL_BLEND);
|
glEnable (GL_BLEND);
|
||||||
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
glColor4f (1,0,0,0.5);
|
glColor4f (1,0,0,0.5);
|
||||||
glBegin (GL_POLYGON);
|
glBegin (GL_POLYGON);
|
||||||
|
|
||||||
glVertex3f (0, 500, 0);
|
glVertex3f (0, 500, 0);
|
||||||
glVertex3f (0, 900, 0);
|
glVertex3f (0, 900, 0);
|
||||||
glVertex3f (0, 900, 100);
|
glVertex3f (0, 900, 100);
|
||||||
glVertex3f (0, 500, 100);
|
glVertex3f (0, 500, 100);
|
||||||
|
|
||||||
glEnd ();
|
glEnd ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
glFlush ();
|
glFlush ();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Draw_SetRed (void)
|
void Draw_SetRed (void)
|
||||||
{
|
{
|
||||||
if (!drawflag)
|
if (!drawflag)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
glColor3f (1,0,0);
|
glColor3f (1,0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Draw_SetGrey (void)
|
void Draw_SetGrey (void)
|
||||||
{
|
{
|
||||||
if (!drawflag)
|
if (!drawflag)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
glColor3f (0.5,0.5,0.5);
|
glColor3f (0.5,0.5,0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Draw_SetBlack (void)
|
void Draw_SetBlack (void)
|
||||||
{
|
{
|
||||||
if (!drawflag)
|
if (!drawflag)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
glColor3f (0,0,0);
|
glColor3f (0,0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawWinding (winding_t *w)
|
void DrawWinding (winding_t *w)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!drawflag)
|
if (!drawflag)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
glColor4f (0,0,0,0.5);
|
glColor4f (0,0,0,0.5);
|
||||||
glBegin (GL_LINE_LOOP);
|
glBegin (GL_LINE_LOOP);
|
||||||
for (i=0 ; i<w->numpoints ; i++)
|
for (i=0 ; i<w->numpoints ; i++)
|
||||||
glVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] );
|
glVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] );
|
||||||
glEnd ();
|
glEnd ();
|
||||||
|
|
||||||
glColor4f (0,1,0,0.3);
|
glColor4f (0,1,0,0.3);
|
||||||
glBegin (GL_POLYGON);
|
glBegin (GL_POLYGON);
|
||||||
for (i=0 ; i<w->numpoints ; i++)
|
for (i=0 ; i<w->numpoints ; i++)
|
||||||
glVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] );
|
glVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] );
|
||||||
glEnd ();
|
glEnd ();
|
||||||
|
|
||||||
glFlush ();
|
glFlush ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawAuxWinding (winding_t *w)
|
void DrawAuxWinding (winding_t *w)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!drawflag)
|
if (!drawflag)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
glColor4f (0,0,0,0.5);
|
glColor4f (0,0,0,0.5);
|
||||||
glBegin (GL_LINE_LOOP);
|
glBegin (GL_LINE_LOOP);
|
||||||
for (i=0 ; i<w->numpoints ; i++)
|
for (i=0 ; i<w->numpoints ; i++)
|
||||||
glVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] );
|
glVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] );
|
||||||
glEnd ();
|
glEnd ();
|
||||||
|
|
||||||
glColor4f (1,0,0,0.3);
|
glColor4f (1,0,0,0.3);
|
||||||
glBegin (GL_POLYGON);
|
glBegin (GL_POLYGON);
|
||||||
for (i=0 ; i<w->numpoints ; i++)
|
for (i=0 ; i<w->numpoints ; i++)
|
||||||
glVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] );
|
glVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] );
|
||||||
glEnd ();
|
glEnd ();
|
||||||
|
|
||||||
glFlush ();
|
glFlush ();
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================
|
//============================================================
|
||||||
|
|
||||||
#define GLSERV_PORT 25001
|
#define GLSERV_PORT 25001
|
||||||
|
|
||||||
qboolean wins_init;
|
qboolean wins_init;
|
||||||
int draw_socket;
|
int draw_socket;
|
||||||
|
|
||||||
void GLS_BeginScene (void)
|
void GLS_BeginScene (void)
|
||||||
{
|
{
|
||||||
WSADATA winsockdata;
|
WSADATA winsockdata;
|
||||||
WORD wVersionRequested;
|
WORD wVersionRequested;
|
||||||
struct sockaddr_in address;
|
struct sockaddr_in address;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!wins_init)
|
if (!wins_init)
|
||||||
{
|
{
|
||||||
wins_init = true;
|
wins_init = true;
|
||||||
|
|
||||||
wVersionRequested = MAKEWORD(1, 1);
|
wVersionRequested = MAKEWORD(1, 1);
|
||||||
|
|
||||||
r = WSAStartup (MAKEWORD(1, 1), &winsockdata);
|
r = WSAStartup (MAKEWORD(1, 1), &winsockdata);
|
||||||
|
|
||||||
if (r)
|
if (r)
|
||||||
Error ("Winsock initialization failed.");
|
Error ("Winsock initialization failed.");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// connect a socket to the server
|
// connect a socket to the server
|
||||||
|
|
||||||
draw_socket = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
draw_socket = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||||
if (draw_socket == -1)
|
if (draw_socket == -1)
|
||||||
Error ("draw_socket failed");
|
Error ("draw_socket failed");
|
||||||
|
|
||||||
address.sin_family = AF_INET;
|
address.sin_family = AF_INET;
|
||||||
address.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
|
address.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
|
||||||
address.sin_port = GLSERV_PORT;
|
address.sin_port = GLSERV_PORT;
|
||||||
r = connect (draw_socket, (struct sockaddr *)&address, sizeof(address));
|
r = connect (draw_socket, (struct sockaddr *)&address, sizeof(address));
|
||||||
if (r == -1)
|
if (r == -1)
|
||||||
{
|
{
|
||||||
closesocket (draw_socket);
|
closesocket (draw_socket);
|
||||||
draw_socket = 0;
|
draw_socket = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLS_Winding (winding_t *w, int code)
|
void GLS_Winding (winding_t *w, int code)
|
||||||
{
|
{
|
||||||
byte buf[1024];
|
byte buf[1024];
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
if (!draw_socket)
|
if (!draw_socket)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
((int *)buf)[0] = w->numpoints;
|
((int *)buf)[0] = w->numpoints;
|
||||||
((int *)buf)[1] = code;
|
((int *)buf)[1] = code;
|
||||||
for (i=0 ; i<w->numpoints ; i++)
|
for (i=0 ; i<w->numpoints ; i++)
|
||||||
for (j=0 ; j<3 ; j++)
|
for (j=0 ; j<3 ; j++)
|
||||||
((float *)buf)[2+i*3+j] = w->p[i][j];
|
((float *)buf)[2+i*3+j] = w->p[i][j];
|
||||||
|
|
||||||
send (draw_socket, buf, w->numpoints*12+8, 0);
|
send (draw_socket, buf, w->numpoints*12+8, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLS_EndScene (void)
|
void GLS_EndScene (void)
|
||||||
{
|
{
|
||||||
closesocket (draw_socket);
|
closesocket (draw_socket);
|
||||||
draw_socket = 0;
|
draw_socket = 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,149 +1,149 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "qbsp.h"
|
#include "qbsp.h"
|
||||||
|
|
||||||
int c_glfaces;
|
int c_glfaces;
|
||||||
|
|
||||||
int PortalVisibleSides (portal_t *p)
|
int PortalVisibleSides (portal_t *p)
|
||||||
{
|
{
|
||||||
int fcon, bcon;
|
int fcon, bcon;
|
||||||
|
|
||||||
if (!p->onnode)
|
if (!p->onnode)
|
||||||
return 0; // outside
|
return 0; // outside
|
||||||
|
|
||||||
fcon = p->nodes[0]->contents;
|
fcon = p->nodes[0]->contents;
|
||||||
bcon = p->nodes[1]->contents;
|
bcon = p->nodes[1]->contents;
|
||||||
|
|
||||||
// same contents never create a face
|
// same contents never create a face
|
||||||
if (fcon == bcon)
|
if (fcon == bcon)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// FIXME: is this correct now?
|
// FIXME: is this correct now?
|
||||||
if (!fcon)
|
if (!fcon)
|
||||||
return 1;
|
return 1;
|
||||||
if (!bcon)
|
if (!bcon)
|
||||||
return 2;
|
return 2;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputWinding (winding_t *w, FILE *glview)
|
void OutputWinding (winding_t *w, FILE *glview)
|
||||||
{
|
{
|
||||||
static int level = 128;
|
static int level = 128;
|
||||||
vec_t light;
|
vec_t light;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
fprintf (glview, "%i\n", w->numpoints);
|
fprintf (glview, "%i\n", w->numpoints);
|
||||||
level+=28;
|
level+=28;
|
||||||
light = (level&255)/255.0;
|
light = (level&255)/255.0;
|
||||||
for (i=0 ; i<w->numpoints ; i++)
|
for (i=0 ; i<w->numpoints ; i++)
|
||||||
{
|
{
|
||||||
fprintf (glview, "%6.3f %6.3f %6.3f %6.3f %6.3f %6.3f\n",
|
fprintf (glview, "%6.3f %6.3f %6.3f %6.3f %6.3f %6.3f\n",
|
||||||
w->p[i][0],
|
w->p[i][0],
|
||||||
w->p[i][1],
|
w->p[i][1],
|
||||||
w->p[i][2],
|
w->p[i][2],
|
||||||
light,
|
light,
|
||||||
light,
|
light,
|
||||||
light);
|
light);
|
||||||
}
|
}
|
||||||
fprintf (glview, "\n");
|
fprintf (glview, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=============
|
=============
|
||||||
OutputPortal
|
OutputPortal
|
||||||
=============
|
=============
|
||||||
*/
|
*/
|
||||||
void OutputPortal (portal_t *p, FILE *glview)
|
void OutputPortal (portal_t *p, FILE *glview)
|
||||||
{
|
{
|
||||||
winding_t *w;
|
winding_t *w;
|
||||||
int sides;
|
int sides;
|
||||||
|
|
||||||
sides = PortalVisibleSides (p);
|
sides = PortalVisibleSides (p);
|
||||||
if (!sides)
|
if (!sides)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
c_glfaces++;
|
c_glfaces++;
|
||||||
|
|
||||||
w = p->winding;
|
w = p->winding;
|
||||||
|
|
||||||
if (sides == 2) // back side
|
if (sides == 2) // back side
|
||||||
w = ReverseWinding (w);
|
w = ReverseWinding (w);
|
||||||
|
|
||||||
OutputWinding (w, glview);
|
OutputWinding (w, glview);
|
||||||
|
|
||||||
if (sides == 2)
|
if (sides == 2)
|
||||||
FreeWinding(w);
|
FreeWinding(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=============
|
=============
|
||||||
WriteGLView_r
|
WriteGLView_r
|
||||||
=============
|
=============
|
||||||
*/
|
*/
|
||||||
void WriteGLView_r (node_t *node, FILE *glview)
|
void WriteGLView_r (node_t *node, FILE *glview)
|
||||||
{
|
{
|
||||||
portal_t *p, *nextp;
|
portal_t *p, *nextp;
|
||||||
|
|
||||||
if (node->planenum != PLANENUM_LEAF)
|
if (node->planenum != PLANENUM_LEAF)
|
||||||
{
|
{
|
||||||
WriteGLView_r (node->children[0], glview);
|
WriteGLView_r (node->children[0], glview);
|
||||||
WriteGLView_r (node->children[1], glview);
|
WriteGLView_r (node->children[1], glview);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// write all the portals
|
// write all the portals
|
||||||
for (p=node->portals ; p ; p=nextp)
|
for (p=node->portals ; p ; p=nextp)
|
||||||
{
|
{
|
||||||
if (p->nodes[0] == node)
|
if (p->nodes[0] == node)
|
||||||
{
|
{
|
||||||
OutputPortal (p, glview);
|
OutputPortal (p, glview);
|
||||||
nextp = p->next[0];
|
nextp = p->next[0];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
nextp = p->next[1];
|
nextp = p->next[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=============
|
=============
|
||||||
WriteGLView
|
WriteGLView
|
||||||
=============
|
=============
|
||||||
*/
|
*/
|
||||||
void WriteGLView (tree_t *tree, char *source)
|
void WriteGLView (tree_t *tree, char *source)
|
||||||
{
|
{
|
||||||
char name[1024];
|
char name[1024];
|
||||||
FILE *glview;
|
FILE *glview;
|
||||||
|
|
||||||
c_glfaces = 0;
|
c_glfaces = 0;
|
||||||
sprintf (name, "%s%s.gl",outbase, source);
|
sprintf (name, "%s%s.gl",outbase, source);
|
||||||
printf ("Writing %s\n", name);
|
printf ("Writing %s\n", name);
|
||||||
|
|
||||||
glview = fopen (name, "w");
|
glview = fopen (name, "w");
|
||||||
if (!glview)
|
if (!glview)
|
||||||
Error ("Couldn't open %s", name);
|
Error ("Couldn't open %s", name);
|
||||||
WriteGLView_r (tree->headnode, glview);
|
WriteGLView_r (tree->headnode, glview);
|
||||||
fclose (glview);
|
fclose (glview);
|
||||||
|
|
||||||
printf ("%5i c_glfaces\n", c_glfaces);
|
printf ("%5i c_glfaces\n", c_glfaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,180 +1,180 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "l_cmd.h"
|
#include "l_cmd.h"
|
||||||
#include "l_math.h"
|
#include "l_math.h"
|
||||||
#include "l_mem.h"
|
#include "l_mem.h"
|
||||||
#include "l_log.h"
|
#include "l_log.h"
|
||||||
#include "../botlib/l_script.h"
|
#include "../botlib/l_script.h"
|
||||||
#include "l_bsp_ent.h"
|
#include "l_bsp_ent.h"
|
||||||
|
|
||||||
#define MAX_KEY 32
|
#define MAX_KEY 32
|
||||||
#define MAX_VALUE 1024
|
#define MAX_VALUE 1024
|
||||||
|
|
||||||
int num_entities;
|
int num_entities;
|
||||||
entity_t entities[MAX_MAP_ENTITIES];
|
entity_t entities[MAX_MAP_ENTITIES];
|
||||||
|
|
||||||
void StripTrailing(char *e)
|
void StripTrailing(char *e)
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
s = e + strlen(e)-1;
|
s = e + strlen(e)-1;
|
||||||
while (s >= e && *s <= 32)
|
while (s >= e && *s <= 32)
|
||||||
{
|
{
|
||||||
*s = 0;
|
*s = 0;
|
||||||
s--;
|
s--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=================
|
=================
|
||||||
ParseEpair
|
ParseEpair
|
||||||
=================
|
=================
|
||||||
*/
|
*/
|
||||||
epair_t *ParseEpair(script_t *script)
|
epair_t *ParseEpair(script_t *script)
|
||||||
{
|
{
|
||||||
epair_t *e;
|
epair_t *e;
|
||||||
token_t token;
|
token_t token;
|
||||||
|
|
||||||
e = GetMemory(sizeof(epair_t));
|
e = GetMemory(sizeof(epair_t));
|
||||||
memset (e, 0, sizeof(epair_t));
|
memset (e, 0, sizeof(epair_t));
|
||||||
|
|
||||||
PS_ExpectAnyToken(script, &token);
|
PS_ExpectAnyToken(script, &token);
|
||||||
StripDoubleQuotes(token.string);
|
StripDoubleQuotes(token.string);
|
||||||
if (strlen(token.string) >= MAX_KEY-1)
|
if (strlen(token.string) >= MAX_KEY-1)
|
||||||
Error ("ParseEpair: token %s too long", token.string);
|
Error ("ParseEpair: token %s too long", token.string);
|
||||||
e->key = copystring(token.string);
|
e->key = copystring(token.string);
|
||||||
PS_ExpectAnyToken(script, &token);
|
PS_ExpectAnyToken(script, &token);
|
||||||
StripDoubleQuotes(token.string);
|
StripDoubleQuotes(token.string);
|
||||||
if (strlen(token.string) >= MAX_VALUE-1)
|
if (strlen(token.string) >= MAX_VALUE-1)
|
||||||
Error ("ParseEpair: token %s too long", token.string);
|
Error ("ParseEpair: token %s too long", token.string);
|
||||||
e->value = copystring(token.string);
|
e->value = copystring(token.string);
|
||||||
|
|
||||||
// strip trailing spaces
|
// strip trailing spaces
|
||||||
StripTrailing(e->key);
|
StripTrailing(e->key);
|
||||||
StripTrailing(e->value);
|
StripTrailing(e->value);
|
||||||
|
|
||||||
return e;
|
return e;
|
||||||
} //end of the function ParseEpair
|
} //end of the function ParseEpair
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
================
|
================
|
||||||
ParseEntity
|
ParseEntity
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
qboolean ParseEntity(script_t *script)
|
qboolean ParseEntity(script_t *script)
|
||||||
{
|
{
|
||||||
epair_t *e;
|
epair_t *e;
|
||||||
entity_t *mapent;
|
entity_t *mapent;
|
||||||
token_t token;
|
token_t token;
|
||||||
|
|
||||||
if (!PS_ReadToken(script, &token))
|
if (!PS_ReadToken(script, &token))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (strcmp(token.string, "{"))
|
if (strcmp(token.string, "{"))
|
||||||
Error ("ParseEntity: { not found");
|
Error ("ParseEntity: { not found");
|
||||||
|
|
||||||
if (num_entities == MAX_MAP_ENTITIES)
|
if (num_entities == MAX_MAP_ENTITIES)
|
||||||
Error ("num_entities == MAX_MAP_ENTITIES");
|
Error ("num_entities == MAX_MAP_ENTITIES");
|
||||||
|
|
||||||
mapent = &entities[num_entities];
|
mapent = &entities[num_entities];
|
||||||
num_entities++;
|
num_entities++;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (!PS_ReadToken(script, &token))
|
if (!PS_ReadToken(script, &token))
|
||||||
Error ("ParseEntity: EOF without closing brace");
|
Error ("ParseEntity: EOF without closing brace");
|
||||||
if (!strcmp(token.string, "}") )
|
if (!strcmp(token.string, "}") )
|
||||||
break;
|
break;
|
||||||
PS_UnreadLastToken(script);
|
PS_UnreadLastToken(script);
|
||||||
e = ParseEpair(script);
|
e = ParseEpair(script);
|
||||||
e->next = mapent->epairs;
|
e->next = mapent->epairs;
|
||||||
mapent->epairs = e;
|
mapent->epairs = e;
|
||||||
} while (1);
|
} while (1);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} //end of the function ParseEntity
|
} //end of the function ParseEntity
|
||||||
|
|
||||||
void PrintEntity (entity_t *ent)
|
void PrintEntity (entity_t *ent)
|
||||||
{
|
{
|
||||||
epair_t *ep;
|
epair_t *ep;
|
||||||
|
|
||||||
printf ("------- entity %p -------\n", ent);
|
printf ("------- entity %p -------\n", ent);
|
||||||
for (ep=ent->epairs ; ep ; ep=ep->next)
|
for (ep=ent->epairs ; ep ; ep=ep->next)
|
||||||
{
|
{
|
||||||
printf ("%s = %s\n", ep->key, ep->value);
|
printf ("%s = %s\n", ep->key, ep->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetKeyValue (entity_t *ent, char *key, char *value)
|
void SetKeyValue (entity_t *ent, char *key, char *value)
|
||||||
{
|
{
|
||||||
epair_t *ep;
|
epair_t *ep;
|
||||||
|
|
||||||
for (ep=ent->epairs ; ep ; ep=ep->next)
|
for (ep=ent->epairs ; ep ; ep=ep->next)
|
||||||
if (!strcmp (ep->key, key) )
|
if (!strcmp (ep->key, key) )
|
||||||
{
|
{
|
||||||
FreeMemory(ep->value);
|
FreeMemory(ep->value);
|
||||||
ep->value = copystring(value);
|
ep->value = copystring(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ep = GetMemory(sizeof(*ep));
|
ep = GetMemory(sizeof(*ep));
|
||||||
ep->next = ent->epairs;
|
ep->next = ent->epairs;
|
||||||
ent->epairs = ep;
|
ent->epairs = ep;
|
||||||
ep->key = copystring(key);
|
ep->key = copystring(key);
|
||||||
ep->value = copystring(value);
|
ep->value = copystring(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *ValueForKey (entity_t *ent, char *key)
|
char *ValueForKey (entity_t *ent, char *key)
|
||||||
{
|
{
|
||||||
epair_t *ep;
|
epair_t *ep;
|
||||||
|
|
||||||
for (ep=ent->epairs ; ep ; ep=ep->next)
|
for (ep=ent->epairs ; ep ; ep=ep->next)
|
||||||
if (!strcmp (ep->key, key) )
|
if (!strcmp (ep->key, key) )
|
||||||
return ep->value;
|
return ep->value;
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
vec_t FloatForKey (entity_t *ent, char *key)
|
vec_t FloatForKey (entity_t *ent, char *key)
|
||||||
{
|
{
|
||||||
char *k;
|
char *k;
|
||||||
|
|
||||||
k = ValueForKey (ent, key);
|
k = ValueForKey (ent, key);
|
||||||
return atof(k);
|
return atof(k);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetVectorForKey (entity_t *ent, char *key, vec3_t vec)
|
void GetVectorForKey (entity_t *ent, char *key, vec3_t vec)
|
||||||
{
|
{
|
||||||
char *k;
|
char *k;
|
||||||
double v1, v2, v3;
|
double v1, v2, v3;
|
||||||
|
|
||||||
k = ValueForKey (ent, key);
|
k = ValueForKey (ent, key);
|
||||||
// scanf into doubles, then assign, so it is vec_t size independent
|
// scanf into doubles, then assign, so it is vec_t size independent
|
||||||
v1 = v2 = v3 = 0;
|
v1 = v2 = v3 = 0;
|
||||||
sscanf (k, "%lf %lf %lf", &v1, &v2, &v3);
|
sscanf (k, "%lf %lf %lf", &v1, &v2, &v3);
|
||||||
vec[0] = v1;
|
vec[0] = v1;
|
||||||
vec[1] = v2;
|
vec[1] = v2;
|
||||||
vec[2] = v3;
|
vec[2] = v3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,58 +1,58 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MAX_MAP_ENTITIES
|
#ifndef MAX_MAP_ENTITIES
|
||||||
#define MAX_MAP_ENTITIES 2048
|
#define MAX_MAP_ENTITIES 2048
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct epair_s
|
typedef struct epair_s
|
||||||
{
|
{
|
||||||
struct epair_s *next;
|
struct epair_s *next;
|
||||||
char *key;
|
char *key;
|
||||||
char *value;
|
char *value;
|
||||||
} epair_t;
|
} epair_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
vec3_t origin;
|
vec3_t origin;
|
||||||
int firstbrush;
|
int firstbrush;
|
||||||
int numbrushes;
|
int numbrushes;
|
||||||
epair_t *epairs;
|
epair_t *epairs;
|
||||||
// only valid for func_areaportals
|
// only valid for func_areaportals
|
||||||
int areaportalnum;
|
int areaportalnum;
|
||||||
int portalareas[2];
|
int portalareas[2];
|
||||||
int modelnum; //for bsp 2 map conversion
|
int modelnum; //for bsp 2 map conversion
|
||||||
qboolean wasdetail; //for SIN
|
qboolean wasdetail; //for SIN
|
||||||
} entity_t;
|
} entity_t;
|
||||||
|
|
||||||
extern int num_entities;
|
extern int num_entities;
|
||||||
extern entity_t entities[MAX_MAP_ENTITIES];
|
extern entity_t entities[MAX_MAP_ENTITIES];
|
||||||
|
|
||||||
void StripTrailing(char *e);
|
void StripTrailing(char *e);
|
||||||
void SetKeyValue(entity_t *ent, char *key, char *value);
|
void SetKeyValue(entity_t *ent, char *key, char *value);
|
||||||
char *ValueForKey(entity_t *ent, char *key); // will return "" if not present
|
char *ValueForKey(entity_t *ent, char *key); // will return "" if not present
|
||||||
vec_t FloatForKey(entity_t *ent, char *key);
|
vec_t FloatForKey(entity_t *ent, char *key);
|
||||||
void GetVectorForKey(entity_t *ent, char *key, vec3_t vec);
|
void GetVectorForKey(entity_t *ent, char *key, vec3_t vec);
|
||||||
qboolean ParseEntity(script_t *script);
|
qboolean ParseEntity(script_t *script);
|
||||||
epair_t *ParseEpair(script_t *script);
|
epair_t *ParseEpair(script_t *script);
|
||||||
void PrintEntity(entity_t *ent);
|
void PrintEntity(entity_t *ent);
|
||||||
|
|
||||||
|
|
|
||||||
1776
code/bspc/l_bsp_hl.c
1776
code/bspc/l_bsp_hl.c
File diff suppressed because it is too large
Load diff
|
|
@ -1,314 +1,314 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
// upper design bounds
|
// upper design bounds
|
||||||
|
|
||||||
#define HL_MAX_MAP_HULLS 4
|
#define HL_MAX_MAP_HULLS 4
|
||||||
|
|
||||||
#define HL_MAX_MAP_MODELS 400
|
#define HL_MAX_MAP_MODELS 400
|
||||||
#define HL_MAX_MAP_BRUSHES 4096
|
#define HL_MAX_MAP_BRUSHES 4096
|
||||||
#define HL_MAX_MAP_ENTITIES 1024
|
#define HL_MAX_MAP_ENTITIES 1024
|
||||||
#define HL_MAX_MAP_ENTSTRING (128*1024)
|
#define HL_MAX_MAP_ENTSTRING (128*1024)
|
||||||
|
|
||||||
#define HL_MAX_MAP_PLANES 32767
|
#define HL_MAX_MAP_PLANES 32767
|
||||||
#define HL_MAX_MAP_NODES 32767 // because negative shorts are contents
|
#define HL_MAX_MAP_NODES 32767 // because negative shorts are contents
|
||||||
#define HL_MAX_MAP_CLIPNODES 32767 //
|
#define HL_MAX_MAP_CLIPNODES 32767 //
|
||||||
#define HL_MAX_MAP_LEAFS 8192
|
#define HL_MAX_MAP_LEAFS 8192
|
||||||
#define HL_MAX_MAP_VERTS 65535
|
#define HL_MAX_MAP_VERTS 65535
|
||||||
#define HL_MAX_MAP_FACES 65535
|
#define HL_MAX_MAP_FACES 65535
|
||||||
#define HL_MAX_MAP_MARKSURFACES 65535
|
#define HL_MAX_MAP_MARKSURFACES 65535
|
||||||
#define HL_MAX_MAP_TEXINFO 8192
|
#define HL_MAX_MAP_TEXINFO 8192
|
||||||
#define HL_MAX_MAP_EDGES 256000
|
#define HL_MAX_MAP_EDGES 256000
|
||||||
#define HL_MAX_MAP_SURFEDGES 512000
|
#define HL_MAX_MAP_SURFEDGES 512000
|
||||||
#define HL_MAX_MAP_TEXTURES 512
|
#define HL_MAX_MAP_TEXTURES 512
|
||||||
#define HL_MAX_MAP_MIPTEX 0x200000
|
#define HL_MAX_MAP_MIPTEX 0x200000
|
||||||
#define HL_MAX_MAP_LIGHTING 0x200000
|
#define HL_MAX_MAP_LIGHTING 0x200000
|
||||||
#define HL_MAX_MAP_VISIBILITY 0x200000
|
#define HL_MAX_MAP_VISIBILITY 0x200000
|
||||||
|
|
||||||
#define HL_MAX_MAP_PORTALS 65536
|
#define HL_MAX_MAP_PORTALS 65536
|
||||||
|
|
||||||
// key / value pair sizes
|
// key / value pair sizes
|
||||||
|
|
||||||
#define MAX_KEY 32
|
#define MAX_KEY 32
|
||||||
#define MAX_VALUE 1024
|
#define MAX_VALUE 1024
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
|
|
||||||
#define HL_BSPVERSION 30
|
#define HL_BSPVERSION 30
|
||||||
#define HL_TOOLVERSION 2
|
#define HL_TOOLVERSION 2
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int fileofs, filelen;
|
int fileofs, filelen;
|
||||||
} hl_lump_t;
|
} hl_lump_t;
|
||||||
|
|
||||||
#define HL_LUMP_ENTITIES 0
|
#define HL_LUMP_ENTITIES 0
|
||||||
#define HL_LUMP_PLANES 1
|
#define HL_LUMP_PLANES 1
|
||||||
#define HL_LUMP_TEXTURES 2
|
#define HL_LUMP_TEXTURES 2
|
||||||
#define HL_LUMP_VERTEXES 3
|
#define HL_LUMP_VERTEXES 3
|
||||||
#define HL_LUMP_VISIBILITY 4
|
#define HL_LUMP_VISIBILITY 4
|
||||||
#define HL_LUMP_NODES 5
|
#define HL_LUMP_NODES 5
|
||||||
#define HL_LUMP_TEXINFO 6
|
#define HL_LUMP_TEXINFO 6
|
||||||
#define HL_LUMP_FACES 7
|
#define HL_LUMP_FACES 7
|
||||||
#define HL_LUMP_LIGHTING 8
|
#define HL_LUMP_LIGHTING 8
|
||||||
#define HL_LUMP_CLIPNODES 9
|
#define HL_LUMP_CLIPNODES 9
|
||||||
#define HL_LUMP_LEAFS 10
|
#define HL_LUMP_LEAFS 10
|
||||||
#define HL_LUMP_MARKSURFACES 11
|
#define HL_LUMP_MARKSURFACES 11
|
||||||
#define HL_LUMP_EDGES 12
|
#define HL_LUMP_EDGES 12
|
||||||
#define HL_LUMP_SURFEDGES 13
|
#define HL_LUMP_SURFEDGES 13
|
||||||
#define HL_LUMP_MODELS 14
|
#define HL_LUMP_MODELS 14
|
||||||
|
|
||||||
#define HL_HEADER_LUMPS 15
|
#define HL_HEADER_LUMPS 15
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
float mins[3], maxs[3];
|
float mins[3], maxs[3];
|
||||||
float origin[3];
|
float origin[3];
|
||||||
int headnode[HL_MAX_MAP_HULLS];
|
int headnode[HL_MAX_MAP_HULLS];
|
||||||
int visleafs; // not including the solid leaf 0
|
int visleafs; // not including the solid leaf 0
|
||||||
int firstface, numfaces;
|
int firstface, numfaces;
|
||||||
} hl_dmodel_t;
|
} hl_dmodel_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int version;
|
int version;
|
||||||
hl_lump_t lumps[HL_HEADER_LUMPS];
|
hl_lump_t lumps[HL_HEADER_LUMPS];
|
||||||
} hl_dheader_t;
|
} hl_dheader_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int nummiptex;
|
int nummiptex;
|
||||||
int dataofs[4]; // [nummiptex]
|
int dataofs[4]; // [nummiptex]
|
||||||
} hl_dmiptexlump_t;
|
} hl_dmiptexlump_t;
|
||||||
|
|
||||||
#define MIPLEVELS 4
|
#define MIPLEVELS 4
|
||||||
typedef struct hl_miptex_s
|
typedef struct hl_miptex_s
|
||||||
{
|
{
|
||||||
char name[16];
|
char name[16];
|
||||||
unsigned width, height;
|
unsigned width, height;
|
||||||
unsigned offsets[MIPLEVELS]; // four mip maps stored
|
unsigned offsets[MIPLEVELS]; // four mip maps stored
|
||||||
} hl_miptex_t;
|
} hl_miptex_t;
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
float point[3];
|
float point[3];
|
||||||
} hl_dvertex_t;
|
} hl_dvertex_t;
|
||||||
|
|
||||||
|
|
||||||
// 0-2 are axial planes
|
// 0-2 are axial planes
|
||||||
#define PLANE_X 0
|
#define PLANE_X 0
|
||||||
#define PLANE_Y 1
|
#define PLANE_Y 1
|
||||||
#define PLANE_Z 2
|
#define PLANE_Z 2
|
||||||
|
|
||||||
// 3-5 are non-axial planes snapped to the nearest
|
// 3-5 are non-axial planes snapped to the nearest
|
||||||
#define PLANE_ANYX 3
|
#define PLANE_ANYX 3
|
||||||
#define PLANE_ANYY 4
|
#define PLANE_ANYY 4
|
||||||
#define PLANE_ANYZ 5
|
#define PLANE_ANYZ 5
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
float normal[3];
|
float normal[3];
|
||||||
float dist;
|
float dist;
|
||||||
int type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
|
int type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
|
||||||
} hl_dplane_t;
|
} hl_dplane_t;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define HL_CONTENTS_EMPTY -1
|
#define HL_CONTENTS_EMPTY -1
|
||||||
#define HL_CONTENTS_SOLID -2
|
#define HL_CONTENTS_SOLID -2
|
||||||
#define HL_CONTENTS_WATER -3
|
#define HL_CONTENTS_WATER -3
|
||||||
#define HL_CONTENTS_SLIME -4
|
#define HL_CONTENTS_SLIME -4
|
||||||
#define HL_CONTENTS_LAVA -5
|
#define HL_CONTENTS_LAVA -5
|
||||||
#define HL_CONTENTS_SKY -6
|
#define HL_CONTENTS_SKY -6
|
||||||
#define HL_CONTENTS_ORIGIN -7 // removed at csg time
|
#define HL_CONTENTS_ORIGIN -7 // removed at csg time
|
||||||
#define HL_CONTENTS_CLIP -8 // changed to contents_solid
|
#define HL_CONTENTS_CLIP -8 // changed to contents_solid
|
||||||
|
|
||||||
#define HL_CONTENTS_CURRENT_0 -9
|
#define HL_CONTENTS_CURRENT_0 -9
|
||||||
#define HL_CONTENTS_CURRENT_90 -10
|
#define HL_CONTENTS_CURRENT_90 -10
|
||||||
#define HL_CONTENTS_CURRENT_180 -11
|
#define HL_CONTENTS_CURRENT_180 -11
|
||||||
#define HL_CONTENTS_CURRENT_270 -12
|
#define HL_CONTENTS_CURRENT_270 -12
|
||||||
#define HL_CONTENTS_CURRENT_UP -13
|
#define HL_CONTENTS_CURRENT_UP -13
|
||||||
#define HL_CONTENTS_CURRENT_DOWN -14
|
#define HL_CONTENTS_CURRENT_DOWN -14
|
||||||
|
|
||||||
#define HL_CONTENTS_TRANSLUCENT -15
|
#define HL_CONTENTS_TRANSLUCENT -15
|
||||||
|
|
||||||
// !!! if this is changed, it must be changed in asm_i386.h too !!!
|
// !!! if this is changed, it must be changed in asm_i386.h too !!!
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int planenum;
|
int planenum;
|
||||||
short children[2]; // negative numbers are -(leafs+1), not nodes
|
short children[2]; // negative numbers are -(leafs+1), not nodes
|
||||||
short mins[3]; // for sphere culling
|
short mins[3]; // for sphere culling
|
||||||
short maxs[3];
|
short maxs[3];
|
||||||
unsigned short firstface;
|
unsigned short firstface;
|
||||||
unsigned short numfaces; // counting both sides
|
unsigned short numfaces; // counting both sides
|
||||||
} hl_dnode_t;
|
} hl_dnode_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int planenum;
|
int planenum;
|
||||||
short children[2]; // negative numbers are contents
|
short children[2]; // negative numbers are contents
|
||||||
} hl_dclipnode_t;
|
} hl_dclipnode_t;
|
||||||
|
|
||||||
|
|
||||||
typedef struct hl_texinfo_s
|
typedef struct hl_texinfo_s
|
||||||
{
|
{
|
||||||
float vecs[2][4]; // [s/t][xyz offset]
|
float vecs[2][4]; // [s/t][xyz offset]
|
||||||
int miptex;
|
int miptex;
|
||||||
int flags;
|
int flags;
|
||||||
} hl_texinfo_t;
|
} hl_texinfo_t;
|
||||||
#define TEX_SPECIAL 1 // sky or slime, no lightmap or 256 subdivision
|
#define TEX_SPECIAL 1 // sky or slime, no lightmap or 256 subdivision
|
||||||
|
|
||||||
// note that edge 0 is never used, because negative edge nums are used for
|
// note that edge 0 is never used, because negative edge nums are used for
|
||||||
// counterclockwise use of the edge in a face
|
// counterclockwise use of the edge in a face
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
unsigned short v[2]; // vertex numbers
|
unsigned short v[2]; // vertex numbers
|
||||||
} hl_dedge_t;
|
} hl_dedge_t;
|
||||||
|
|
||||||
#define MAXLIGHTMAPS 4
|
#define MAXLIGHTMAPS 4
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
short planenum;
|
short planenum;
|
||||||
short side;
|
short side;
|
||||||
|
|
||||||
int firstedge; // we must support > 64k edges
|
int firstedge; // we must support > 64k edges
|
||||||
short numedges;
|
short numedges;
|
||||||
short texinfo;
|
short texinfo;
|
||||||
|
|
||||||
// lighting info
|
// lighting info
|
||||||
byte styles[MAXLIGHTMAPS];
|
byte styles[MAXLIGHTMAPS];
|
||||||
int lightofs; // start of [numstyles*surfsize] samples
|
int lightofs; // start of [numstyles*surfsize] samples
|
||||||
} hl_dface_t;
|
} hl_dface_t;
|
||||||
|
|
||||||
|
|
||||||
#define AMBIENT_WATER 0
|
#define AMBIENT_WATER 0
|
||||||
#define AMBIENT_SKY 1
|
#define AMBIENT_SKY 1
|
||||||
#define AMBIENT_SLIME 2
|
#define AMBIENT_SLIME 2
|
||||||
#define AMBIENT_LAVA 3
|
#define AMBIENT_LAVA 3
|
||||||
|
|
||||||
#define NUM_AMBIENTS 4 // automatic ambient sounds
|
#define NUM_AMBIENTS 4 // automatic ambient sounds
|
||||||
|
|
||||||
// leaf 0 is the generic HL_CONTENTS_SOLID leaf, used for all solid areas
|
// leaf 0 is the generic HL_CONTENTS_SOLID leaf, used for all solid areas
|
||||||
// all other leafs need visibility info
|
// all other leafs need visibility info
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int contents;
|
int contents;
|
||||||
int visofs; // -1 = no visibility info
|
int visofs; // -1 = no visibility info
|
||||||
|
|
||||||
short mins[3]; // for frustum culling
|
short mins[3]; // for frustum culling
|
||||||
short maxs[3];
|
short maxs[3];
|
||||||
|
|
||||||
unsigned short firstmarksurface;
|
unsigned short firstmarksurface;
|
||||||
unsigned short nummarksurfaces;
|
unsigned short nummarksurfaces;
|
||||||
|
|
||||||
byte ambient_level[NUM_AMBIENTS];
|
byte ambient_level[NUM_AMBIENTS];
|
||||||
} hl_dleaf_t;
|
} hl_dleaf_t;
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef QUAKE_GAME
|
#ifndef QUAKE_GAME
|
||||||
|
|
||||||
#define ANGLE_UP -1
|
#define ANGLE_UP -1
|
||||||
#define ANGLE_DOWN -2
|
#define ANGLE_DOWN -2
|
||||||
|
|
||||||
|
|
||||||
// the utilities get to be lazy and just use large static arrays
|
// the utilities get to be lazy and just use large static arrays
|
||||||
|
|
||||||
extern int hl_nummodels;
|
extern int hl_nummodels;
|
||||||
extern hl_dmodel_t *hl_dmodels;//[MAX_MAP_MODELS];
|
extern hl_dmodel_t *hl_dmodels;//[MAX_MAP_MODELS];
|
||||||
extern int hl_dmodels_checksum;
|
extern int hl_dmodels_checksum;
|
||||||
|
|
||||||
extern int hl_visdatasize;
|
extern int hl_visdatasize;
|
||||||
extern byte *hl_dvisdata;//[MAX_MAP_VISIBILITY];
|
extern byte *hl_dvisdata;//[MAX_MAP_VISIBILITY];
|
||||||
extern int hl_dvisdata_checksum;
|
extern int hl_dvisdata_checksum;
|
||||||
|
|
||||||
extern int hl_lightdatasize;
|
extern int hl_lightdatasize;
|
||||||
extern byte *hl_dlightdata;//[MAX_MAP_LIGHTING];
|
extern byte *hl_dlightdata;//[MAX_MAP_LIGHTING];
|
||||||
extern int hl_dlightdata_checksum;
|
extern int hl_dlightdata_checksum;
|
||||||
|
|
||||||
extern int hl_texdatasize;
|
extern int hl_texdatasize;
|
||||||
extern byte *hl_dtexdata;//[MAX_MAP_MIPTEX]; // (dmiptexlump_t)
|
extern byte *hl_dtexdata;//[MAX_MAP_MIPTEX]; // (dmiptexlump_t)
|
||||||
extern int hl_dtexdata_checksum;
|
extern int hl_dtexdata_checksum;
|
||||||
|
|
||||||
extern int hl_entdatasize;
|
extern int hl_entdatasize;
|
||||||
extern char *hl_dentdata;//[MAX_MAP_ENTSTRING];
|
extern char *hl_dentdata;//[MAX_MAP_ENTSTRING];
|
||||||
extern int hl_dentdata_checksum;
|
extern int hl_dentdata_checksum;
|
||||||
|
|
||||||
extern int hl_numleafs;
|
extern int hl_numleafs;
|
||||||
extern hl_dleaf_t *hl_dleafs;//[MAX_MAP_LEAFS];
|
extern hl_dleaf_t *hl_dleafs;//[MAX_MAP_LEAFS];
|
||||||
extern int hl_dleafs_checksum;
|
extern int hl_dleafs_checksum;
|
||||||
|
|
||||||
extern int hl_numplanes;
|
extern int hl_numplanes;
|
||||||
extern hl_dplane_t *hl_dplanes;//[MAX_MAP_PLANES];
|
extern hl_dplane_t *hl_dplanes;//[MAX_MAP_PLANES];
|
||||||
extern int hl_dplanes_checksum;
|
extern int hl_dplanes_checksum;
|
||||||
|
|
||||||
extern int hl_numvertexes;
|
extern int hl_numvertexes;
|
||||||
extern hl_dvertex_t *hl_dvertexes;//[MAX_MAP_VERTS];
|
extern hl_dvertex_t *hl_dvertexes;//[MAX_MAP_VERTS];
|
||||||
extern int hl_dvertexes_checksum;
|
extern int hl_dvertexes_checksum;
|
||||||
|
|
||||||
extern int hl_numnodes;
|
extern int hl_numnodes;
|
||||||
extern hl_dnode_t *hl_dnodes;//[MAX_MAP_NODES];
|
extern hl_dnode_t *hl_dnodes;//[MAX_MAP_NODES];
|
||||||
extern int hl_dnodes_checksum;
|
extern int hl_dnodes_checksum;
|
||||||
|
|
||||||
extern int hl_numtexinfo;
|
extern int hl_numtexinfo;
|
||||||
extern hl_texinfo_t *hl_texinfo;//[MAX_MAP_TEXINFO];
|
extern hl_texinfo_t *hl_texinfo;//[MAX_MAP_TEXINFO];
|
||||||
extern int hl_texinfo_checksum;
|
extern int hl_texinfo_checksum;
|
||||||
|
|
||||||
extern int hl_numfaces;
|
extern int hl_numfaces;
|
||||||
extern hl_dface_t *hl_dfaces;//[MAX_MAP_FACES];
|
extern hl_dface_t *hl_dfaces;//[MAX_MAP_FACES];
|
||||||
extern int hl_dfaces_checksum;
|
extern int hl_dfaces_checksum;
|
||||||
|
|
||||||
extern int hl_numclipnodes;
|
extern int hl_numclipnodes;
|
||||||
extern hl_dclipnode_t *hl_dclipnodes;//[MAX_MAP_CLIPNODES];
|
extern hl_dclipnode_t *hl_dclipnodes;//[MAX_MAP_CLIPNODES];
|
||||||
extern int hl_dclipnodes_checksum;
|
extern int hl_dclipnodes_checksum;
|
||||||
|
|
||||||
extern int hl_numedges;
|
extern int hl_numedges;
|
||||||
extern hl_dedge_t *hl_dedges;//[MAX_MAP_EDGES];
|
extern hl_dedge_t *hl_dedges;//[MAX_MAP_EDGES];
|
||||||
extern int hl_dedges_checksum;
|
extern int hl_dedges_checksum;
|
||||||
|
|
||||||
extern int hl_nummarksurfaces;
|
extern int hl_nummarksurfaces;
|
||||||
extern unsigned short *hl_dmarksurfaces;//[MAX_MAP_MARKSURFACES];
|
extern unsigned short *hl_dmarksurfaces;//[MAX_MAP_MARKSURFACES];
|
||||||
extern int hl_dmarksurfaces_checksum;
|
extern int hl_dmarksurfaces_checksum;
|
||||||
|
|
||||||
extern int hl_numsurfedges;
|
extern int hl_numsurfedges;
|
||||||
extern int *hl_dsurfedges;//[MAX_MAP_SURFEDGES];
|
extern int *hl_dsurfedges;//[MAX_MAP_SURFEDGES];
|
||||||
extern int hl_dsurfedges_checksum;
|
extern int hl_dsurfedges_checksum;
|
||||||
|
|
||||||
int FastChecksum(void *buffer, int bytes);
|
int FastChecksum(void *buffer, int bytes);
|
||||||
|
|
||||||
void HL_AllocMaxBSP(void);
|
void HL_AllocMaxBSP(void);
|
||||||
void HL_FreeMaxBSP(void);
|
void HL_FreeMaxBSP(void);
|
||||||
|
|
||||||
void HL_DecompressVis(byte *in, byte *decompressed);
|
void HL_DecompressVis(byte *in, byte *decompressed);
|
||||||
int HL_CompressVis(byte *vis, byte *dest);
|
int HL_CompressVis(byte *vis, byte *dest);
|
||||||
|
|
||||||
void HL_LoadBSPFile(char *filename, int offset, int length);
|
void HL_LoadBSPFile(char *filename, int offset, int length);
|
||||||
void HL_WriteBSPFile(char *filename);
|
void HL_WriteBSPFile(char *filename);
|
||||||
void HL_PrintBSPFileSizes(void);
|
void HL_PrintBSPFileSizes(void);
|
||||||
void HL_PrintBSPFileSizes(void);
|
void HL_PrintBSPFileSizes(void);
|
||||||
void HL_ParseEntities(void);
|
void HL_ParseEntities(void);
|
||||||
void HL_UnparseEntities(void);
|
void HL_UnparseEntities(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
1240
code/bspc/l_bsp_q1.c
1240
code/bspc/l_bsp_q1.c
File diff suppressed because it is too large
Load diff
|
|
@ -1,275 +1,275 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
// upper design bounds
|
// upper design bounds
|
||||||
|
|
||||||
#define Q1_MAX_MAP_HULLS 4
|
#define Q1_MAX_MAP_HULLS 4
|
||||||
|
|
||||||
#define Q1_MAX_MAP_MODELS 256
|
#define Q1_MAX_MAP_MODELS 256
|
||||||
#define Q1_MAX_MAP_BRUSHES 4096
|
#define Q1_MAX_MAP_BRUSHES 4096
|
||||||
#define Q1_MAX_MAP_ENTITIES 1024
|
#define Q1_MAX_MAP_ENTITIES 1024
|
||||||
#define Q1_MAX_MAP_ENTSTRING 65536
|
#define Q1_MAX_MAP_ENTSTRING 65536
|
||||||
|
|
||||||
#define Q1_MAX_MAP_PLANES 8192
|
#define Q1_MAX_MAP_PLANES 8192
|
||||||
#define Q1_MAX_MAP_NODES 32767 // because negative shorts are contents
|
#define Q1_MAX_MAP_NODES 32767 // because negative shorts are contents
|
||||||
#define Q1_MAX_MAP_CLIPNODES 32767 //
|
#define Q1_MAX_MAP_CLIPNODES 32767 //
|
||||||
#define Q1_MAX_MAP_LEAFS 32767 //
|
#define Q1_MAX_MAP_LEAFS 32767 //
|
||||||
#define Q1_MAX_MAP_VERTS 65535
|
#define Q1_MAX_MAP_VERTS 65535
|
||||||
#define Q1_MAX_MAP_FACES 65535
|
#define Q1_MAX_MAP_FACES 65535
|
||||||
#define Q1_MAX_MAP_MARKSURFACES 65535
|
#define Q1_MAX_MAP_MARKSURFACES 65535
|
||||||
#define Q1_MAX_MAP_TEXINFO 4096
|
#define Q1_MAX_MAP_TEXINFO 4096
|
||||||
#define Q1_MAX_MAP_EDGES 256000
|
#define Q1_MAX_MAP_EDGES 256000
|
||||||
#define Q1_MAX_MAP_SURFEDGES 512000
|
#define Q1_MAX_MAP_SURFEDGES 512000
|
||||||
#define Q1_MAX_MAP_MIPTEX 0x200000
|
#define Q1_MAX_MAP_MIPTEX 0x200000
|
||||||
#define Q1_MAX_MAP_LIGHTING 0x100000
|
#define Q1_MAX_MAP_LIGHTING 0x100000
|
||||||
#define Q1_MAX_MAP_VISIBILITY 0x100000
|
#define Q1_MAX_MAP_VISIBILITY 0x100000
|
||||||
|
|
||||||
// key / value pair sizes
|
// key / value pair sizes
|
||||||
|
|
||||||
#define MAX_KEY 32
|
#define MAX_KEY 32
|
||||||
#define MAX_VALUE 1024
|
#define MAX_VALUE 1024
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
|
|
||||||
#define Q1_BSPVERSION 29
|
#define Q1_BSPVERSION 29
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int fileofs, filelen;
|
int fileofs, filelen;
|
||||||
} q1_lump_t;
|
} q1_lump_t;
|
||||||
|
|
||||||
#define Q1_LUMP_ENTITIES 0
|
#define Q1_LUMP_ENTITIES 0
|
||||||
#define Q1_LUMP_PLANES 1
|
#define Q1_LUMP_PLANES 1
|
||||||
#define Q1_LUMP_TEXTURES 2
|
#define Q1_LUMP_TEXTURES 2
|
||||||
#define Q1_LUMP_VERTEXES 3
|
#define Q1_LUMP_VERTEXES 3
|
||||||
#define Q1_LUMP_VISIBILITY 4
|
#define Q1_LUMP_VISIBILITY 4
|
||||||
#define Q1_LUMP_NODES 5
|
#define Q1_LUMP_NODES 5
|
||||||
#define Q1_LUMP_TEXINFO 6
|
#define Q1_LUMP_TEXINFO 6
|
||||||
#define Q1_LUMP_FACES 7
|
#define Q1_LUMP_FACES 7
|
||||||
#define Q1_LUMP_LIGHTING 8
|
#define Q1_LUMP_LIGHTING 8
|
||||||
#define Q1_LUMP_CLIPNODES 9
|
#define Q1_LUMP_CLIPNODES 9
|
||||||
#define Q1_LUMP_LEAFS 10
|
#define Q1_LUMP_LEAFS 10
|
||||||
#define Q1_LUMP_MARKSURFACES 11
|
#define Q1_LUMP_MARKSURFACES 11
|
||||||
#define Q1_LUMP_EDGES 12
|
#define Q1_LUMP_EDGES 12
|
||||||
#define Q1_LUMP_SURFEDGES 13
|
#define Q1_LUMP_SURFEDGES 13
|
||||||
#define Q1_LUMP_MODELS 14
|
#define Q1_LUMP_MODELS 14
|
||||||
|
|
||||||
#define Q1_HEADER_LUMPS 15
|
#define Q1_HEADER_LUMPS 15
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
float mins[3], maxs[3];
|
float mins[3], maxs[3];
|
||||||
float origin[3];
|
float origin[3];
|
||||||
int headnode[Q1_MAX_MAP_HULLS];
|
int headnode[Q1_MAX_MAP_HULLS];
|
||||||
int visleafs; // not including the solid leaf 0
|
int visleafs; // not including the solid leaf 0
|
||||||
int firstface, numfaces;
|
int firstface, numfaces;
|
||||||
} q1_dmodel_t;
|
} q1_dmodel_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int version;
|
int version;
|
||||||
q1_lump_t lumps[Q1_HEADER_LUMPS];
|
q1_lump_t lumps[Q1_HEADER_LUMPS];
|
||||||
} q1_dheader_t;
|
} q1_dheader_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int nummiptex;
|
int nummiptex;
|
||||||
int dataofs[4]; // [nummiptex]
|
int dataofs[4]; // [nummiptex]
|
||||||
} q1_dmiptexlump_t;
|
} q1_dmiptexlump_t;
|
||||||
|
|
||||||
#define MIPLEVELS 4
|
#define MIPLEVELS 4
|
||||||
typedef struct q1_miptex_s
|
typedef struct q1_miptex_s
|
||||||
{
|
{
|
||||||
char name[16];
|
char name[16];
|
||||||
unsigned width, height;
|
unsigned width, height;
|
||||||
unsigned offsets[MIPLEVELS]; // four mip maps stored
|
unsigned offsets[MIPLEVELS]; // four mip maps stored
|
||||||
} q1_miptex_t;
|
} q1_miptex_t;
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
float point[3];
|
float point[3];
|
||||||
} q1_dvertex_t;
|
} q1_dvertex_t;
|
||||||
|
|
||||||
|
|
||||||
// 0-2 are axial planes
|
// 0-2 are axial planes
|
||||||
#define PLANE_X 0
|
#define PLANE_X 0
|
||||||
#define PLANE_Y 1
|
#define PLANE_Y 1
|
||||||
#define PLANE_Z 2
|
#define PLANE_Z 2
|
||||||
|
|
||||||
// 3-5 are non-axial planes snapped to the nearest
|
// 3-5 are non-axial planes snapped to the nearest
|
||||||
#define PLANE_ANYX 3
|
#define PLANE_ANYX 3
|
||||||
#define PLANE_ANYY 4
|
#define PLANE_ANYY 4
|
||||||
#define PLANE_ANYZ 5
|
#define PLANE_ANYZ 5
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
float normal[3];
|
float normal[3];
|
||||||
float dist;
|
float dist;
|
||||||
int type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
|
int type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
|
||||||
} q1_dplane_t;
|
} q1_dplane_t;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define Q1_CONTENTS_EMPTY -1
|
#define Q1_CONTENTS_EMPTY -1
|
||||||
#define Q1_CONTENTS_SOLID -2
|
#define Q1_CONTENTS_SOLID -2
|
||||||
#define Q1_CONTENTS_WATER -3
|
#define Q1_CONTENTS_WATER -3
|
||||||
#define Q1_CONTENTS_SLIME -4
|
#define Q1_CONTENTS_SLIME -4
|
||||||
#define Q1_CONTENTS_LAVA -5
|
#define Q1_CONTENTS_LAVA -5
|
||||||
#define Q1_CONTENTS_SKY -6
|
#define Q1_CONTENTS_SKY -6
|
||||||
|
|
||||||
// !!! if this is changed, it must be changed in asm_i386.h too !!!
|
// !!! if this is changed, it must be changed in asm_i386.h too !!!
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int planenum;
|
int planenum;
|
||||||
short children[2]; // negative numbers are -(leafs+1), not nodes
|
short children[2]; // negative numbers are -(leafs+1), not nodes
|
||||||
short mins[3]; // for sphere culling
|
short mins[3]; // for sphere culling
|
||||||
short maxs[3];
|
short maxs[3];
|
||||||
unsigned short firstface;
|
unsigned short firstface;
|
||||||
unsigned short numfaces; // counting both sides
|
unsigned short numfaces; // counting both sides
|
||||||
} q1_dnode_t;
|
} q1_dnode_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int planenum;
|
int planenum;
|
||||||
short children[2]; // negative numbers are contents
|
short children[2]; // negative numbers are contents
|
||||||
} q1_dclipnode_t;
|
} q1_dclipnode_t;
|
||||||
|
|
||||||
|
|
||||||
typedef struct q1_texinfo_s
|
typedef struct q1_texinfo_s
|
||||||
{
|
{
|
||||||
float vecs[2][4]; // [s/t][xyz offset]
|
float vecs[2][4]; // [s/t][xyz offset]
|
||||||
int miptex;
|
int miptex;
|
||||||
int flags;
|
int flags;
|
||||||
} q1_texinfo_t;
|
} q1_texinfo_t;
|
||||||
#define TEX_SPECIAL 1 // sky or slime, no lightmap or 256 subdivision
|
#define TEX_SPECIAL 1 // sky or slime, no lightmap or 256 subdivision
|
||||||
|
|
||||||
// note that edge 0 is never used, because negative edge nums are used for
|
// note that edge 0 is never used, because negative edge nums are used for
|
||||||
// counterclockwise use of the edge in a face
|
// counterclockwise use of the edge in a face
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
unsigned short v[2]; // vertex numbers
|
unsigned short v[2]; // vertex numbers
|
||||||
} q1_dedge_t;
|
} q1_dedge_t;
|
||||||
|
|
||||||
#define MAXLIGHTMAPS 4
|
#define MAXLIGHTMAPS 4
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
short planenum;
|
short planenum;
|
||||||
short side;
|
short side;
|
||||||
|
|
||||||
int firstedge; // we must support > 64k edges
|
int firstedge; // we must support > 64k edges
|
||||||
short numedges;
|
short numedges;
|
||||||
short texinfo;
|
short texinfo;
|
||||||
|
|
||||||
// lighting info
|
// lighting info
|
||||||
byte styles[MAXLIGHTMAPS];
|
byte styles[MAXLIGHTMAPS];
|
||||||
int lightofs; // start of [numstyles*surfsize] samples
|
int lightofs; // start of [numstyles*surfsize] samples
|
||||||
} q1_dface_t;
|
} q1_dface_t;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define AMBIENT_WATER 0
|
#define AMBIENT_WATER 0
|
||||||
#define AMBIENT_SKY 1
|
#define AMBIENT_SKY 1
|
||||||
#define AMBIENT_SLIME 2
|
#define AMBIENT_SLIME 2
|
||||||
#define AMBIENT_LAVA 3
|
#define AMBIENT_LAVA 3
|
||||||
|
|
||||||
#define NUM_AMBIENTS 4 // automatic ambient sounds
|
#define NUM_AMBIENTS 4 // automatic ambient sounds
|
||||||
|
|
||||||
// leaf 0 is the generic Q1_CONTENTS_SOLID leaf, used for all solid areas
|
// leaf 0 is the generic Q1_CONTENTS_SOLID leaf, used for all solid areas
|
||||||
// all other leafs need visibility info
|
// all other leafs need visibility info
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int contents;
|
int contents;
|
||||||
int visofs; // -1 = no visibility info
|
int visofs; // -1 = no visibility info
|
||||||
|
|
||||||
short mins[3]; // for frustum culling
|
short mins[3]; // for frustum culling
|
||||||
short maxs[3];
|
short maxs[3];
|
||||||
|
|
||||||
unsigned short firstmarksurface;
|
unsigned short firstmarksurface;
|
||||||
unsigned short nummarksurfaces;
|
unsigned short nummarksurfaces;
|
||||||
|
|
||||||
byte ambient_level[NUM_AMBIENTS];
|
byte ambient_level[NUM_AMBIENTS];
|
||||||
} q1_dleaf_t;
|
} q1_dleaf_t;
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef QUAKE_GAME
|
#ifndef QUAKE_GAME
|
||||||
|
|
||||||
// the utilities get to be lazy and just use large static arrays
|
// the utilities get to be lazy and just use large static arrays
|
||||||
|
|
||||||
extern int q1_nummodels;
|
extern int q1_nummodels;
|
||||||
extern q1_dmodel_t *q1_dmodels;//[MAX_MAP_MODELS];
|
extern q1_dmodel_t *q1_dmodels;//[MAX_MAP_MODELS];
|
||||||
|
|
||||||
extern int q1_visdatasize;
|
extern int q1_visdatasize;
|
||||||
extern byte *q1_dvisdata;//[MAX_MAP_VISIBILITY];
|
extern byte *q1_dvisdata;//[MAX_MAP_VISIBILITY];
|
||||||
|
|
||||||
extern int q1_lightdatasize;
|
extern int q1_lightdatasize;
|
||||||
extern byte *q1_dlightdata;//[MAX_MAP_LIGHTING];
|
extern byte *q1_dlightdata;//[MAX_MAP_LIGHTING];
|
||||||
|
|
||||||
extern int q1_texdatasize;
|
extern int q1_texdatasize;
|
||||||
extern byte *q1_dtexdata;//[MAX_MAP_MIPTEX]; // (dmiptexlump_t)
|
extern byte *q1_dtexdata;//[MAX_MAP_MIPTEX]; // (dmiptexlump_t)
|
||||||
|
|
||||||
extern int q1_entdatasize;
|
extern int q1_entdatasize;
|
||||||
extern char *q1_dentdata;//[MAX_MAP_ENTSTRING];
|
extern char *q1_dentdata;//[MAX_MAP_ENTSTRING];
|
||||||
|
|
||||||
extern int q1_numleafs;
|
extern int q1_numleafs;
|
||||||
extern q1_dleaf_t *q1_dleafs;//[MAX_MAP_LEAFS];
|
extern q1_dleaf_t *q1_dleafs;//[MAX_MAP_LEAFS];
|
||||||
|
|
||||||
extern int q1_numplanes;
|
extern int q1_numplanes;
|
||||||
extern q1_dplane_t *q1_dplanes;//[MAX_MAP_PLANES];
|
extern q1_dplane_t *q1_dplanes;//[MAX_MAP_PLANES];
|
||||||
|
|
||||||
extern int q1_numvertexes;
|
extern int q1_numvertexes;
|
||||||
extern q1_dvertex_t *q1_dvertexes;//[MAX_MAP_VERTS];
|
extern q1_dvertex_t *q1_dvertexes;//[MAX_MAP_VERTS];
|
||||||
|
|
||||||
extern int q1_numnodes;
|
extern int q1_numnodes;
|
||||||
extern q1_dnode_t *q1_dnodes;//[MAX_MAP_NODES];
|
extern q1_dnode_t *q1_dnodes;//[MAX_MAP_NODES];
|
||||||
|
|
||||||
extern int q1_numtexinfo;
|
extern int q1_numtexinfo;
|
||||||
extern q1_texinfo_t *q1_texinfo;//[MAX_MAP_TEXINFO];
|
extern q1_texinfo_t *q1_texinfo;//[MAX_MAP_TEXINFO];
|
||||||
|
|
||||||
extern int q1_numfaces;
|
extern int q1_numfaces;
|
||||||
extern q1_dface_t *q1_dfaces;//[MAX_MAP_FACES];
|
extern q1_dface_t *q1_dfaces;//[MAX_MAP_FACES];
|
||||||
|
|
||||||
extern int q1_numclipnodes;
|
extern int q1_numclipnodes;
|
||||||
extern q1_dclipnode_t *q1_dclipnodes;//[MAX_MAP_CLIPNODES];
|
extern q1_dclipnode_t *q1_dclipnodes;//[MAX_MAP_CLIPNODES];
|
||||||
|
|
||||||
extern int q1_numedges;
|
extern int q1_numedges;
|
||||||
extern q1_dedge_t *q1_dedges;//[MAX_MAP_EDGES];
|
extern q1_dedge_t *q1_dedges;//[MAX_MAP_EDGES];
|
||||||
|
|
||||||
extern int q1_nummarksurfaces;
|
extern int q1_nummarksurfaces;
|
||||||
extern unsigned short *q1_dmarksurfaces;//[MAX_MAP_MARKSURFACES];
|
extern unsigned short *q1_dmarksurfaces;//[MAX_MAP_MARKSURFACES];
|
||||||
|
|
||||||
extern int q1_numsurfedges;
|
extern int q1_numsurfedges;
|
||||||
extern int *q1_dsurfedges;//[MAX_MAP_SURFEDGES];
|
extern int *q1_dsurfedges;//[MAX_MAP_SURFEDGES];
|
||||||
|
|
||||||
|
|
||||||
void Q1_AllocMaxBSP(void);
|
void Q1_AllocMaxBSP(void);
|
||||||
void Q1_FreeMaxBSP(void);
|
void Q1_FreeMaxBSP(void);
|
||||||
void Q1_LoadBSPFile(char *filename, int offset, int length);
|
void Q1_LoadBSPFile(char *filename, int offset, int length);
|
||||||
void Q1_WriteBSPFile(char *filename);
|
void Q1_WriteBSPFile(char *filename);
|
||||||
void Q1_PrintBSPFileSizes(void);
|
void Q1_PrintBSPFileSizes(void);
|
||||||
void Q1_ParseEntities(void);
|
void Q1_ParseEntities(void);
|
||||||
void Q1_UnparseEntities(void);
|
void Q1_UnparseEntities(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
2268
code/bspc/l_bsp_q2.c
2268
code/bspc/l_bsp_q2.c
File diff suppressed because it is too large
Load diff
|
|
@ -1,98 +1,98 @@
|
||||||
/*
|
/*
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Copyright (C) 1999-2005 Id Software, Inc.
|
Copyright (C) 1999-2005 Id Software, Inc.
|
||||||
|
|
||||||
This file is part of Quake III Arena source code.
|
This file is part of Quake III Arena source code.
|
||||||
|
|
||||||
Quake III Arena source code is free software; you can redistribute it
|
Quake III Arena source code is free software; you can redistribute it
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the License,
|
published by the Free Software Foundation; either version 2 of the License,
|
||||||
or (at your option) any later version.
|
or (at your option) any later version.
|
||||||
|
|
||||||
Quake III Arena source code is distributed in the hope that it will be
|
Quake III Arena source code is distributed in the hope that it will be
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Foobar; if not, write to the Free Software
|
along with Foobar; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
===========================================================================
|
===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef ME
|
#ifndef ME
|
||||||
#define ME
|
#define ME
|
||||||
#endif //ME
|
#endif //ME
|
||||||
|
|
||||||
extern int nummodels;
|
extern int nummodels;
|
||||||
extern dmodel_t *dmodels;//[MAX_MAP_MODELS];
|
extern dmodel_t *dmodels;//[MAX_MAP_MODELS];
|
||||||
|
|
||||||
extern int visdatasize;
|
extern int visdatasize;
|
||||||
extern byte *dvisdata;//[MAX_MAP_VISIBILITY];
|
extern byte *dvisdata;//[MAX_MAP_VISIBILITY];
|
||||||
extern dvis_t *dvis;
|
extern dvis_t *dvis;
|
||||||
|
|
||||||
extern int lightdatasize;
|
extern int lightdatasize;
|
||||||
extern byte *dlightdata;//[MAX_MAP_LIGHTING];
|
extern byte *dlightdata;//[MAX_MAP_LIGHTING];
|
||||||
|
|
||||||
extern int entdatasize;
|
extern int entdatasize;
|
||||||
extern char *dentdata;//[MAX_MAP_ENTSTRING];
|
extern char *dentdata;//[MAX_MAP_ENTSTRING];
|
||||||
|
|
||||||
extern int numleafs;
|
extern int numleafs;
|
||||||
extern dleaf_t *dleafs;//[MAX_MAP_LEAFS];
|
extern dleaf_t *dleafs;//[MAX_MAP_LEAFS];
|
||||||
|
|
||||||
extern int numplanes;
|
extern int numplanes;
|
||||||
extern dplane_t *dplanes;//[MAX_MAP_PLANES];
|
extern dplane_t *dplanes;//[MAX_MAP_PLANES];
|
||||||
|
|
||||||
extern int numvertexes;
|
extern int numvertexes;
|
||||||
extern dvertex_t *dvertexes;//[MAX_MAP_VERTS];
|
extern dvertex_t *dvertexes;//[MAX_MAP_VERTS];
|
||||||
|
|
||||||
extern int numnodes;
|
extern int numnodes;
|
||||||
extern dnode_t *dnodes;//[MAX_MAP_NODES];
|
extern dnode_t *dnodes;//[MAX_MAP_NODES];
|
||||||
|
|
||||||
extern int numtexinfo;
|
extern int numtexinfo;
|
||||||
extern texinfo_t texinfo[MAX_MAP_TEXINFO];
|
extern texinfo_t texinfo[MAX_MAP_TEXINFO];
|
||||||
|
|
||||||
extern int numfaces;
|
extern int numfaces;
|
||||||
extern dface_t *dfaces;//[MAX_MAP_FACES];
|
extern dface_t *dfaces;//[MAX_MAP_FACES];
|
||||||
|
|
||||||
extern int numedges;
|
extern int numedges;
|
||||||
extern dedge_t *dedges;//[MAX_MAP_EDGES];
|
extern dedge_t *dedges;//[MAX_MAP_EDGES];
|
||||||
|
|
||||||
extern int numleaffaces;
|
extern int numleaffaces;
|
||||||
extern unsigned short *dleaffaces;//[MAX_MAP_LEAFFACES];
|
extern unsigned short *dleaffaces;//[MAX_MAP_LEAFFACES];
|
||||||
|
|
||||||
extern int numleafbrushes;
|
extern int numleafbrushes;
|
||||||
extern unsigned short *dleafbrushes;//[MAX_MAP_LEAFBRUSHES];
|
extern unsigned short *dleafbrushes;//[MAX_MAP_LEAFBRUSHES];
|
||||||
|
|
||||||
extern int numsurfedges;
|
extern int numsurfedges;
|
||||||
extern int *dsurfedges;//[MAX_MAP_SURFEDGES];
|
extern int *dsurfedges;//[MAX_MAP_SURFEDGES];
|
||||||
|
|
||||||
extern int numareas;
|
extern int numareas;
|
||||||
extern darea_t *dareas;//[MAX_MAP_AREAS];
|
extern darea_t *dareas;//[MAX_MAP_AREAS];
|
||||||
|
|
||||||
extern int numareaportals;
|
extern int numareaportals;
|
||||||
extern dareaportal_t *dareaportals;//[MAX_MAP_AREAPORTALS];
|
extern dareaportal_t *dareaportals;//[MAX_MAP_AREAPORTALS];
|
||||||
|
|
||||||
extern int numbrushes;
|
extern int numbrushes;
|
||||||
extern dbrush_t *dbrushes;//[MAX_MAP_BRUSHES];
|
extern dbrush_t *dbrushes;//[MAX_MAP_BRUSHES];
|
||||||
|
|
||||||
extern int numbrushsides;
|
extern int numbrushsides;
|
||||||
extern dbrushside_t *dbrushsides;//[MAX_MAP_BRUSHSIDES];
|
extern dbrushside_t *dbrushsides;//[MAX_MAP_BRUSHSIDES];
|
||||||
|
|
||||||
extern byte dpop[256];
|
extern byte dpop[256];
|
||||||
|
|
||||||
extern char brushsidetextured[MAX_MAP_BRUSHSIDES];
|
extern char brushsidetextured[MAX_MAP_BRUSHSIDES];
|
||||||
|
|
||||||
void Q2_AllocMaxBSP(void);
|
void Q2_AllocMaxBSP(void);
|
||||||
void Q2_FreeMaxBSP(void);
|
void Q2_FreeMaxBSP(void);
|
||||||
|
|
||||||
void Q2_DecompressVis(byte *in, byte *decompressed);
|
void Q2_DecompressVis(byte *in, byte *decompressed);
|
||||||
int Q2_CompressVis(byte *vis, byte *dest);
|
int Q2_CompressVis(byte *vis, byte *dest);
|
||||||
|
|
||||||
void Q2_LoadBSPFile(char *filename, int offset, int length);
|
void Q2_LoadBSPFile(char *filename, int offset, int length);
|
||||||
void Q2_LoadBSPFileTexinfo(char *filename); // just for qdata
|
void Q2_LoadBSPFileTexinfo(char *filename); // just for qdata
|
||||||
void Q2_WriteBSPFile(char *filename);
|
void Q2_WriteBSPFile(char *filename);
|
||||||
void Q2_PrintBSPFileSizes(void);
|
void Q2_PrintBSPFileSizes(void);
|
||||||
void Q2_ParseEntities(void);
|
void Q2_ParseEntities(void);
|
||||||
void Q2_UnparseEntities(void);
|
void Q2_UnparseEntities(void);
|
||||||
|
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue