Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Jedi Outcast v055

Jedi Outcast v056

Jedi Outcast Release v1.0

Jedi Outcast Release v1.0

Jedi Outcast Patch v1.02

Jedi Outcast Patch v1.03

Jedi Outcast MP Patch v1.04

Jedi Outcast Release v1.0

Jedi Outcast Release v1.0

Jedi Academy Release

remove scc files

remove 3rd party libs
  • Loading branch information...
commit 0bedbf0e790ab3bd1c6434d725b41ee17102838d 0 parents
James Monroe authored committed
Showing with 35,485 additions and 0 deletions.
  1. BIN  CODE-mp/ALut.lib
  2. BIN  CODE-mp/Debug/HA312W32.DLL
  3. BIN  CODE-mp/Debug/JK2cgame/vc60.idb
  4. BIN  CODE-mp/Debug/JK2game/vc60.idb
  5. BIN  CODE-mp/Debug/SHW32.DLL
  6. BIN  CODE-mp/Debug/botlib.lib
  7. BIN  CODE-mp/Debug/botlib/vc60.idb
  8. BIN  CODE-mp/Debug/cgamex86.dll
  9. BIN  CODE-mp/Debug/cgamex86.lib
  10. BIN  CODE-mp/Debug/jk2/vc60.idb
  11. BIN  CODE-mp/Debug/jk2mp.exe
  12. BIN  CODE-mp/Debug/jk2mpgamex86.dll
  13. BIN  CODE-mp/Debug/jk2mpgamex86.lib
  14. BIN  CODE-mp/Debug/ui/vc60.idb
  15. BIN  CODE-mp/Debug/uix86.dll
  16. BIN  CODE-mp/Debug/uix86.lib
  17. +3 −0  CODE-mp/Default.SUP
  18. BIN  CODE-mp/EaxMan.dll
  19. BIN  CODE-mp/Final/JK2cgame/vc60.idb
  20. BIN  CODE-mp/Final/JK2game/vc60.idb
  21. BIN  CODE-mp/Final/OpenAL32.dll
  22. BIN  CODE-mp/Final/botlib.lib
  23. BIN  CODE-mp/Final/botlib/vc60.idb
  24. BIN  CODE-mp/Final/cgamex86.dll
  25. BIN  CODE-mp/Final/cgamex86.lib
  26. BIN  CODE-mp/Final/jk2/vc60.idb
  27. BIN  CODE-mp/Final/jk2/winquake.res
  28. BIN  CODE-mp/Final/jk2mp.exe
  29. BIN  CODE-mp/Final/jk2mpgamex86.dll
  30. BIN  CODE-mp/Final/jk2mpgamex86.lib
  31. BIN  CODE-mp/Final/ui/vc60.idb
  32. BIN  CODE-mp/Final/uix86.dll
  33. BIN  CODE-mp/Final/uix86.lib
  34. BIN  CODE-mp/OpenAL32.dll
  35. BIN  CODE-mp/OpenAL32.lib
  36. BIN  CODE-mp/Release/Dedicated/vc60.idb
  37. BIN  CODE-mp/Release/JK2cgame/vc60.idb
  38. BIN  CODE-mp/Release/JK2game/vc60.idb
  39. BIN  CODE-mp/Release/botlib.lib
  40. BIN  CODE-mp/Release/botlib/vc60.idb
  41. BIN  CODE-mp/Release/cgamex86.dll
  42. BIN  CODE-mp/Release/cgamex86.lib
  43. BIN  CODE-mp/Release/jk2/vc60.idb
  44. BIN  CODE-mp/Release/jk2/winquake.res
  45. BIN  CODE-mp/Release/jk2Ded.exe
  46. BIN  CODE-mp/Release/jk2mp.exe
  47. BIN  CODE-mp/Release/jk2mpgamex86.dll
  48. BIN  CODE-mp/Release/jk2mpgamex86.lib
  49. BIN  CODE-mp/Release/ui/vc60.idb
  50. BIN  CODE-mp/Release/uix86.dll
  51. BIN  CODE-mp/Release/uix86.lib
  52. +156 −0 CODE-mp/Splines/Splines.dsp
  53. +129 −0 CODE-mp/Splines/math_angles.cpp
  54. +174 −0 CODE-mp/Splines/math_angles.h
  55. +113 −0 CODE-mp/Splines/math_matrix.cpp
  56. +202 −0 CODE-mp/Splines/math_matrix.h
  57. +57 −0 CODE-mp/Splines/math_quaternion.cpp
  58. +169 −0 CODE-mp/Splines/math_quaternion.h
  59. +123 −0 CODE-mp/Splines/math_vector.cpp
  60. +553 −0 CODE-mp/Splines/math_vector.h
  61. +514 −0 CODE-mp/Splines/q_parse.cpp
  62. +955 −0 CODE-mp/Splines/q_shared.cpp
  63. +789 −0 CODE-mp/Splines/q_shared.h
  64. +1,226 −0 CODE-mp/Splines/splines.cpp
  65. +1,061 −0 CODE-mp/Splines/splines.h
  66. +325 −0 CODE-mp/Splines/util_list.h
  67. +598 −0 CODE-mp/Splines/util_str.cpp
  68. +796 −0 CODE-mp/Splines/util_str.h
  69. +779 −0 CODE-mp/WinDed.dsp
  70. +358 −0 CODE-mp/WinDed.plg
  71. +810 −0 CODE-mp/base/games.log
  72. +408 −0 CODE-mp/base/jk2mpconfig.cfg
  73. +351 −0 CODE-mp/base/qconsole.log
  74. BIN  CODE-mp/base/screenshots/shot0000.jpg
  75. +17 −0 CODE-mp/base/server.cfg
  76. +1,597 −0 CODE-mp/base/vm/cgame.map
  77. BIN  CODE-mp/base/vm/cgame.qvm
  78. +1,602 −0 CODE-mp/base/vm/jk2mpgame.map
  79. BIN  CODE-mp/base/vm/jk2mpgame.qvm
  80. +1,011 −0 CODE-mp/base/vm/ui.map
  81. BIN  CODE-mp/base/vm/ui.qvm
  82. +246 −0 CODE-mp/botlib/aasfile.h
  83. +72 −0 CODE-mp/botlib/be_aas_bsp.h
  84. +470 −0 CODE-mp/botlib/be_aas_bspq3.cpp
  85. +1,528 −0 CODE-mp/botlib/be_aas_cluster.cpp
  86. +21 −0 CODE-mp/botlib/be_aas_cluster.h
  87. +760 −0 CODE-mp/botlib/be_aas_debug.cpp
  88. +45 −0 CODE-mp/botlib/be_aas_debug.h
  89. +290 −0 CODE-mp/botlib/be_aas_def.h
  90. +420 −0 CODE-mp/botlib/be_aas_entity.cpp
  91. +46 −0 CODE-mp/botlib/be_aas_entity.h
  92. +565 −0 CODE-mp/botlib/be_aas_file.cpp
  93. +25 −0 CODE-mp/botlib/be_aas_file.h
  94. +30 −0 CODE-mp/botlib/be_aas_funcs.h
  95. +412 −0 CODE-mp/botlib/be_aas_main.cpp
  96. +44 −0 CODE-mp/botlib/be_aas_main.h
  97. +1,084 −0 CODE-mp/botlib/be_aas_move.cpp
  98. +54 −0 CODE-mp/botlib/be_aas_move.h
  99. +295 −0 CODE-mp/botlib/be_aas_optimize.cpp
  100. +16 −0 CODE-mp/botlib/be_aas_optimize.h
  101. +4,525 −0 CODE-mp/botlib/be_aas_reach.cpp
  102. +51 −0 CODE-mp/botlib/be_aas_reach.h
  103. +2,192 −0 CODE-mp/botlib/be_aas_route.cpp
  104. +50 −0 CODE-mp/botlib/be_aas_route.h
  105. +223 −0 CODE-mp/botlib/be_aas_routealt.cpp
  106. +23 −0 CODE-mp/botlib/be_aas_routealt.h
  107. +1,377 −0 CODE-mp/botlib/be_aas_sample.cpp
  108. +52 −0 CODE-mp/botlib/be_aas_sample.h
  109. +773 −0 CODE-mp/botlib/be_ai_char.cpp
  110. +3,000 −0 CODE-mp/botlib/be_ai_chat.cpp
  111. +117 −0 CODE-mp/botlib/be_ai_gen.cpp
  112. +1,803 −0 CODE-mp/botlib/be_ai_goal.cpp
Sorry, we could not display the entire diff because too many files (1,835) changed.
BIN  CODE-mp/ALut.lib
Binary file not shown
BIN  CODE-mp/Debug/HA312W32.DLL
Binary file not shown
BIN  CODE-mp/Debug/JK2cgame/vc60.idb
Binary file not shown
BIN  CODE-mp/Debug/JK2game/vc60.idb
Binary file not shown
BIN  CODE-mp/Debug/SHW32.DLL
Binary file not shown
BIN  CODE-mp/Debug/botlib.lib
Binary file not shown
BIN  CODE-mp/Debug/botlib/vc60.idb
Binary file not shown
BIN  CODE-mp/Debug/cgamex86.dll
Binary file not shown
BIN  CODE-mp/Debug/cgamex86.lib
Binary file not shown
BIN  CODE-mp/Debug/jk2/vc60.idb
Binary file not shown
BIN  CODE-mp/Debug/jk2mp.exe
Binary file not shown
BIN  CODE-mp/Debug/jk2mpgamex86.dll
Binary file not shown
BIN  CODE-mp/Debug/jk2mpgamex86.lib
Binary file not shown
BIN  CODE-mp/Debug/ui/vc60.idb
Binary file not shown
BIN  CODE-mp/Debug/uix86.dll
Binary file not shown
BIN  CODE-mp/Debug/uix86.lib
Binary file not shown
3  CODE-mp/Default.SUP
@@ -0,0 +1,3 @@
+//SUPPRESSIONPROJ:Default
+//VERSION:5.00
+//ENABLE:Yes
BIN  CODE-mp/EaxMan.dll
Binary file not shown
BIN  CODE-mp/Final/JK2cgame/vc60.idb
Binary file not shown
BIN  CODE-mp/Final/JK2game/vc60.idb
Binary file not shown
BIN  CODE-mp/Final/OpenAL32.dll
Binary file not shown
BIN  CODE-mp/Final/botlib.lib
Binary file not shown
BIN  CODE-mp/Final/botlib/vc60.idb
Binary file not shown
BIN  CODE-mp/Final/cgamex86.dll
Binary file not shown
BIN  CODE-mp/Final/cgamex86.lib
Binary file not shown
BIN  CODE-mp/Final/jk2/vc60.idb
Binary file not shown
BIN  CODE-mp/Final/jk2/winquake.res
Binary file not shown
BIN  CODE-mp/Final/jk2mp.exe
Binary file not shown
BIN  CODE-mp/Final/jk2mpgamex86.dll
Binary file not shown
BIN  CODE-mp/Final/jk2mpgamex86.lib
Binary file not shown
BIN  CODE-mp/Final/ui/vc60.idb
Binary file not shown
BIN  CODE-mp/Final/uix86.dll
Binary file not shown
BIN  CODE-mp/Final/uix86.lib
Binary file not shown
BIN  CODE-mp/OpenAL32.dll
Binary file not shown
BIN  CODE-mp/OpenAL32.lib
Binary file not shown
BIN  CODE-mp/Release/Dedicated/vc60.idb
Binary file not shown
BIN  CODE-mp/Release/JK2cgame/vc60.idb
Binary file not shown
BIN  CODE-mp/Release/JK2game/vc60.idb
Binary file not shown
BIN  CODE-mp/Release/botlib.lib
Binary file not shown
BIN  CODE-mp/Release/botlib/vc60.idb
Binary file not shown
BIN  CODE-mp/Release/cgamex86.dll
Binary file not shown
BIN  CODE-mp/Release/cgamex86.lib
Binary file not shown
BIN  CODE-mp/Release/jk2/vc60.idb
Binary file not shown
BIN  CODE-mp/Release/jk2/winquake.res
Binary file not shown
BIN  CODE-mp/Release/jk2Ded.exe
Binary file not shown
BIN  CODE-mp/Release/jk2mp.exe
Binary file not shown
BIN  CODE-mp/Release/jk2mpgamex86.dll
Binary file not shown
BIN  CODE-mp/Release/jk2mpgamex86.lib
Binary file not shown
BIN  CODE-mp/Release/ui/vc60.idb
Binary file not shown
BIN  CODE-mp/Release/uix86.dll
Binary file not shown
BIN  CODE-mp/Release/uix86.lib
Binary file not shown
156 CODE-mp/Splines/Splines.dsp
@@ -0,0 +1,156 @@
+# Microsoft Developer Studio Project File - Name="Splines" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Static Library" 0x0104
+
+CFG=Splines - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "Splines.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "Splines.mak" CFG="Splines - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "Splines - Win32 Release" (based on "Win32 (x86) Static Library")
+!MESSAGE "Splines - Win32 Debug" (based on "Win32 (x86) Static Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""$/General/code/Splines", GAAAAAAA"
+# PROP Scc_LocalPath "."
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "Splines - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ELSEIF "$(CFG)" == "Splines - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /YX /FD /GZ /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ENDIF
+
+# Begin Target
+
+# Name "Splines - Win32 Release"
+# Name "Splines - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\math_angles.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\math_matrix.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\math_quaternion.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\math_vector.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\q_parse.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\q_shared.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\splines.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\util_str.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\math_angles.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\math_matrix.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\math_quaternion.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\math_vector.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\q_shared.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\splines.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\util_list.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\util_str.h
+# End Source File
+# End Group
+# End Target
+# End Project
129 CODE-mp/Splines/math_angles.cpp
@@ -0,0 +1,129 @@
+#include "q_shared.h"
+#include <float.h>
+
+angles_t ang_zero( 0.0f, 0.0f, 0.0f );
+
+void toAngles( mat3_t &src, angles_t &dst ) {
+ double theta;
+ double cp;
+ double sp;
+
+ sp = src[ 0 ][ 2 ];
+
+ // cap off our sin value so that we don't get any NANs
+ if ( sp > 1.0 ) {
+ sp = 1.0;
+ } else if ( sp < -1.0 ) {
+ sp = -1.0;
+ }
+
+ theta = -asin( sp );
+ cp = cos( theta );
+
+ if ( cp > 8192 * FLT_EPSILON ) {
+ dst.pitch = theta * 180 / M_PI;
+ dst.yaw = atan2( src[ 0 ][ 1 ], src[ 0 ][ 0 ] ) * 180 / M_PI;
+ dst.roll = atan2( src[ 1 ][ 2 ], src[ 2 ][ 2 ] ) * 180 / M_PI;
+ } else {
+ dst.pitch = theta * 180 / M_PI;
+ dst.yaw = -atan2( src[ 1 ][ 0 ], src[ 1 ][ 1 ] ) * 180 / M_PI;
+ dst.roll = 0;
+ }
+}
+
+void toAngles( quat_t &src, angles_t &dst ) {
+ mat3_t temp;
+
+ toMatrix( src, temp );
+ toAngles( temp, dst );
+}
+
+void toAngles( idVec3_t &src, angles_t &dst ) {
+ dst.pitch = src[ 0 ];
+ dst.yaw = src[ 1 ];
+ dst.roll = src[ 2 ];
+}
+
+void angles_t::toVectors( idVec3_t *forward, idVec3_t *right, idVec3_t *up ) {
+ float angle;
+ static float sr, sp, sy, cr, cp, cy; // static to help MS compiler fp bugs
+
+ angle = yaw * ( M_PI * 2 / 360 );
+ sy = sin( angle );
+ cy = cos( angle );
+
+ angle = pitch * ( M_PI * 2 / 360 );
+ sp = sin( angle );
+ cp = cos( angle );
+
+ angle = roll * ( M_PI * 2 / 360 );
+ sr = sin( angle );
+ cr = cos( angle );
+
+ if ( forward ) {
+ forward->set( cp * cy, cp * sy, -sp );
+ }
+
+ if ( right ) {
+ right->set( -sr * sp * cy + cr * sy, -sr * sp * sy + -cr * cy, -sr * cp );
+ }
+
+ if ( up ) {
+ up->set( cr * sp * cy + -sr * -sy, cr * sp * sy + -sr * cy, cr * cp );
+ }
+}
+
+idVec3_t angles_t::toForward( void ) {
+ float angle;
+ static float sp, sy, cp, cy; // static to help MS compiler fp bugs
+
+ angle = yaw * ( M_PI * 2 / 360 );
+ sy = sin( angle );
+ cy = cos( angle );
+
+ angle = pitch * ( M_PI * 2 / 360 );
+ sp = sin( angle );
+ cp = cos( angle );
+
+ return idVec3_t( cp * cy, cp * sy, -sp );
+}
+
+/*
+=================
+Normalize360
+
+returns angles normalized to the range [0 <= angle < 360]
+=================
+*/
+angles_t& angles_t::Normalize360( void ) {
+ pitch = (360.0 / 65536) * ( ( int )( pitch * ( 65536 / 360.0 ) ) & 65535 );
+ yaw = (360.0 / 65536) * ( ( int )( yaw * ( 65536 / 360.0 ) ) & 65535 );
+ roll = (360.0 / 65536) * ( ( int )( roll * ( 65536 / 360.0 ) ) & 65535 );
+
+ return *this;
+}
+
+
+/*
+=================
+Normalize180
+
+returns angles normalized to the range [-180 < angle <= 180]
+=================
+*/
+angles_t& angles_t::Normalize180( void ) {
+ Normalize360();
+
+ if ( pitch > 180.0 ) {
+ pitch -= 360.0;
+ }
+
+ if ( yaw > 180.0 ) {
+ yaw -= 360.0;
+ }
+
+ if ( roll > 180.0 ) {
+ roll -= 360.0;
+ }
+ return *this;
+}
174 CODE-mp/Splines/math_angles.h
@@ -0,0 +1,174 @@
+#ifndef __MATH_ANGLES_H__
+#define __MATH_ANGLES_H__
+
+#include <stdlib.h>
+#include <assert.h>
+
+#include "math_vector.h"
+
+class mat3_t;
+class quat_t;
+class idVec3_t;
+typedef idVec3_t &vec3_p;
+
+class angles_t {
+public:
+ float pitch;
+ float yaw;
+ float roll;
+
+ angles_t();
+ angles_t( float pitch, float yaw, float roll );
+ angles_t( const idVec3_t &vec );
+
+ friend void toAngles( idVec3_t &src, angles_t &dst );
+ friend void toAngles( quat_t &src, angles_t &dst );
+ friend void toAngles( mat3_t &src, angles_t &dst );
+
+ operator vec3_p();
+
+ float operator[]( int index ) const;
+ float& operator[]( int index );
+
+ void set( float pitch, float yaw, float roll );
+
+ void operator=( angles_t const &a );
+ void operator=( idVec3_t const &a );
+
+ friend angles_t operator+( const angles_t &a, const angles_t &b );
+ angles_t &operator+=( angles_t const &a );
+ angles_t &operator+=( idVec3_t const &a );
+
+ friend angles_t operator-( angles_t &a, angles_t &b );
+ angles_t &operator-=( angles_t &a );
+
+ friend angles_t operator*( const angles_t &a, float b );
+ friend angles_t operator*( float a, const angles_t &b );
+ angles_t &operator*=( float a );
+
+ friend int operator==( angles_t &a, angles_t &b );
+
+ friend int operator!=( angles_t &a, angles_t &b );
+
+ void toVectors( idVec3_t *forward, idVec3_t *right = NULL, idVec3_t *up = NULL );
+ idVec3_t toForward( void );
+
+ angles_t &Zero( void );
+
+ angles_t &Normalize360( void );
+ angles_t &Normalize180( void );
+};
+
+extern angles_t ang_zero;
+
+inline angles_t::angles_t() {}
+
+inline angles_t::angles_t( float pitch, float yaw, float roll ) {
+ this->pitch = pitch;
+ this->yaw = yaw;
+ this->roll = roll;
+}
+
+inline angles_t::angles_t( const idVec3_t &vec ) {
+ this->pitch = vec.x;
+ this->yaw = vec.y;
+ this->roll = vec.z;
+}
+
+inline float angles_t::operator[]( int index ) const {
+ assert( ( index >= 0 ) && ( index < 3 ) );
+ return ( &pitch )[ index ];
+}
+
+inline float& angles_t::operator[]( int index ) {
+ assert( ( index >= 0 ) && ( index < 3 ) );
+ return ( &pitch )[ index ];
+}
+
+inline angles_t::operator vec3_p( void ) {
+ return *( idVec3_t * )&pitch;
+}
+
+inline void angles_t::set( float pitch, float yaw, float roll ) {
+ this->pitch = pitch;
+ this->yaw = yaw;
+ this->roll = roll;
+}
+
+inline void angles_t::operator=( angles_t const &a ) {
+ pitch = a.pitch;
+ yaw = a.yaw;
+ roll = a.roll;
+}
+
+inline void angles_t::operator=( idVec3_t const &a ) {
+ pitch = a[ 0 ];
+ yaw = a[ 1 ];
+ roll = a[ 2 ];
+}
+
+inline angles_t operator+( const angles_t &a, const angles_t &b ) {
+ return angles_t( a.pitch + b.pitch, a.yaw + b.yaw, a.roll + b.roll );
+}
+
+inline angles_t& angles_t::operator+=( angles_t const &a ) {
+ pitch += a.pitch;
+ yaw += a.yaw;
+ roll += a.roll;
+
+ return *this;
+}
+
+inline angles_t& angles_t::operator+=( idVec3_t const &a ) {
+ pitch += a.x;
+ yaw += a.y;
+ roll += a.z;
+
+ return *this;
+}
+
+inline angles_t operator-( angles_t &a, angles_t &b ) {
+ return angles_t( a.pitch - b.pitch, a.yaw - b.yaw, a.roll - b.roll );
+}
+
+inline angles_t& angles_t::operator-=( angles_t &a ) {
+ pitch -= a.pitch;
+ yaw -= a.yaw;
+ roll -= a.roll;
+
+ return *this;
+}
+
+inline angles_t operator*( const angles_t &a, float b ) {
+ return angles_t( a.pitch * b, a.yaw * b, a.roll * b );
+}
+
+inline angles_t operator*( float a, const angles_t &b ) {
+ return angles_t( a * b.pitch, a * b.yaw, a * b.roll );
+}
+
+inline angles_t& angles_t::operator*=( float a ) {
+ pitch *= a;
+ yaw *= a;
+ roll *= a;
+
+ return *this;
+}
+
+inline int operator==( angles_t &a, angles_t &b ) {
+ return ( ( a.pitch == b.pitch ) && ( a.yaw == b.yaw ) && ( a.roll == b.roll ) );
+}
+
+inline int operator!=( angles_t &a, angles_t &b ) {
+ return ( ( a.pitch != b.pitch ) || ( a.yaw != b.yaw ) || ( a.roll != b.roll ) );
+}
+
+inline angles_t& angles_t::Zero( void ) {
+ pitch = 0.0f;
+ yaw = 0.0f;
+ roll = 0.0f;
+
+ return *this;
+}
+
+#endif /* !__MATH_ANGLES_H__ */
113 CODE-mp/Splines/math_matrix.cpp
@@ -0,0 +1,113 @@
+#include "q_shared.h"
+
+mat3_t mat3_default( idVec3_t( 1, 0, 0 ), idVec3_t( 0, 1, 0 ), idVec3_t( 0, 0, 1 ) );
+
+void toMatrix( quat_t const &src, mat3_t &dst ) {
+ float wx, wy, wz;
+ float xx, yy, yz;
+ float xy, xz, zz;
+ float x2, y2, z2;
+
+ x2 = src.x + src.x;
+ y2 = src.y + src.y;
+ z2 = src.z + src.z;
+
+ xx = src.x * x2;
+ xy = src.x * y2;
+ xz = src.x * z2;
+
+ yy = src.y * y2;
+ yz = src.y * z2;
+ zz = src.z * z2;
+
+ wx = src.w * x2;
+ wy = src.w * y2;
+ wz = src.w * z2;
+
+ dst[ 0 ][ 0 ] = 1.0f - ( yy + zz );
+ dst[ 0 ][ 1 ] = xy - wz;
+ dst[ 0 ][ 2 ] = xz + wy;
+
+ dst[ 1 ][ 0 ] = xy + wz;
+ dst[ 1 ][ 1 ] = 1.0f - ( xx + zz );
+ dst[ 1 ][ 2 ] = yz - wx;
+
+ dst[ 2 ][ 0 ] = xz - wy;
+ dst[ 2 ][ 1 ] = yz + wx;
+ dst[ 2 ][ 2 ] = 1.0f - ( xx + yy );
+}
+
+void toMatrix( angles_t const &src, mat3_t &dst ) {
+ float angle;
+ static float sr, sp, sy, cr, cp, cy; // static to help MS compiler fp bugs
+
+ angle = src.yaw * ( M_PI * 2.0f / 360.0f );
+ sy = sin( angle );
+ cy = cos( angle );
+
+ angle = src.pitch * ( M_PI * 2.0f / 360.0f );
+ sp = sin( angle );
+ cp = cos( angle );
+
+ angle = src.roll * ( M_PI * 2.0f / 360.0f );
+ sr = sin( angle );
+ cr = cos( angle );
+
+ dst[ 0 ].set( cp * cy, cp * sy, -sp );
+ dst[ 1 ].set( sr * sp * cy + cr * -sy, sr * sp * sy + cr * cy, sr * cp );
+ dst[ 2 ].set( cr * sp * cy + -sr * -sy, cr * sp * sy + -sr * cy, cr * cp );
+}
+
+void toMatrix( idVec3_t const &src, mat3_t &dst ) {
+ angles_t sup = src;
+ toMatrix(sup, dst);
+}
+
+void mat3_t::ProjectVector( const idVec3_t &src, idVec3_t &dst ) const {
+ dst.x = src * mat[ 0 ];
+ dst.y = src * mat[ 1 ];
+ dst.z = src * mat[ 2 ];
+}
+
+void mat3_t::UnprojectVector( const idVec3_t &src, idVec3_t &dst ) const {
+ dst = mat[ 0 ] * src.x + mat[ 1 ] * src.y + mat[ 2 ] * src.z;
+}
+
+void mat3_t::Transpose( mat3_t &matrix ) {
+ int i;
+ int j;
+
+ for( i = 0; i < 3; i++ ) {
+ for( j = 0; j < 3; j++ ) {
+ matrix[ i ][ j ] = mat[ j ][ i ];
+ }
+ }
+}
+
+void mat3_t::Transpose( void ) {
+ float temp;
+ int i;
+ int j;
+
+ for( i = 0; i < 3; i++ ) {
+ for( j = i + 1; j < 3; j++ ) {
+ temp = mat[ i ][ j ];
+ mat[ i ][ j ] = mat[ j ][ i ];
+ mat[ j ][ i ] = temp;
+ }
+ }
+}
+
+mat3_t mat3_t::Inverse( void ) const {
+ mat3_t inv( *this );
+
+ inv.Transpose();
+
+ return inv;
+}
+
+void mat3_t::Clear( void ) {
+ mat[0].set( 1, 0, 0 );
+ mat[1].set( 0, 1, 0 );
+ mat[2].set( 0, 0, 1 );
+}
202 CODE-mp/Splines/math_matrix.h
@@ -0,0 +1,202 @@
+#ifndef __MATH_MATRIX_H__
+#define __MATH_MATRIX_H__
+
+#include <string.h>
+#include "math_vector.h"
+
+#ifndef ID_INLINE
+#ifdef _WIN32
+#define ID_INLINE __inline
+#else
+#define ID_INLINE inline
+#endif
+#endif
+
+class quat_t;
+class angles_t;
+
+class mat3_t {
+public:
+ idVec3_t mat[ 3 ];
+
+ mat3_t();
+ mat3_t( float src[ 3 ][ 3 ] );
+ mat3_t( idVec3_t const &x, idVec3_t const &y, idVec3_t const &z );
+ mat3_t( const float xx, const float xy, const float xz, const float yx, const float yy, const float yz, const float zx, const float zy, const float zz );
+
+ friend void toMatrix( quat_t const &src, mat3_t &dst );
+ friend void toMatrix( angles_t const &src, mat3_t &dst );
+ friend void toMatrix( idVec3_t const &src, mat3_t &dst );
+
+ idVec3_t operator[]( int index ) const;
+ idVec3_t &operator[]( int index );
+
+ idVec3_t operator*( const idVec3_t &vec ) const;
+ mat3_t operator*( const mat3_t &a ) const;
+ mat3_t operator*( float a ) const;
+ mat3_t operator+( mat3_t const &a ) const;
+ mat3_t operator-( mat3_t const &a ) const;
+
+ friend idVec3_t operator*( const idVec3_t &vec, const mat3_t &mat );
+ friend mat3_t operator*( float a, mat3_t const &b );
+
+ mat3_t &operator*=( float a );
+ mat3_t &operator+=( mat3_t const &a );
+ mat3_t &operator-=( mat3_t const &a );
+
+ void Clear( void );
+
+ void ProjectVector( const idVec3_t &src, idVec3_t &dst ) const;
+ void UnprojectVector( const idVec3_t &src, idVec3_t &dst ) const;
+
+ void OrthoNormalize( void );
+ void Transpose( mat3_t &matrix );
+ void Transpose( void );
+ mat3_t Inverse( void ) const;
+ void Identity( void );
+
+ friend void InverseMultiply( const mat3_t &inv, const mat3_t &b, mat3_t &dst );
+ friend mat3_t SkewSymmetric( idVec3_t const &src );
+};
+
+ID_INLINE mat3_t::mat3_t() {
+}
+
+ID_INLINE mat3_t::mat3_t( float src[ 3 ][ 3 ] ) {
+ memcpy( mat, src, sizeof( src ) );
+}
+
+ID_INLINE mat3_t::mat3_t( idVec3_t const &x, idVec3_t const &y, idVec3_t const &z ) {
+ mat[ 0 ].x = x.x; mat[ 0 ].y = x.y; mat[ 0 ].z = x.z;
+ mat[ 1 ].x = y.x; mat[ 1 ].y = y.y; mat[ 1 ].z = y.z;
+ mat[ 2 ].x = z.x; mat[ 2 ].y = z.y; mat[ 2 ].z = z.z;
+}
+
+ID_INLINE mat3_t::mat3_t( const float xx, const float xy, const float xz, const float yx, const float yy, const float yz, const float zx, const float zy, const float zz ) {
+ mat[ 0 ].x = xx; mat[ 0 ].y = xy; mat[ 0 ].z = xz;
+ mat[ 1 ].x = yx; mat[ 1 ].y = yy; mat[ 1 ].z = yz;
+ mat[ 2 ].x = zx; mat[ 2 ].y = zy; mat[ 2 ].z = zz;
+}
+
+ID_INLINE idVec3_t mat3_t::operator[]( int index ) const {
+ assert( ( index >= 0 ) && ( index < 3 ) );
+ return mat[ index ];
+}
+
+ID_INLINE idVec3_t& mat3_t::operator[]( int index ) {
+ assert( ( index >= 0 ) && ( index < 3 ) );
+ return mat[ index ];
+}
+
+ID_INLINE idVec3_t mat3_t::operator*( const idVec3_t &vec ) const {
+ return idVec3_t(
+ mat[ 0 ].x * vec.x + mat[ 1 ].x * vec.y + mat[ 2 ].x * vec.z,
+ mat[ 0 ].y * vec.x + mat[ 1 ].y * vec.y + mat[ 2 ].y * vec.z,
+ mat[ 0 ].z * vec.x + mat[ 1 ].z * vec.y + mat[ 2 ].z * vec.z );
+}
+
+ID_INLINE mat3_t mat3_t::operator*( const mat3_t &a ) const {
+ return mat3_t(
+ mat[0].x * a[0].x + mat[0].y * a[1].x + mat[0].z * a[2].x,
+ mat[0].x * a[0].y + mat[0].y * a[1].y + mat[0].z * a[2].y,
+ mat[0].x * a[0].z + mat[0].y * a[1].z + mat[0].z * a[2].z,
+ mat[1].x * a[0].x + mat[1].y * a[1].x + mat[1].z * a[2].x,
+ mat[1].x * a[0].y + mat[1].y * a[1].y + mat[1].z * a[2].y,
+ mat[1].x * a[0].z + mat[1].y * a[1].z + mat[1].z * a[2].z,
+ mat[2].x * a[0].x + mat[2].y * a[1].x + mat[2].z * a[2].x,
+ mat[2].x * a[0].y + mat[2].y * a[1].y + mat[2].z * a[2].y,
+ mat[2].x * a[0].z + mat[2].y * a[1].z + mat[2].z * a[2].z );
+}
+
+ID_INLINE mat3_t mat3_t::operator*( float a ) const {
+ return mat3_t(
+ mat[0].x * a, mat[0].y * a, mat[0].z * a,
+ mat[1].x * a, mat[1].y * a, mat[1].z * a,
+ mat[2].x * a, mat[2].y * a, mat[2].z * a );
+}
+
+ID_INLINE mat3_t mat3_t::operator+( mat3_t const &a ) const {
+ return mat3_t(
+ mat[0].x + a[0].x, mat[0].y + a[0].y, mat[0].z + a[0].z,
+ mat[1].x + a[1].x, mat[1].y + a[1].y, mat[1].z + a[1].z,
+ mat[2].x + a[2].x, mat[2].y + a[2].y, mat[2].z + a[2].z );
+}
+
+ID_INLINE mat3_t mat3_t::operator-( mat3_t const &a ) const {
+ return mat3_t(
+ mat[0].x - a[0].x, mat[0].y - a[0].y, mat[0].z - a[0].z,
+ mat[1].x - a[1].x, mat[1].y - a[1].y, mat[1].z - a[1].z,
+ mat[2].x - a[2].x, mat[2].y - a[2].y, mat[2].z - a[2].z );
+}
+
+ID_INLINE idVec3_t operator*( const idVec3_t &vec, const mat3_t &mat ) {
+ return idVec3_t(
+ mat[ 0 ].x * vec.x + mat[ 1 ].x * vec.y + mat[ 2 ].x * vec.z,
+ mat[ 0 ].y * vec.x + mat[ 1 ].y * vec.y + mat[ 2 ].y * vec.z,
+ mat[ 0 ].z * vec.x + mat[ 1 ].z * vec.y + mat[ 2 ].z * vec.z );
+}
+
+ID_INLINE mat3_t operator*( float a, mat3_t const &b ) {
+ return mat3_t(
+ b[0].x * a, b[0].y * a, b[0].z * a,
+ b[1].x * a, b[1].y * a, b[1].z * a,
+ b[2].x * a, b[2].y * a, b[2].z * a );
+}
+
+ID_INLINE mat3_t &mat3_t::operator*=( float a ) {
+ mat[0].x *= a; mat[0].y *= a; mat[0].z *= a;
+ mat[1].x *= a; mat[1].y *= a; mat[1].z *= a;
+ mat[2].x *= a; mat[2].y *= a; mat[2].z *= a;
+
+ return *this;
+}
+
+ID_INLINE mat3_t &mat3_t::operator+=( mat3_t const &a ) {
+ mat[0].x += a[0].x; mat[0].y += a[0].y; mat[0].z += a[0].z;
+ mat[1].x += a[1].x; mat[1].y += a[1].y; mat[1].z += a[1].z;
+ mat[2].x += a[2].x; mat[2].y += a[2].y; mat[2].z += a[2].z;
+
+ return *this;
+}
+
+ID_INLINE mat3_t &mat3_t::operator-=( mat3_t const &a ) {
+ mat[0].x -= a[0].x; mat[0].y -= a[0].y; mat[0].z -= a[0].z;
+ mat[1].x -= a[1].x; mat[1].y -= a[1].y; mat[1].z -= a[1].z;
+ mat[2].x -= a[2].x; mat[2].y -= a[2].y; mat[2].z -= a[2].z;
+
+ return *this;
+}
+
+ID_INLINE void mat3_t::OrthoNormalize( void ) {
+ mat[ 0 ].Normalize();
+ mat[ 2 ].Cross( mat[ 0 ], mat[ 1 ] );
+ mat[ 2 ].Normalize();
+ mat[ 1 ].Cross( mat[ 2 ], mat[ 0 ] );
+ mat[ 1 ].Normalize();
+}
+
+ID_INLINE void mat3_t::Identity( void ) {
+ mat[ 0 ].x = 1.f; mat[ 0 ].y = 0.f; mat[ 0 ].z = 0.f;
+ mat[ 1 ].x = 0.f; mat[ 1 ].y = 1.f; mat[ 1 ].z = 0.f;
+ mat[ 2 ].x = 0.f; mat[ 2 ].y = 0.f; mat[ 2 ].z = 1.f;
+}
+
+ID_INLINE void InverseMultiply( const mat3_t &inv, const mat3_t &b, mat3_t &dst ) {
+ dst[0].x = inv[0].x * b[0].x + inv[1].x * b[1].x + inv[2].x * b[2].x;
+ dst[0].y = inv[0].x * b[0].y + inv[1].x * b[1].y + inv[2].x * b[2].y;
+ dst[0].z = inv[0].x * b[0].z + inv[1].x * b[1].z + inv[2].x * b[2].z;
+ dst[1].x = inv[0].y * b[0].x + inv[1].y * b[1].x + inv[2].y * b[2].x;
+ dst[1].y = inv[0].y * b[0].y + inv[1].y * b[1].y + inv[2].y * b[2].y;
+ dst[1].z = inv[0].y * b[0].z + inv[1].y * b[1].z + inv[2].y * b[2].z;
+ dst[2].x = inv[0].z * b[0].x + inv[1].z * b[1].x + inv[2].z * b[2].x;
+ dst[2].y = inv[0].z * b[0].y + inv[1].z * b[1].y + inv[2].z * b[2].y;
+ dst[2].z = inv[0].z * b[0].z + inv[1].z * b[1].z + inv[2].z * b[2].z;
+}
+
+ID_INLINE mat3_t SkewSymmetric( idVec3_t const &src ) {
+ return mat3_t( 0.0f, -src.z, src.y, src.z, 0.0f, -src.x, -src.y, src.x, 0.0f );
+}
+
+extern mat3_t mat3_default;
+
+#endif /* !__MATH_MATRIX_H__ */
57 CODE-mp/Splines/math_quaternion.cpp
@@ -0,0 +1,57 @@
+#include "math_quaternion.h"
+#include "math_matrix.h"
+
+void toQuat( idVec3_t &src, quat_t &dst ) {
+ dst.x = src.x;
+ dst.y = src.y;
+ dst.z = src.z;
+ dst.w = 0.0f;
+}
+
+void toQuat( angles_t &src, quat_t &dst ) {
+ mat3_t temp;
+
+ toMatrix( src, temp );
+ toQuat( temp, dst );
+}
+
+void toQuat( mat3_t &src, quat_t &dst ) {
+ float trace;
+ float s;
+ int i;
+ int j;
+ int k;
+
+ static int next[ 3 ] = { 1, 2, 0 };
+
+ trace = src[ 0 ][ 0 ] + src[ 1 ][ 1 ] + src[ 2 ][ 2 ];
+ if ( trace > 0.0f ) {
+ s = ( float )sqrt( trace + 1.0f );
+ dst.w = s * 0.5f;
+ s = 0.5f / s;
+
+ dst.x = ( src[ 2 ][ 1 ] - src[ 1 ][ 2 ] ) * s;
+ dst.y = ( src[ 0 ][ 2 ] - src[ 2 ][ 0 ] ) * s;
+ dst.z = ( src[ 1 ][ 0 ] - src[ 0 ][ 1 ] ) * s;
+ } else {
+ i = 0;
+ if ( src[ 1 ][ 1 ] > src[ 0 ][ 0 ] ) {
+ i = 1;
+ }
+ if ( src[ 2 ][ 2 ] > src[ i ][ i ] ) {
+ i = 2;
+ }
+
+ j = next[ i ];
+ k = next[ j ];
+
+ s = ( float )sqrt( ( src[ i ][ i ] - ( src[ j ][ j ] + src[ k ][ k ] ) ) + 1.0f );
+ dst[ i ] = s * 0.5f;
+
+ s = 0.5f / s;
+
+ dst.w = ( src[ k ][ j ] - src[ j ][ k ] ) * s;
+ dst[ j ] = ( src[ j ][ i ] + src[ i ][ j ] ) * s;
+ dst[ k ] = ( src[ k ][ i ] + src[ i ][ k ] ) * s;
+ }
+}
169 CODE-mp/Splines/math_quaternion.h
@@ -0,0 +1,169 @@
+#ifndef __MATH_QUATERNION_H__
+#define __MATH_QUATERNION_H__
+
+#include <assert.h>
+#include <math.h>
+
+class idVec3_t;
+class angles_t;
+class mat3_t;
+
+class quat_t {
+public:
+ float x;
+ float y;
+ float z;
+ float w;
+
+ quat_t();
+ quat_t( float x, float y, float z, float w );
+
+ friend void toQuat( idVec3_t &src, quat_t &dst );
+ friend void toQuat( angles_t &src, quat_t &dst );
+ friend void toQuat( mat3_t &src, quat_t &dst );
+
+ float *vec4( void );
+
+ float operator[]( int index ) const;
+ float &operator[]( int index );
+
+ void set( float x, float y, float z, float w );
+
+ void operator=( quat_t a );
+
+ friend quat_t operator+( quat_t a, quat_t b );
+ quat_t &operator+=( quat_t a );
+
+ friend quat_t operator-( quat_t a, quat_t b );
+ quat_t &operator-=( quat_t a );
+
+ friend quat_t operator*( quat_t a, float b );
+ friend quat_t operator*( float a, quat_t b );
+ quat_t &operator*=( float a );
+
+ friend int operator==( quat_t a, quat_t b );
+ friend int operator!=( quat_t a, quat_t b );
+
+ float Length( void );
+ quat_t &Normalize( void );
+
+ quat_t operator-();
+};
+
+inline quat_t::quat_t() {
+}
+
+inline quat_t::quat_t( float x, float y, float z, float w ) {
+ this->x = x;
+ this->y = y;
+ this->z = z;
+ this->w = w;
+}
+
+inline float *quat_t::vec4( void ) {
+ return &x;
+}
+
+inline float quat_t::operator[]( int index ) const {
+ assert( ( index >= 0 ) && ( index < 4 ) );
+ return ( &x )[ index ];
+}
+
+inline float& quat_t::operator[]( int index ) {
+ assert( ( index >= 0 ) && ( index < 4 ) );
+ return ( &x )[ index ];
+}
+
+inline void quat_t::set( float x, float y, float z, float w ) {
+ this->x = x;
+ this->y = y;
+ this->z = z;
+ this->w = w;
+}
+
+inline void quat_t::operator=( quat_t a ) {
+ x = a.x;
+ y = a.y;
+ z = a.z;
+ w = a.w;
+}
+
+inline quat_t operator+( quat_t a, quat_t b ) {
+ return quat_t( a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w );
+}
+
+inline quat_t& quat_t::operator+=( quat_t a ) {
+ x += a.x;
+ y += a.y;
+ z += a.z;
+ w += a.w;
+
+ return *this;
+}
+
+inline quat_t operator-( quat_t a, quat_t b ) {
+ return quat_t( a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w );
+}
+
+inline quat_t& quat_t::operator-=( quat_t a ) {
+ x -= a.x;
+ y -= a.y;
+ z -= a.z;
+ w -= a.w;
+
+ return *this;
+}
+
+inline quat_t operator*( quat_t a, float b ) {
+ return quat_t( a.x * b, a.y * b, a.z * b, a.w * b );
+}
+
+inline quat_t operator*( float a, quat_t b ) {
+ return b * a;
+}
+
+inline quat_t& quat_t::operator*=( float a ) {
+ x *= a;
+ y *= a;
+ z *= a;
+ w *= a;
+
+ return *this;
+}
+
+inline int operator==( quat_t a, quat_t b ) {
+ return ( ( a.x == b.x ) && ( a.y == b.y ) && ( a.z == b.z ) && ( a.w == b.w ) );
+}
+
+inline int operator!=( quat_t a, quat_t b ) {
+ return ( ( a.x != b.x ) || ( a.y != b.y ) || ( a.z != b.z ) && ( a.w != b.w ) );
+}
+
+inline float quat_t::Length( void ) {
+ float length;
+
+ length = x * x + y * y + z * z + w * w;
+ return ( float )sqrt( length );
+}
+
+inline quat_t& quat_t::Normalize( void ) {
+ float length;
+ float ilength;
+
+ length = this->Length();
+ if ( length ) {
+ ilength = 1 / length;
+ x *= ilength;
+ y *= ilength;
+ z *= ilength;
+ w *= ilength;
+ }
+
+ return *this;
+}
+
+inline quat_t quat_t::operator-() {
+ return quat_t( -x, -y, -z, -w );
+}
+
+#endif /* !__MATH_QUATERNION_H__ */
123 CODE-mp/Splines/math_vector.cpp
@@ -0,0 +1,123 @@
+//#include "../game/q_shared.h"
+#include "math_vector.h"
+#include <assert.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <stdlib.h>
+#include <time.h>
+#include <ctype.h>
+
+#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h
+
+#define LERP_DELTA 1e-6
+
+idVec3_t vec_zero( 0.0f, 0.0f, 0.0f );
+
+Bounds boundsZero;
+
+float idVec3_t::toYaw( void ) {
+ float yaw;
+
+ if ( ( y == 0 ) && ( x == 0 ) ) {
+ yaw = 0;
+ } else {
+ yaw = atan2( y, x ) * 180 / M_PI;
+ if ( yaw < 0 ) {
+ yaw += 360;
+ }
+ }
+
+ return yaw;
+}
+
+float idVec3_t::toPitch( void ) {
+ float forward;
+ float pitch;
+
+ if ( ( x == 0 ) && ( y == 0 ) ) {
+ if ( z > 0 ) {
+ pitch = 90;
+ } else {
+ pitch = 270;
+ }
+ } else {
+ forward = ( float )idSqrt( x * x + y * y );
+ pitch = atan2( z, forward ) * 180 / M_PI;
+ if ( pitch < 0 ) {
+ pitch += 360;
+ }
+ }
+
+ return pitch;
+}
+
+/*
+angles_t idVec3_t::toAngles( void ) {
+ float forward;
+ float yaw;
+ float pitch;
+
+ if ( ( x == 0 ) && ( y == 0 ) ) {
+ yaw = 0;
+ if ( z > 0 ) {
+ pitch = 90;
+ } else {
+ pitch = 270;
+ }
+ } else {
+ yaw = atan2( y, x ) * 180 / M_PI;
+ if ( yaw < 0 ) {
+ yaw += 360;
+ }
+
+ forward = ( float )idSqrt( x * x + y * y );
+ pitch = atan2( z, forward ) * 180 / M_PI;
+ if ( pitch < 0 ) {
+ pitch += 360;
+ }
+ }
+
+ return angles_t( -pitch, yaw, 0 );
+}
+*/
+
+idVec3_t LerpVector( idVec3_t &w1, idVec3_t &w2, const float t ) {
+ float omega, cosom, sinom, scale0, scale1;
+
+ cosom = w1 * w2;
+ if ( ( 1.0 - cosom ) > LERP_DELTA ) {
+ omega = acos( cosom );
+ sinom = sin( omega );
+ scale0 = sin( ( 1.0 - t ) * omega ) / sinom;
+ scale1 = sin( t * omega ) / sinom;
+ } else {
+ scale0 = 1.0 - t;
+ scale1 = t;
+ }
+
+ return ( w1 * scale0 + w2 * scale1 );
+}
+
+/*
+=============
+idVec3_t::string
+
+This is just a convenience function
+for printing vectors
+=============
+*/
+char *idVec3_t::string( void ) {
+ static int index = 0;
+ static char str[ 8 ][ 36 ];
+ char *s;
+
+ // use an array so that multiple toString's won't collide
+ s = str[ index ];
+ index = (index + 1)&7;
+
+ sprintf( s, "%.2f %.2f %.2f", x, y, z );
+
+ return s;
+}
553 CODE-mp/Splines/math_vector.h
@@ -0,0 +1,553 @@
+#ifndef __MATH_VECTOR_H__
+#define __MATH_VECTOR_H__
+
+#if defined(_WIN32)
+#pragma warning(disable : 4244)
+#endif
+
+#include <math.h>
+#include <assert.h>
+
+//#define DotProduct(a,b) ((a)[0]*(b)[0]+(a)[1]*(b)[1]+(a)[2]*(b)[2])
+//#define VectorSubtract(a,b,c) ((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2])
+//#define VectorAdd(a,b,c) ((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2])
+//#define VectorCopy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2])
+//#define VectorCopy(a,b) ((b).x=(a).x,(b).y=(a).y,(b).z=(a).z])
+
+//#define VectorScale(v, s, o) ((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s))
+#define __VectorMA(v, s, b, o) ((o)[0]=(v)[0]+(b)[0]*(s),(o)[1]=(v)[1]+(b)[1]*(s),(o)[2]=(v)[2]+(b)[2]*(s))
+//#define CrossProduct(a,b,c) ((c)[0]=(a)[1]*(b)[2]-(a)[2]*(b)[1],(c)[1]=(a)[2]*(b)[0]-(a)[0]*(b)[2],(c)[2]=(a)[0]*(b)[1]-(a)[1]*(b)[0])
+
+#define DotProduct4(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2]+(x)[3]*(y)[3])
+#define VectorSubtract4(a,b,c) ((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2],(c)[3]=(a)[3]-(b)[3])
+#define VectorAdd4(a,b,c) ((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2],(c)[3]=(a)[3]+(b)[3])
+#define VectorCopy4(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])
+#define VectorScale4(v, s, o) ((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s),(o)[3]=(v)[3]*(s))
+#define VectorMA4(v, s, b, o) ((o)[0]=(v)[0]+(b)[0]*(s),(o)[1]=(v)[1]+(b)[1]*(s),(o)[2]=(v)[2]+(b)[2]*(s),(o)[3]=(v)[3]+(b)[3]*(s))
+
+
+//#define VectorClear(a) ((a)[0]=(a)[1]=(a)[2]=0)
+#define VectorNegate(a,b) ((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2])
+//#define VectorSet(v, x, y, z) ((v)[0]=(x), (v)[1]=(y), (v)[2]=(z))
+#define Vector4Copy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])
+
+#define SnapVector(v) {v[0]=(int)v[0];v[1]=(int)v[1];v[2]=(int)v[2];}
+
+
+//#include "util_heap.h"
+
+#ifndef EQUAL_EPSILON
+#define EQUAL_EPSILON 0.001
+#endif
+
+float Q_fabs( float f );
+
+#ifndef ID_INLINE
+#ifdef _WIN32
+#define ID_INLINE __inline
+#else
+#define ID_INLINE inline
+#endif
+#endif
+
+// if this is defined, vec3 will take four elements, which may allow
+// easier SIMD optimizations
+//#define FAT_VEC3
+//#ifdef __ppc__
+//#pragma align(16)
+//#endif
+
+class angles_t;
+#ifdef __ppc__
+// Vanilla PPC code, but since PPC has a reciprocal square root estimate instruction,
+// runs *much* faster than calling sqrt(). We'll use two Newton-Raphson
+// refinement steps to get bunch more precision in the 1/sqrt() value for very little cost.
+// We'll then multiply 1/sqrt times the original value to get the sqrt.
+// This is about 12.4 times faster than sqrt() and according to my testing (not exhaustive)
+// it returns fairly accurate results (error below 1.0e-5 up to 100000.0 in 0.1 increments).
+
+static inline float idSqrt(float x) {
+ const float half = 0.5;
+ const float one = 1.0;
+ float B, y0, y1;
+
+ // This'll NaN if it hits frsqrte. Handle both +0.0 and -0.0
+ if (fabs(x) == 0.0)
+ return x;
+ B = x;
+
+#ifdef __GNUC__
+ asm("frsqrte %0,%1" : "=f" (y0) : "f" (B));
+#else
+ y0 = __frsqrte(B);
+#endif
+ /* First refinement step */
+
+ y1 = y0 + half*y0*(one - B*y0*y0);
+
+ /* Second refinement step -- copy the output of the last step to the input of this step */
+
+ y0 = y1;
+ y1 = y0 + half*y0*(one - B*y0*y0);
+
+ /* Get sqrt(x) from x * 1/sqrt(x) */
+ return x * y1;
+}
+#else
+static inline double idSqrt(double x) {
+ return sqrt(x);
+}
+#endif
+
+
+//class idVec3_t : public idHeap<idVec3_t> {
+class idVec3_t {
+public:
+#ifndef FAT_VEC3
+ float x,y,z;
+#else
+ float x,y,z,dist;
+#endif
+
+#ifndef FAT_VEC3
+ idVec3_t() {};
+#else
+ idVec3_t() {dist = 0.0f;};
+#endif
+ idVec3_t( const float x, const float y, const float z );
+
+ operator float *();
+
+ float operator[]( const int index ) const;
+ float &operator[]( const int index );
+
+ void set( const float x, const float y, const float z );
+
+ idVec3_t operator-() const;
+
+ idVec3_t &operator=( const idVec3_t &a );
+
+ float operator*( const idVec3_t &a ) const;
+ idVec3_t operator*( const float a ) const;
+ friend idVec3_t operator*( float a, idVec3_t b );
+
+ idVec3_t operator+( const idVec3_t &a ) const;
+ idVec3_t operator-( const idVec3_t &a ) const;
+
+ idVec3_t &operator+=( const idVec3_t &a );
+ idVec3_t &operator-=( const idVec3_t &a );
+ idVec3_t &operator*=( const float a );
+
+ int operator==( const idVec3_t &a ) const;
+ int operator!=( const idVec3_t &a ) const;
+
+ idVec3_t Cross( const idVec3_t &a ) const;
+ idVec3_t &Cross( const idVec3_t &a, const idVec3_t &b );
+
+ float Length( void ) const;
+ float Normalize( void );
+
+ void Zero( void );
+ void Snap( void );
+ void SnapTowards( const idVec3_t &to );
+
+ float toYaw( void );
+ float toPitch( void );
+ angles_t toAngles( void );
+ friend idVec3_t LerpVector( const idVec3_t &w1, const idVec3_t &w2, const float t );
+
+ char *string( void );
+};
+
+extern idVec3_t vec_zero;
+
+ID_INLINE idVec3_t::idVec3_t( const float x, const float y, const float z ) {
+ this->x = x;
+ this->y = y;
+ this->z = z;
+#ifdef FAT_VEC3
+ this->dist = 0.0f;
+#endif
+}
+
+ID_INLINE float idVec3_t::operator[]( const int index ) const {
+ return ( &x )[ index ];
+}
+
+ID_INLINE float &idVec3_t::operator[]( const int index ) {
+ return ( &x )[ index ];
+}
+
+ID_INLINE idVec3_t::operator float *( void ) {
+ return &x;
+}
+
+ID_INLINE idVec3_t idVec3_t::operator-() const {
+ return idVec3_t( -x, -y, -z );
+}
+
+ID_INLINE idVec3_t &idVec3_t::operator=( const idVec3_t &a ) {
+ x = a.x;
+ y = a.y;
+ z = a.z;
+
+ return *this;
+}
+
+ID_INLINE void idVec3_t::set( const float x, const float y, const float z ) {
+ this->x = x;
+ this->y = y;
+ this->z = z;
+}
+
+ID_INLINE idVec3_t idVec3_t::operator-( const idVec3_t &a ) const {
+ return idVec3_t( x - a.x, y - a.y, z - a.z );
+}
+
+ID_INLINE float idVec3_t::operator*( const idVec3_t &a ) const {
+ return x * a.x + y * a.y + z * a.z;
+}
+
+ID_INLINE idVec3_t idVec3_t::operator*( const float a ) const {
+ return idVec3_t( x * a, y * a, z * a );
+}
+
+ID_INLINE idVec3_t operator*( const float a, const idVec3_t b ) {
+ return idVec3_t( b.x * a, b.y * a, b.z * a );
+}
+
+ID_INLINE idVec3_t idVec3_t::operator+( const idVec3_t &a ) const {
+ return idVec3_t( x + a.x, y + a.y, z + a.z );
+}
+
+ID_INLINE idVec3_t &idVec3_t::operator+=( const idVec3_t &a ) {
+ x += a.x;
+ y += a.y;
+ z += a.z;
+
+ return *this;
+}
+
+ID_INLINE idVec3_t &idVec3_t::operator-=( const idVec3_t &a ) {
+ x -= a.x;
+ y -= a.y;
+ z -= a.z;
+
+ return *this;
+}
+
+ID_INLINE idVec3_t &idVec3_t::operator*=( const float a ) {
+ x *= a;
+ y *= a;
+ z *= a;
+
+ return *this;
+}
+
+ID_INLINE int idVec3_t::operator==( const idVec3_t &a ) const {
+ if ( Q_fabs( x - a.x ) > EQUAL_EPSILON ) {
+ return false;
+ }
+
+ if ( Q_fabs( y - a.y ) > EQUAL_EPSILON ) {
+ return false;
+ }
+
+ if ( Q_fabs( z - a.z ) > EQUAL_EPSILON ) {
+ return false;
+ }
+
+ return true;
+}
+
+ID_INLINE int idVec3_t::operator!=( const idVec3_t &a ) const {
+ if ( Q_fabs( x - a.x ) > EQUAL_EPSILON ) {
+ return true;
+ }
+
+ if ( Q_fabs( y - a.y ) > EQUAL_EPSILON ) {
+ return true;
+ }
+
+ if ( Q_fabs( z - a.z ) > EQUAL_EPSILON ) {
+ return true;
+ }
+
+ return false;
+}
+
+ID_INLINE idVec3_t idVec3_t::Cross( const idVec3_t &a ) const {
+ return idVec3_t( y * a.z - z * a.y, z * a.x - x * a.z, x * a.y - y * a.x );
+}
+
+ID_INLINE idVec3_t &idVec3_t::Cross( const idVec3_t &a, const idVec3_t &b ) {
+ x = a.y * b.z - a.z * b.y;
+ y = a.z * b.x - a.x * b.z;
+ z = a.x * b.y - a.y * b.x;
+
+ return *this;
+}
+
+ID_INLINE float idVec3_t::Length( void ) const {
+ float length;
+
+ length = x * x + y * y + z * z;
+ return ( float )idSqrt( length );
+}
+
+ID_INLINE float idVec3_t::Normalize( void ) {
+ float length;
+ float ilength;
+
+ length = this->Length();
+ if ( length ) {
+ ilength = 1.0f / length;
+ x *= ilength;
+ y *= ilength;
+ z *= ilength;
+ }
+
+ return length;
+}
+
+ID_INLINE void idVec3_t::Zero( void ) {
+ x = 0.0f;
+ y = 0.0f;
+ z = 0.0f;
+}
+
+ID_INLINE void idVec3_t::Snap( void ) {
+ x = float( int( x ) );
+ y = float( int( y ) );
+ z = float( int( z ) );
+}
+
+/*
+======================
+SnapTowards
+
+Round a vector to integers for more efficient network
+transmission, but make sure that it rounds towards a given point
+rather than blindly truncating. This prevents it from truncating
+into a wall.
+======================
+*/
+ID_INLINE void idVec3_t::SnapTowards( const idVec3_t &to ) {
+ if ( to.x <= x ) {
+ x = float( int( x ) );
+ } else {
+ x = float( int( x ) + 1 );
+ }
+
+ if ( to.y <= y ) {
+ y = float( int( y ) );
+ } else {
+ y = float( int( y ) + 1 );
+ }
+
+ if ( to.z <= z ) {
+ z = float( int( z ) );
+ } else {
+ z = float( int( z ) + 1 );
+ }
+}
+
+//===============================================================
+
+class Bounds {
+public:
+ idVec3_t b[2];
+
+ Bounds();
+ Bounds( const idVec3_t &mins, const idVec3_t &maxs );
+
+ void Clear();
+ void Zero();
+ float Radius(); // radius from origin, not from center
+ idVec3_t Center();
+ void AddPoint( const idVec3_t &v );
+ void AddBounds( const Bounds &bb );
+ bool IsCleared();
+ bool ContainsPoint( const idVec3_t &p );
+ bool IntersectsBounds( const Bounds &b2 ); // touching is NOT intersecting
+};
+
+extern Bounds boundsZero;
+
+ID_INLINE Bounds::Bounds(){
+}
+
+ID_INLINE bool Bounds::IsCleared() {
+ return b[0][0] > b[1][0];
+}
+
+ID_INLINE bool Bounds::ContainsPoint( const idVec3_t &p ) {
+ if ( p[0] < b[0][0] || p[1] < b[0][1] || p[2] < b[0][2]
+ || p[0] > b[1][0] || p[1] > b[1][1] || p[2] > b[1][2] ) {
+ return false;
+ }
+ return true;
+}
+
+ID_INLINE bool Bounds::IntersectsBounds( const Bounds &b2 ) {
+ if ( b2.b[1][0] < b[0][0] || b2.b[1][1] < b[0][1] || b2.b[1][2] < b[0][2]
+ || b2.b[0][0] > b[1][0] || b2.b[0][1] > b[1][1] || b2.b[0][2] > b[1][2] ) {
+ return false;
+ }
+ return true;
+}
+
+ID_INLINE Bounds::Bounds( const idVec3_t &mins, const idVec3_t &maxs ) {
+ b[0] = mins;
+ b[1] = maxs;
+}
+
+ID_INLINE idVec3_t Bounds::Center() {
+ return idVec3_t( ( b[1][0] + b[0][0] ) * 0.5f, ( b[1][1] + b[0][1] ) * 0.5f, ( b[1][2] + b[0][2] ) * 0.5f );
+}
+
+ID_INLINE void Bounds::Clear() {
+ b[0][0] = b[0][1] = b[0][2] = 99999;
+ b[1][0] = b[1][1] = b[1][2] = -99999;
+}
+
+ID_INLINE void Bounds::Zero() {
+ b[0][0] = b[0][1] = b[0][2] =
+ b[1][0] = b[1][1] = b[1][2] = 0;
+}
+
+ID_INLINE void Bounds::AddPoint( const idVec3_t &v ) {
+ if ( v[0] < b[0][0]) {
+ b[0][0] = v[0];
+ }
+ if ( v[0] > b[1][0]) {
+ b[1][0] = v[0];
+ }
+ if ( v[1] < b[0][1] ) {
+ b[0][1] = v[1];
+ }
+ if ( v[1] > b[1][1]) {
+ b[1][1] = v[1];
+ }
+ if ( v[2] < b[0][2] ) {
+ b[0][2] = v[2];
+ }
+ if ( v[2] > b[1][2]) {
+ b[1][2] = v[2];
+ }
+}
+
+
+ID_INLINE void Bounds::AddBounds( const Bounds &bb ) {
+ if ( bb.b[0][0] < b[0][0]) {
+ b[0][0] = bb.b[0][0];
+ }
+ if ( bb.b[0][1] < b[0][1]) {
+ b[0][1] = bb.b[0][1];
+ }
+ if ( bb.b[0][2] < b[0][2]) {
+ b[0][2] = bb.b[0][2];
+ }
+
+ if ( bb.b[1][0] > b[1][0]) {
+ b[1][0] = bb.b[1][0];
+ }
+ if ( bb.b[1][1] > b[1][1]) {
+ b[1][1] = bb.b[1][1];
+ }
+ if ( bb.b[1][2] > b[1][2]) {
+ b[1][2] = bb.b[1][2];
+ }
+}
+
+ID_INLINE float Bounds::Radius( ) {
+ int i;
+ float total;
+ float a, aa;
+
+ total = 0;
+ for (i=0 ; i<3 ; i++) {
+ a = (float)fabs( b[0][i] );
+ aa = (float)fabs( b[1][i] );
+ if ( aa > a ) {
+ a = aa;
+ }
+ total += a * a;
+ }
+
+ return (float)idSqrt( total );
+}
+
+//===============================================================
+
+
+class idVec2_t {
+public:
+ float x;
+ float y;
+
+ operator float *();
+ float operator[]( int index ) const;
+ float &operator[]( int index );
+};
+
+ID_INLINE float idVec2_t::operator[]( int index ) const {
+ return ( &x )[ index ];
+}
+
+ID_INLINE float& idVec2_t::operator[]( int index ) {
+ return ( &x )[ index ];
+}
+
+ID_INLINE idVec2_t::operator float *( void ) {
+ return &x;
+}
+
+class vec4_t : public idVec3_t {
+public:
+#ifndef FAT_VEC3
+ float dist;
+#endif
+ vec4_t();
+ ~vec4_t() {};
+
+ vec4_t( float x, float y, float z, float dist );
+ float operator[]( int index ) const;
+ float &operator[]( int index );
+};
+
+ID_INLINE vec4_t::vec4_t() {}
+ID_INLINE vec4_t::vec4_t( float x, float y, float z, float dist ) {
+ this->x = x;
+ this->y = y;
+ this->z = z;
+ this->dist = dist;
+}
+
+ID_INLINE float vec4_t::operator[]( int index ) const {
+ return ( &x )[ index ];
+}
+
+ID_INLINE float& vec4_t::operator[]( int index ) {
+ return ( &x )[ index ];
+}
+
+
+class idVec5_t : public idVec3_t {
+public:
+ float s;
+ float t;
+ float operator[]( int index ) const;
+ float &operator[]( int index );
+};
+
+
+ID_INLINE float idVec5_t::operator[]( int index ) const {
+ return ( &x )[ index ];
+}
+
+ID_INLINE float& idVec5_t::operator[]( int index ) {
+ return ( &x )[ index ];
+}
+
+#endif /* !__MATH_VECTOR_H__ */
514 CODE-mp/Splines/q_parse.cpp
@@ -0,0 +1,514 @@
+// q_parse.c -- support for parsing text files
+
+#include "q_shared.h"
+
+/*
+============================================================================
+
+PARSING
+
+============================================================================
+*/
+
+// multiple character punctuation tokens
+static const char *punctuation[] = {
+ "+=", "-=", "*=", "/=", "&=", "|=", "++", "--",
+ "&&", "||", "<=", ">=", "==", "!=",
+ NULL
+};
+
+typedef struct {
+ char token[MAX_TOKEN_CHARS];
+ int lines;
+ qboolean ungetToken;
+ char parseFile[MAX_QPATH];
+} parseInfo_t;
+
+#define MAX_PARSE_INFO 16
+static parseInfo_t parseInfo[MAX_PARSE_INFO];
+static int parseInfoNum;
+static parseInfo_t *pi = &parseInfo[0];
+
+/*
+===================
+Com_BeginParseSession
+===================
+*/
+void Com_BeginParseSession( const char *filename ) {
+ if ( parseInfoNum == MAX_PARSE_INFO - 1 ) {
+ Com_Error( ERR_FATAL, "Com_BeginParseSession: session overflow" );
+ }
+ parseInfoNum++;
+ pi = &parseInfo[parseInfoNum];
+
+ pi->lines = 1;
+ Q_strncpyz( pi->parseFile, filename, sizeof( pi->parseFile ) );
+}
+
+/*
+===================
+Com_EndParseSession
+===================
+*/
+void Com_EndParseSession( void ) {
+ if ( parseInfoNum == 0 ) {
+ Com_Error( ERR_FATAL, "Com_EndParseSession: session underflow" );
+ }
+ parseInfoNum--;
+ pi = &parseInfo[parseInfoNum];
+}
+
+/*
+===================
+Com_GetCurrentParseLine
+===================
+*/
+int Com_GetCurrentParseLine( void ) {
+ return pi->lines;
+}
+
+/*
+===================
+Com_ScriptError
+
+Prints the script name and line number in the message
+===================
+*/
+void Com_ScriptError( const char *msg, ... ) {
+ va_list argptr;
+ char string[32000];
+
+ va_start( argptr, msg );
+ vsprintf( string, msg,argptr );
+ va_end( argptr );
+
+ Com_Error( ERR_DROP, "File %s, line %i: %s", pi->parseFile, pi->lines, string );
+}
+
+void Com_ScriptWarning( const char *msg, ... ) {
+ va_list argptr;
+ char string[32000];
+
+ va_start( argptr, msg );
+ vsprintf( string, msg,argptr );
+ va_end( argptr );
+
+ Com_Printf( "File %s, line %i: %s", pi->parseFile, pi->lines, string );
+}
+
+
+/*
+===================
+Com_UngetToken
+
+Calling this will make the next Com_Parse return
+the current token instead of advancing the pointer
+===================
+*/
+void Com_UngetToken( void ) {
+ if ( pi->ungetToken ) {
+ Com_ScriptError( "UngetToken called twice" );
+ }
+ pi->ungetToken = qtrue;
+}
+
+
+static const char *SkipWhitespace( const char (*data), qboolean *hasNewLines ) {
+ int c;
+
+ while( (c = *data) <= ' ') {
+ if( !c ) {
+ return NULL;
+ }
+ if( c == '\n' ) {
+ pi->lines++;
+ *hasNewLines = qtrue;
+ }
+ data++;
+ }
+
+ return data;
+}
+
+/*
+==============
+Com_ParseExt
+
+Parse a token out of a string
+Will never return NULL, just empty strings.
+An empty string will only be returned at end of file.
+
+If "allowLineBreaks" is qtrue then an empty
+string will be returned if the next token is
+a newline.
+==============
+*/
+static char *Com_ParseExt( const char *(*data_p), qboolean allowLineBreaks ) {
+ int c = 0, len;
+ qboolean hasNewLines = qfalse;
+ const char *data;
+ const char **punc;
+
+ if ( !data_p ) {
+ Com_Error( ERR_FATAL, "Com_ParseExt: NULL data_p" );
+ }
+
+ data = *data_p;
+ len = 0;
+ pi->token[0] = 0;
+
+ // make sure incoming data is valid
+ if ( !data ) {
+ *data_p = NULL;
+ return pi->token;
+ }
+
+ // skip any leading whitespace
+ while ( 1 ) {
+ // skip whitespace
+ data = SkipWhitespace( data, &hasNewLines );
+ if ( !data ) {
+ *data_p = NULL;
+ return pi->token;
+ }
+ if ( hasNewLines && !allowLineBreaks ) {
+ *data_p = data;
+ return pi->token;
+ }
+
+ c = *data;
+
+ // skip double slash comments
+ if ( c == '/' && data[1] == '/' ) {
+ while (*data && *data != '\n') {
+ data++;
+ }
+ continue;
+ }
+
+ // skip /* */ comments
+ if ( c=='/' && data[1] == '*' ) {
+ while ( *data && ( *data != '*' || data[1] != '/' ) ) {
+ if( *data == '\n' ) {
+ pi->lines++;
+ }
+ data++;
+ }
+ if ( *data ) {
+ data += 2;
+ }
+ continue;
+ }
+
+ // a real token to parse
+ break;
+ }
+
+ // handle quoted strings
+ if ( c == '\"' ) {
+ data++;
+ while( 1 ) {
+ c = *data++;
+ if ( ( c=='\\' ) && ( *data == '\"' ) ) {
+ // allow quoted strings to use \" to indicate the " character
+ data++;
+ } else if ( c=='\"' || !c ) {
+ pi->token[len] = 0;
+ *data_p = ( char * ) data;
+ return pi->token;
+ } else if( *data == '\n' ) {
+ pi->lines++;
+ }
+ if ( len < MAX_TOKEN_CHARS - 1 ) {
+ pi->token[len] = c;
+ len++;
+ }
+ }
+ }
+
+ // check for a number
+ // is this parsing of negative numbers going to cause expression problems
+ if ( ( c >= '0' && c <= '9' ) || ( c == '-' && data[ 1 ] >= '0' && data[ 1 ] <= '9' ) ||
+ ( c == '.' && data[ 1 ] >= '0' && data[ 1 ] <= '9' ) ) {
+ do {
+
+ if (len < MAX_TOKEN_CHARS - 1) {
+ pi->token[len] = c;
+ len++;
+ }
+ data++;
+
+ c = *data;
+ } while ( ( c >= '0' && c <= '9' ) || c == '.' );
+
+ // parse the exponent
+ if ( c == 'e' || c == 'E' ) {
+ if (len < MAX_TOKEN_CHARS - 1) {
+ pi->token[len] = c;
+ len++;
+ }
+ data++;
+ c = *data;
+
+ if ( c == '-' || c == '+' ) {
+ if (len < MAX_TOKEN_CHARS - 1) {
+ pi->token[len] = c;
+ len++;
+ }
+ data++;
+ c = *data;
+ }
+
+ do {
+ if (len < MAX_TOKEN_CHARS - 1) {
+ pi->token[len] = c;
+ len++;
+ }
+ data++;
+
+ c = *data;
+ } while ( c >= '0' && c <= '9' );
+ }
+
+ if (len == MAX_TOKEN_CHARS) {
+ len = 0;
+ }
+ pi->token[len] = 0;
+
+ *data_p = ( char * ) data;
+ return pi->token;
+ }
+
+ // check for a regular word
+ // we still allow forward and back slashes in name tokens for pathnames
+ // and also colons for drive letters
+ if ( ( c >= 'a' && c <= 'z' ) || ( c >= 'A' && c <= 'Z' ) || c == '_' || c == '/' || c == '\\' ) {
+ do {
+ if (len < MAX_TOKEN_CHARS - 1) {
+ pi->token[len] = c;
+ len++;
+ }
+ data++;
+
+ c = *data;
+ } while ( ( c >= 'a' && c <= 'z' ) || ( c >= 'A' && c <= 'Z' ) || c == '_'
+ || ( c >= '0' && c <= '9' ) || c == '/' || c == '\\' || c == ':' || c == '.' );
+
+ if (len == MAX_TOKEN_CHARS) {
+ len = 0;
+ }
+ pi->token[len] = 0;
+
+ *data_p = ( char * ) data;
+ return pi->token;
+ }
+
+ // check for multi-character punctuation token
+ for ( punc = punctuation ; *punc ; punc++ ) {
+ int l;
+ int j;
+
+ l = strlen( *punc );
+ for ( j = 0 ; j < l ; j++ ) {
+ if ( data[j] != (*punc)[j] ) {
+ break;
+ }
+ }
+ if ( j == l ) {
+ // a valid multi-character punctuation
+ memcpy( pi->token, *punc, l );
+ pi->token[l] = 0;
+ data += l;
+ *data_p = (char *)data;
+ return pi->token;
+ }
+ }
+
+ // single character punctuation
+ pi->token[0] = *data;
+ pi->token[1] = 0;
+ data++;
+ *data_p = (char *)data;
+
+ return pi->token;
+}
+
+/*
+===================
+Com_Parse
+===================
+*/
+const char *Com_Parse( const char *(*data_p) ) {
+ if ( pi->ungetToken ) {
+ pi->ungetToken = qfalse;
+ return pi->token;
+ }
+ return Com_ParseExt( data_p, qtrue );
+}
+
+/*
+===================
+Com_ParseOnLine
+===================
+*/
+const char *Com_ParseOnLine( const char *(*data_p) ) {
+ if ( pi->ungetToken ) {
+ pi->ungetToken = qfalse;
+ return pi->token;
+ }
+ return Com_ParseExt( data_p, qfalse );
+}
+
+
+
+/*
+==================
+Com_MatchToken
+==================
+*/
+void Com_MatchToken( const char *(*buf_p), const char *match, qboolean warning ) {
+ const char *token;
+
+ token = Com_Parse( buf_p );
+ if ( strcmp( token, match ) ) {
+ if (warning) {
+ Com_ScriptWarning( "MatchToken: %s != %s", token, match );
+ } else {
+ Com_ScriptError( "MatchToken: %s != %s", token, match );
+ }
+ }
+}
+
+
+/*
+=================
+Com_SkipBracedSection
+
+The next token should be an open brace.
+Skips until a matching close brace is found.
+Internal brace depths are properly skipped.
+=================
+*/
+void Com_SkipBracedSection( const char *(*program) ) {
+ const char *token;
+ int depth;
+
+ depth = 0;
+ do {
+ token = Com_Parse( program );
+ if( token[1] == 0 ) {
+ if( token[0] == '{' ) {
+ depth++;
+ }
+ else if( token[0] == '}' ) {
+ depth--;
+ }
+ }
+ } while( depth && *program );
+}
+
+/*
+=================
+Com_SkipRestOfLine
+=================
+*/
+void Com_SkipRestOfLine ( const char *(*data) ) {
+ const char *p;
+ int c;
+
+ p = *data;
+ while ( (c = *p++) != 0 ) {
+ if ( c == '\n' ) {
+ pi->lines++;
+ break;
+ }
+ }
+
+ *data = p;
+}
+
+/*
+====================
+Com_ParseRestOfLine
+====================
+*/
+const char *Com_ParseRestOfLine( const char *(*data_p) ) {
+ static char line[MAX_TOKEN_CHARS];
+ const char *token;
+
+ line[0] = 0;
+ while( 1 ) {
+ token = Com_ParseOnLine( data_p );
+ if ( !token[0] ) {
+ break;
+ }
+ if ( line[0] ) {
+ Q_strcat( line, sizeof(line), " " );
+ }
+ Q_strcat( line, sizeof(line), token );
+ }
+
+ return line;
+}
+
+
+float Com_ParseFloat( const char *(*buf_p) ) {
+ const char *token;
+
+ token = Com_Parse( buf_p );
+ if ( !token[0] ) {
+ return 0;
+ }
+ return atof( token );
+}
+
+int Com_ParseInt( const char *(*buf_p) ) {
+ const char *token;
+
+ token = Com_Parse( buf_p );
+ if ( !token[0] ) {
+ return 0;
+ }
+ return atoi( token );
+}
+
+
+
+void Com_Parse1DMatrix( const char *(*buf_p), int x, float *m ) {
+ const char *token;
+ int i;
+
+ Com_MatchToken( buf_p, "(" );
+
+ for (i = 0 ; i < x ; i++) {
+ token = Com_Parse(buf_p);
+ m[i] = atof(token);
+ }
+
+ Com_MatchToken( buf_p, ")" );
+}
+
+void Com_Parse2DMatrix( const char *(*buf_p), int y, int x, float *m ) {
+ int i;
+
+ Com_MatchToken( buf_p, "(" );
+
+ for (i = 0 ; i < y ; i++) {
+ Com_Parse1DMatrix (buf_p, x, m + i * x);
+ }
+
+ Com_MatchToken( buf_p, ")" );
+}
+
+void Com_Parse3DMatrix( const char *(*buf_p), int z, int y, int x, float *m ) {
+ int i;
+
+ Com_MatchToken( buf_p, "(" );
+
+ for (i = 0 ; i < z ; i++) {
+ Com_Parse2DMatrix (buf_p, y, x, m + i * x*y);
+ }
+
+ Com_MatchToken( buf_p, ")" );
+}
+
955 CODE-mp/Splines/q_shared.cpp